\hypertarget{group__EPhysics__Shape}{}\section{E\+Physics Shape}
\label{group__EPhysics__Shape}\index{E\+Physics Shape@{E\+Physics Shape}}


Shapes are used to create bodies with shapes that differ from primitive ones, like box and cylinder.  


\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef struct \+\_\+\+E\+Physics\+\_\+\+Shape \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape}
\begin{DoxyCompactList}\small\item\em Shape handle, represents a shape to be used to create a body. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$ \hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new} (void)
\begin{DoxyCompactList}\small\item\em Create a new shape. \end{DoxyCompactList}\item 
\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} void \hyperlink{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}{ephysics\+\_\+shape\+\_\+del} (\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$shape)
\begin{DoxyCompactList}\small\item\em Delete a shape. \end{DoxyCompactList}\item 
\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\+\_\+shape\+\_\+point\+\_\+add} (\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$shape, double x, double y, double z)
\begin{DoxyCompactList}\small\item\em Add a new point to the shape. \end{DoxyCompactList}\item 
\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$ \hyperlink{group__EPhysics__Shape_ga63339f80d1692ed327238cab5ef7f2a7}{ephysics\+\_\+shape\+\_\+load} (const char $\ast$filename)
\begin{DoxyCompactList}\small\item\em Load the shape from a file. \end{DoxyCompactList}\item 
\hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} \hyperlink{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}{ephysics\+\_\+shape\+\_\+save} (const \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$shape, const char $\ast$filename)
\begin{DoxyCompactList}\small\item\em Save the shape to a file. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Shapes are used to create bodies with shapes that differ from primitive ones, like box and cylinder. 

A shape consists in a group of points, the vertices of the body to be created later with \hyperlink{group__EPhysics__Body_gabe733ecf3e04d267005118ff7291daab}{ephysics\+\_\+body\+\_\+shape\+\_\+add()}.

A new shape is created with \hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new()} and points are set with \hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\+\_\+shape\+\_\+point\+\_\+add()}. A shape can be used to create many bodies. When done, it\textquotesingle{}s required to delete the shape with \hyperlink{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}{ephysics\+\_\+shape\+\_\+del()}.

A shape can be loaded from a file describing it with \hyperlink{group__EPhysics__Shape_ga63339f80d1692ed327238cab5ef7f2a7}{ephysics\+\_\+shape\+\_\+load()}, and can be saved to a file with \hyperlink{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}{ephysics\+\_\+shape\+\_\+save()}. With that shapes can be done or visualized on design applications.

\begin{DoxyNote}{Note}
Using primitive shapes has better perfomance than generic shapes. 

For now, only convex shapes are supported. 
\end{DoxyNote}


\subsection{Typedef Documentation}
\mbox{\Hypertarget{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}\label{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}} 
\index{E\+Physics Shape@{E\+Physics Shape}!E\+Physics\+\_\+\+Shape@{E\+Physics\+\_\+\+Shape}}
\index{E\+Physics\+\_\+\+Shape@{E\+Physics\+\_\+\+Shape}!E\+Physics Shape@{E\+Physics Shape}}
\subsubsection{\texorpdfstring{E\+Physics\+\_\+\+Shape}{EPhysics\_Shape}}
{\footnotesize\ttfamily \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape}}



Shape handle, represents a shape to be used to create a body. 

Created with \hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new()} and deleted with \hyperlink{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}{ephysics\+\_\+shape\+\_\+del()}. 

\subsection{Function Documentation}
\mbox{\Hypertarget{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}\label{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}} 
\index{E\+Physics Shape@{E\+Physics Shape}!ephysics\+\_\+shape\+\_\+new@{ephysics\+\_\+shape\+\_\+new}}
\index{ephysics\+\_\+shape\+\_\+new@{ephysics\+\_\+shape\+\_\+new}!E\+Physics Shape@{E\+Physics Shape}}
\subsubsection{\texorpdfstring{ephysics\+\_\+shape\+\_\+new()}{ephysics\_shape\_new()}}
{\footnotesize\ttfamily \hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape}$\ast$ ephysics\+\_\+shape\+\_\+new (\begin{DoxyParamCaption}\item[{void}]{ }\end{DoxyParamCaption})}



