next up previous contents index
Next: Geometric primitives Up: Description of an obstacle Previous: Description of an obstacle

General polyhedron

A general polyhedron description always starts by the function void p3d_add_desc_poly (char name[20])   with the name of the polyhedron poly_name as an input. p3d_add_desc _poly calls the function p3d_poly *p3d_poly_beg_poly(char name[20])   with the name poly _name as an input and stores this new polyhedron as the current polyhedron of the current object. The function p3d_poly_beg_poly allocates a polyhedron structure p3d_poly (cf Annex gif) of name poly_name , initializes it, and returns it as an output.

The vertices of the polyhedron poly_name are the described one by one, using the function void p3d_add_desc_vert(double x, double y, double z)  . The function p3d_add_desc_vert calls the function void p3d_poly_add_vert(p3d_poly *poly, float x, float y, float z)   with x, y, z and the current polyhedron of the current object as inputs. The function void p3d_poly_add_vert numbers the vertex (x,y,z), adds it to the current polyhedron and updates its bounding box.

Once all the vertices have been described, we must describe the faces, using the numbers of the vertices. A face description is a list of integer a b c d ... where the integers a, b, c, d, ... must be the numbers of the vertices of the face, in the counter clockwise order if you face the exterior normal (cf Fig. gif).

   figure137
Figure: Description of a face of a general polyhedron

Those numbers must be stored in an array of integer so the function void p3d_add _desc_face(int *listeV, int nb_Vert)  can be called. The function p3d_add_desc _face calls the function void p3d_poly_add_face (p3d_poly *poly, int *listeV, int nb_Vert)   with the list of vertices of the face, the number of vertices in the list and the current polyhedron of the current object as inputs. The function p3d_poly_add_face builds the face of the current polyhedron.

Once all the faces have been described, the user must close the description of the current polyhedron by the function void p3d_end_desc_poly(void) . This function calls the function void p3d_poly_end_poly(p3d_poly *poly)   with the current polyhedron as an input, udates the number of polyhedron of the current object and its bounding box and places the current polyhedron in the array of polyhedrons of the current object. The function void p3d_poly_end_poly creates the edges of the polyhedron and finishes its initialization.

This decription of a polyhedron can be very useful for a polyhedron of specific or unusual shape, but most of the time we use regular polyhedron. Move3d proposes a library of regular polyhedron called primitives that simplify the description of polyhedrons.


next up previous contents index
Next: Geometric primitives Up: Description of an obstacle Previous: Description of an obstacle

Nicola Simeon
Fri Oct 27 09:07:38 MET DST 2000