\hypertarget{group__EPhysics__Shape}{}\doxysection{EPhysics Shape}
\label{group__EPhysics__Shape}\index{EPhysics Shape@{EPhysics Shape}}


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


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


\doxysubsection{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 \mbox{\hyperlink{group__EPhysics__Body_gaee1301dfd2548f4774d5e4cb81b14385}{ephysics\+\_\+body\+\_\+shape\+\_\+add()}}.

A new shape is created with \mbox{\hyperlink{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}{ephysics\+\_\+shape\+\_\+new()}} and points are set with \mbox{\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 \mbox{\hyperlink{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}{ephysics\+\_\+shape\+\_\+del()}}.

A shape can be loaded from a file describing it with \mbox{\hyperlink{group__EPhysics__Shape_ga198f9d7121e917084c31e636b110364f}{ephysics\+\_\+shape\+\_\+load()}}, and can be saved to a file with \mbox{\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 performance than generic shapes. 

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


\doxysubsection{Typedef Documentation}
\mbox{\Hypertarget{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}\label{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}} 
\index{EPhysics Shape@{EPhysics Shape}!EPhysics\_Shape@{EPhysics\_Shape}}
\index{EPhysics\_Shape@{EPhysics\_Shape}!EPhysics Shape@{EPhysics Shape}}
\doxysubsubsection{\texorpdfstring{EPhysics\_Shape}{EPhysics\_Shape}}
{\footnotesize\ttfamily \mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\+\_\+\+Shape}}}



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

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

\doxysubsection{Function Documentation}
\mbox{\Hypertarget{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}\label{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}} 
\index{EPhysics Shape@{EPhysics Shape}!ephysics\_shape\_new@{ephysics\_shape\_new}}
\index{ephysics\_shape\_new@{ephysics\_shape\_new}!EPhysics Shape@{EPhysics Shape}}
\doxysubsubsection{\texorpdfstring{ephysics\_shape\_new()}{ephysics\_shape\_new()}}
{\footnotesize\ttfamily EAPI \mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\+\_\+\+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 \mbox{\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 \mbox{\hyperlink{group__EPhysics__Body_gaee1301dfd2548f4774d5e4cb81b14385}{ephysics\+\_\+body\+\_\+shape\+\_\+add()}}.

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

\mbox{\hyperlink{group__EPhysics__Shape_ga198f9d7121e917084c31e636b110364f}{ephysics\+\_\+shape\+\_\+load()}}. 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{test_shapes_8c-example}{test\+\_\+shapes.\+c}}.\end{Desc}
\mbox{\Hypertarget{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}\label{group__EPhysics__Shape_ga9d91574e5cdac7772d6c75c22c32d8a7}} 
\index{EPhysics Shape@{EPhysics Shape}!ephysics\_shape\_del@{ephysics\_shape\_del}}
\index{ephysics\_shape\_del@{ephysics\_shape\_del}!EPhysics Shape@{EPhysics Shape}}
\doxysubsubsection{\texorpdfstring{ephysics\_shape\_del()}{ephysics\_shape\_del()}}
{\footnotesize\ttfamily EAPI void ephysics\+\_\+shape\+\_\+del (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\+\_\+\+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}
\mbox{\hyperlink{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}{ephysics\+\_\+shape\+\_\+new()}}. 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{test_shapes_8c-example}{test\+\_\+shapes.\+c}}.\end{Desc}
\mbox{\Hypertarget{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}\label{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}} 
\index{EPhysics Shape@{EPhysics Shape}!ephysics\_shape\_point\_add@{ephysics\_shape\_point\_add}}
\index{ephysics\_shape\_point\_add@{ephysics\_shape\_point\_add}!EPhysics Shape@{EPhysics Shape}}
\doxysubsubsection{\texorpdfstring{ephysics\_shape\_point\_add()}{ephysics\_shape\_point\_add()}}
{\footnotesize\ttfamily EAPI \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ephysics\+\_\+shape\+\_\+point\+\_\+add (\begin{DoxyParamCaption}\item[{\mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\+\_\+\+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}{0}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\_Shape}}\ *shape\ =\ \mbox{\hyperlink{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}{ephysics\_shape\_new}}();}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 0,\ 24,\ -\/10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 0,\ 24,\ 10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 35,\ 0,\ -\/10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 35,\ 0,\ 10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 70,\ 24,\ -\/10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 70,\ 24,\ 10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 56,\ 66,\ -\/10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 56,\ 66,\ 10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 14,\ 66,\ -\/10);}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Shape_ga2548c7a3aaf658b9be6132f60c1b3948}{ephysics\_shape\_point\_add}}(shape,\ 14,\ 66,\ 10);}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\hyperlink{group__EPhysics__Body_gaee1301dfd2548f4774d5e4cb81b14385}{ephysics\_body\_shape\_add}}(world,\ shape);}
\DoxyCodeLine{}
\DoxyCodeLine{\mbox{\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 EINA\+\_\+\+TRUE} on success or EINA\+\_\+\+FALSE on error.
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}{ephysics\+\_\+shape\+\_\+new()}}. 
\end{DoxySeeAlso}
\begin{Desc}
\item[Examples]\par
\mbox{\hyperlink{test_shapes_8c-example}{test\+\_\+shapes.\+c}}.\end{Desc}
\mbox{\Hypertarget{group__EPhysics__Shape_ga198f9d7121e917084c31e636b110364f}\label{group__EPhysics__Shape_ga198f9d7121e917084c31e636b110364f}} 
\index{EPhysics Shape@{EPhysics Shape}!ephysics\_shape\_load@{ephysics\_shape\_load}}
\index{ephysics\_shape\_load@{ephysics\_shape\_load}!EPhysics Shape@{EPhysics Shape}}
\doxysubsubsection{\texorpdfstring{ephysics\_shape\_load()}{ephysics\_shape\_load()}}
{\footnotesize\ttfamily EAPI \mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\+\_\+\+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 \mbox{\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 NULL} on error.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
Not implemented yet.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}{ephysics\+\_\+shape\+\_\+new()}} for more details. 

\mbox{\hyperlink{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}{ephysics\+\_\+shape\+\_\+save()}}. 
\end{DoxySeeAlso}
\mbox{\Hypertarget{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}\label{group__EPhysics__Shape_ga60c974e4692ed765e0b7ba2e8a5d9819}} 
\index{EPhysics Shape@{EPhysics Shape}!ephysics\_shape\_save@{ephysics\_shape\_save}}
\index{ephysics\_shape\_save@{ephysics\_shape\_save}!EPhysics Shape@{EPhysics Shape}}
\doxysubsubsection{\texorpdfstring{ephysics\_shape\_save()}{ephysics\_shape\_save()}}
{\footnotesize\ttfamily EAPI \mbox{\hyperlink{group__Eina__Types__Group_ga3fe0caf72e93b1bab1ca8ee3ccf3f226}{Eina\+\_\+\+Bool}} ephysics\+\_\+shape\+\_\+save (\begin{DoxyParamCaption}\item[{const \mbox{\hyperlink{group__EPhysics__Shape_gadfcc565af1b4e898f2959292a9089e7e}{EPhysics\+\_\+\+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 EINA\+\_\+\+TRUE} on success or EINA\+\_\+\+FALSE on error.
\end{DoxyReturn}
\begin{DoxyNote}{Note}
Not implemented yet.
\end{DoxyNote}
\begin{DoxySeeAlso}{See also}
\mbox{\hyperlink{group__EPhysics__Shape_gae9e86be43d7e1c4407f6de877950217b}{ephysics\+\_\+shape\+\_\+new()}}. 

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