Create a new shape. 

The returned shape initially doesn\textquotesingle{}t has points set, so it\textquotesingle{}s required to set vertices with \hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\+\_\+shape\+\_\+point\+\_\+add()}.

After the shape is completely defined, all the points were added, it\textquotesingle{}s possible to create one or more bodies with \hyperlink{group__EPhysics__Body_gabe733ecf3e04d267005118ff7291daab}{ephysics\+\_\+body\+\_\+shape\+\_\+add()}.

\begin{DoxyReturn}{Returns}
The created shape or {\ttfamily N\+U\+LL} on error.
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}{ephysics\+\_\+shape\+\_\+del()}. 

\hyperlink{group__EPhysics__Shape_ga63339f80d1692ed327238cab5ef7f2a7}{ephysics\+\_\+shape\+\_\+load()}. 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{test_shapes_8c-example}{test\+\_\+shapes.\+c}.\end{Desc}
\mbox{\Hypertarget{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}\label{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}} 
\index{E\+Physics Shape@{E\+Physics Shape}!ephysics\+\_\+shape\+\_\+del@{ephysics\+\_\+shape\+\_\+del}}
\index{ephysics\+\_\+shape\+\_\+del@{ephysics\+\_\+shape\+\_\+del}!E\+Physics Shape@{E\+Physics Shape}}
\subsubsection{\texorpdfstring{ephysics\+\_\+shape\+\_\+del()}{ephysics\_shape\_del()}}
{\footnotesize\ttfamily \hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} void ephysics\+\_\+shape\+\_\+del (\begin{DoxyParamCaption}\item[{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$}]{shape }\end{DoxyParamCaption})}



Delete a shape. 

After a shape is used to create the wanted bodies, it\textquotesingle{}s required to delete it. It won\textquotesingle{}t be deleted automatically by ephysics at any point, even on shutdown. The creator is responsible to free it after usage is concluded.


\begin{DoxyParams}{Parameters}
{\em shape} & The shape to be deleted.\\
\hline
\end{DoxyParams}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new()}. 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{test_shapes_8c-example}{test\+\_\+shapes.\+c}.\end{Desc}
\mbox{\Hypertarget{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}\label{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}} 
\index{E\+Physics Shape@{E\+Physics Shape}!ephysics\+\_\+shape\+\_\+point\+\_\+add@{ephysics\+\_\+shape\+\_\+point\+\_\+add}}
\index{ephysics\+\_\+shape\+\_\+point\+\_\+add@{ephysics\+\_\+shape\+\_\+point\+\_\+add}!E\+Physics Shape@{E\+Physics Shape}}
\subsubsection{\texorpdfstring{ephysics\+\_\+shape\+\_\+point\+\_\+add()}{ephysics\_shape\_point\_add()}}
{\footnotesize\ttfamily \hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} ephysics\+\_\+shape\+\_\+point\+\_\+add (\begin{DoxyParamCaption}\item[{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$}]{shape,  }\item[{double}]{x,  }\item[{double}]{y,  }\item[{double}]{z }\end{DoxyParamCaption})}



Add a new point to the shape. 

Any point can be added to a shape, but only vertices matter. A vertex is a special kind of point that describes a corner of geometric shapes. The final shape will be constructed in such a way it will have all the added points and will be convex.

The center of mass will be the centroid, or geometric center of the shape.

The order of points doesn\textquotesingle{}t matter.

For example, to create a pentagon\+:


\begin{DoxyCode}
\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\_Shape} *shape = \hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\_shape\_new}();

\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 0, 24, -10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 0, 24, 10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 35, 0, -10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 35, 0, 10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 70, 24, -10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 70, 24, 10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 56, 66, -10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 56, 66, 10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 14, 66, -10);
\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}(shape, 14, 66, 10);

\hyperlink{group__EPhysics__Body_gabe733ecf3e04d267005118ff7291daab}{ephysics\_body\_shape\_add}(world, shape);

\hyperlink{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}{ephysics\_shape\_del}(shape);
\end{DoxyCode}



\begin{DoxyParams}{Parameters}
{\em shape} & The shape to be modified. \\
\hline
{\em x} & Point position at x axis. \\
\hline
{\em y} & Point position at y axis. \\
\hline
{\em z} & Point position at z axis. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily E\+I\+N\+A\+\_\+\+T\+R\+UE} on success or E\+I\+N\+A\+\_\+\+F\+A\+L\+SE on error.
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new()}. 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples\+: ]\par
\hyperlink{test_shapes_8c-example}{test\+\_\+shapes.\+c}.\end{Desc}
\mbox{\Hypertarget{group__EPhysics__Shape_ga63339f80d1692ed327238cab5ef7f2a7}\label{group__EPhysics__Shape_ga63339f80d1692ed327238cab5ef7f2a7}} 
\index{E\+Physics Shape@{E\+Physics Shape}!ephysics\+\_\+shape\+\_\+load@{ephysics\+\_\+shape\+\_\+load}}
\index{ephysics\+\_\+shape\+\_\+load@{ephysics\+\_\+shape\+\_\+load}!E\+Physics Shape@{E\+Physics Shape}}
\subsubsection{\texorpdfstring{ephysics\+\_\+shape\+\_\+load()}{ephysics\_shape\_load()}}
{\footnotesize\ttfamily \hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape}$\ast$ ephysics\+\_\+shape\+\_\+load (\begin{DoxyParamCaption}\item[{const char $\ast$}]{filename }\end{DoxyParamCaption})}



Load the shape from a file. 

Useful to edit shapes on design tools and load it from an exported file.

Also it helps to avoid lots of \hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\+\_\+shape\+\_\+point\+\_\+add()} in the code, and keep a better separation between code logic and design stuff.


\begin{DoxyParams}{Parameters}
{\em filename} & The path to the file describing the shape. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The loaded shape or {\ttfamily N\+U\+LL} on error.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
Not implemented yet.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new()} for more details. 

\hyperlink{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}{ephysics\+\_\+shape\+\_\+save()}. 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}\label{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}} 
\index{E\+Physics Shape@{E\+Physics Shape}!ephysics\+\_\+shape\+\_\+save@{ephysics\+\_\+shape\+\_\+save}}
\index{ephysics\+\_\+shape\+\_\+save@{ephysics\+\_\+shape\+\_\+save}!E\+Physics Shape@{E\+Physics Shape}}
\subsubsection{\texorpdfstring{ephysics\+\_\+shape\+\_\+save()}{ephysics\_shape\_save()}}
{\footnotesize\ttfamily \hyperlink{group__Elua_ga3db3556eec8ef18cb8ddb43816974ac8}{E\+A\+PI} \hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool} ephysics\+\_\+shape\+\_\+save (\begin{DoxyParamCaption}\item[{const \hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{E\+Physics\+\_\+\+Shape} $\ast$}]{shape,  }\item[{const char $\ast$}]{filename }\end{DoxyParamCaption})}



Save the shape to a file. 

It can be useful to visualize it on design tools.


\begin{DoxyParams}{Parameters}
{\em shape} & The shape to be saved. \\
\hline
{\em filename} & The path to save the shape. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
{\ttfamily E\+I\+N\+A\+\_\+\+T\+R\+UE} on success or E\+I\+N\+A\+\_\+\+F\+A\+L\+SE on error.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
Not implemented yet.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\hyperlink{group__EPhysics__Shape_ga79ca252f9b15296416c3f73c75efa293}{ephysics\+\_\+shape\+\_\+new()}. 

\hyperlink{group__EPhysics__Shape_ga63339f80d1692ed327238cab5ef7f2a7}{ephysics\+\_\+shape\+\_\+load()}. 
\end{DoxySeeAlso}
