![]() |
![]() |
![]() |
V_Sim API - Reference Manual | ![]() |
---|---|---|---|---|
Top | Description | Object Hierarchy | Signals |
#define PLANE_TYPE #define PLANE (obj) #define PLANE_CLASS (klass) #define IS_PLANE_TYPE (obj) #define IS_PLANE_CLASS (klass) #define PLANE_GET_CLASS (obj) typedef PlaneClass; Plane; GType plane_get_type (void
); enum Plane_hidingMode; #define PLANE_SIDE_PLUS #define PLANE_SIDE_MINUS #define PLANE_SIDE_NONE Plane* planeNew (float vertices[8][3]
,float vect[3]
,float dist
,ToolColor *color
); Plane* planeNew_undefined (void
); gboolean planeSet_normalVector (Plane *plane
,float vect[3]
); gboolean planeSet_distanceFromOrigin (Plane *plane
,float dist
); gboolean planeSet_color (Plane *plane
,ToolColor *color
); void planeSet_box (Plane *plane
,float vertices[8][3]
); int planeShowHide (Plane *plane
,VisuData *visuData
,gboolean hide
,float side
); void planeDraw (Plane *plane
); void planeGet_basis (Plane *plane
,float xyz[2][3]
,float center[3]
); GList* planeGet_intersection (Plane *plane
); float* planeGet_reducedIntersection (Plane *plane
,guint *nVals
); void planeGet_nVectUser (Plane *plane
,float *vect
); void planeGet_nVect (Plane *plane
,float *vect
); void planeGet_distanceFromOrigin (Plane *plane
,float *dist
); void planeGet_color (Plane *plane
,ToolColor **color
); int planeSet_hiddenState (Plane *plane
,int side
); int planeGet_hiddenState (Plane *plane
); int planeSet_rendered (Plane *plane
,gboolean rendered
); gboolean planeGet_rendered (Plane *plane
); gboolean planeGet_cross (Plane *plane
,float pointA[3]
,float pointB[3]
,float *lambda
); void planesDraw_list (Plane **list
,int openGLId
); int planeShowHide_all (VisuData *visuData
,Plane **listOfPlanes
); gboolean planesGet_visibility (Plane **listOfPlanes
,float point[3]
); gboolean planesGet_intersection (Plane **listOfPlanes
,float pointA[3]
,float pointB[3]
,float inter[3]
,gboolean inside
); gboolean planesGet_orderedIntersections (int nPlanes
,Plane **listOfPlanes
,float pointA[3]
,float pointB[3]
,float *inter
,int *index
); int planeSet_hidingMode (Plane_hidingMode mode
); gboolean planesParse_XMLFile (gchar *filename
,Plane ***list
,GError **error
); gboolean planesExport_XMLFile (gchar *filename
,Plane **list
,GError **error
);
A Plane is a GObject. It is defined by its normal vector and
the distance of the plane with the origin (see
planeSet_normalVector()
and planeSet_distanceFromOrigin()
). When
these informations are given and an VisuOpenGLView is used to render
the plane, V_Sim computes the intersections of the plane with the
bounding box (see planeGet_intersection()
).
Planes can be used to hide nodes defining their
planeSet_hiddenState()
and planeSet_hidingMode()
. A list of planes
can also be exported or imported from an XML file using
planesExport_XMLFile()
and planesParse_XMLFile()
.
Planes can have transparency but the support of it is limited to one plane. If several planes are drawn with transparency, they may hide each other because of the implementation of transparency in OpenGL (planes are treated as single polygons).
#define PLANE(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, PLANE_TYPE, Plane))
Cast the given obj
into Plane type.
|
a GObject to cast. |
#define PLANE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST(klass, PLANE_TYPE, PlaneClass))
Cast the given klass
into PlaneClass.
|
a GObjectClass to cast. |
#define IS_PLANE_TYPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, PLANE_TYPE))
Test if the given ogj
is of the type of Plane object.
|
a GObject to test. |
#define IS_PLANE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE(klass, PLANE_TYPE))
Test if the given klass
is of the type of PlaneClass class.
|
a GObjectClass to test. |
#define PLANE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS(obj, PLANE_TYPE, PlaneClass))
It returns the class of the given obj
.
|
a GObject to get the class of. |
GType plane_get_type (void
);
This method returns the type of Plane, use PLANE_TYPE instead.
Returns : |
the type of Plane. |
typedef enum { plane_hideUnion, plane_hideInter, plane_nbHidingMode } Plane_hidingMode;
Enum used to address different hiding modes. See planeSet_hidingMode()
for
further details.
#define PLANE_SIDE_PLUS +1
This is a key that defines which side is hidden by the plane. For this value, the side is the one pointed by the normal vector.
#define PLANE_SIDE_MINUS -1
This is a key that defines which side is hidden by the plane. For this value, the side is the one at the opposite of the one pointed by the normal vector.
#define PLANE_SIDE_NONE 0
This is a key that defines which side is hidden by the plane. For this value, no node is hidden.
Plane* planeNew (float vertices[8][3]
,float vect[3]
,float dist
,ToolColor *color
);
Create a plane with the specified attributes.
|
the coordinates that describes the rendering box ; |
|
three values defining the normal vector (unitary or not) ; |
|
the distance between origin and intersection of the plane and the line made by origin and normal vector ; |
|
a ToolColor. |
Returns : |
a newly allocated Plane structure. |
Plane* planeNew_undefined (void
);
Create a new plane with default values. This plane can't be
rendered directly and one needs to computes its intersection with
the bounding box before using planeComputeInter()
.
Returns : |
a newly allocated Plane structure. |
gboolean planeSet_normalVector (Plane *plane
,float vect[3]
);
Change the normal vector defining the orientation of the plane.
|
a Plane object ; |
|
three values defining the normal vector (unitary or not). |
Returns : |
1 if the intersections should be recalculated by
a call to planeComputeInter() , 0 if not. Or -1 if there is
an error.
|
gboolean planeSet_distanceFromOrigin (Plane *plane
,float dist
);
Change the position of the plane.
|
a Plane object ; |
|
the distance between origin and intersection of the plane and the line made by origin and normal vector. |
Returns : |
1 if the intersections should be recalculated by
a call to planeComputeInter() , 0 if not. Or -1 if there is
an error.
|
gboolean planeSet_color (Plane *plane
,ToolColor *color
);
Change the color of the plane.
void planeSet_box (Plane *plane
,float vertices[8][3]
);
This method is used to fit plane
in a box for rendering
purpose. It also computes the intersections between the bounding
box and the plane.
|
a Plane ; |
|
the vertices that describe the rendering box. |
Since 3.6
int planeShowHide (Plane *plane
,VisuData *visuData
,gboolean hide
,float side
);
A call to this method change the visibility flag of all nodes of the given VisuData. Notice that this method makes a call to visu_data_createAllNodes if necessary.
|
a Plane ; |
|
a VisuData which show or hide nodes to; |
|
a boolean, TRUE to hide elements, FALSE to return them to visibility ; |
|
give a positive number to hide elements in the same side that the normal vector, a negative number will hide the other nodes. |
Returns : |
1 if the calling method should ask for redraw, 0 otherwise. |
void planeDraw (Plane *plane
);
Call OpenGL primitives to draw the plane.
|
a Plane. |
void planeGet_basis (Plane *plane
,float xyz[2][3]
,float center[3]
);
Stores the coordinates of barycentre of the plane in center
and
provide coordinates of two orthogonal vector in the plane. The planeComputeInter()
should have been called before.
|
a Plane ; |
|
two vectors. |
|
a point in cartesian coordinates. |
GList* planeGet_intersection (Plane *plane
);
The list of intersection between the plane and the box is made of
float[3]. The planeComputeInter()
should have been called before.
|
a Plane. |
Returns : |
a list of float[3] elements. This list is owned by V_Sim. |
float* planeGet_reducedIntersection (Plane *plane
,guint *nVals
);
This routine returns the coordinates in the plane
basis set of its
intersections with a box (see planeSet_box()
). The coordinates are
appended in the return array which length is stored in nVals
.
|
a Plane object. |
|
a location for an integer. |
Returns : |
a newly allocated array of nVals * 2 values. Free it with
g_free() .
|
Since 3.6
void planeGet_nVectUser (Plane *plane
,float *vect
);
Stores the coordinates of the normal vector in vec
of the plane. It returns the values
given by the user, not the normalized vaues.
|
a Plane. |
|
an already alloacted (size 3) float array. |
void planeGet_nVect (Plane *plane
,float *vect
);
Stores the coordinates of the normal vector in vect
of the plane.
It returns the normalized values.
|
a Plane. |
|
an already alloacted (size 3) float array. |
void planeGet_distanceFromOrigin (Plane *plane
,float *dist
);
Stores the distance of the plane to the origin.
|
a Plane ; |
|
a float location to store the value. |
void planeGet_color (Plane *plane
,ToolColor **color
);
Stores the color of the plane.
int planeSet_hiddenState (Plane *plane
,int side
);
The plane can hide the nodes on one of its side.
The side
argument can be PLANE_SIDE_PLUS or PLANE_SIDE_MINUS or
PLANE_SIDE_NONE. It codes the side of the plane which hides the nodes.
If PLANE_SIDE_NONE is selected all nodes are rendered.
|
a Plane ; |
|
a key, PLANE_SIDE_NONE, PLANE_SIDE_PLUS or PLANE_SIDE_MINUS. |
Returns : |
1 if planeShowHide_all() should be called.
|
int planeGet_hiddenState (Plane *plane
);
The plane can hide the nodes on one of its side. this
method get the status for the given plane
.
|
a Plane. |
Returns : |
the state, defined by PLANE_SIDE_PLUS or PLANE_SIDE_MINUS or PLANE_SIDE_NONE. |
int planeSet_rendered (Plane *plane
,gboolean rendered
);
Change the visibility of the plane.
|
a Plane ; |
|
TRUE to make the plane drawable. |
Returns : |
1 if planeShowHide_all() should be called.
|
gboolean planeGet_rendered (Plane *plane
);
Get the visibility of a plane.
|
a Plane. |
Returns : |
TRUE if the plane is visible. |
gboolean planeGet_cross (Plane *plane
,float pointA[3]
,float pointB[3]
,float *lambda
);
Given the line [AB], it looks for an intersection with plane
. If
lambda is provided, it gives the position of the intersection
(lambda = 0 means A, lambda = 1 means B).
|
a Plane object. |
|
a point. |
|
another point. |
|
a location to store a float (can be NULL). |
Returns : |
TRUE if any crossing point is found. |
Since 3.6
void planesDraw_list (Plane **list
,int openGLId
);
Call OpenGL primitives to draw each plane of the given list. It's
a convenient wrapper around planeDraw()
for a list.
|
an array of Plane (NULL terminated). |
|
the OpenGL list to draw to. |
int planeShowHide_all (VisuData *visuData
,Plane **listOfPlanes
);
This method test for each node if it is hidden or not by the combination of all the given planes.
|
a VisuData which show or hide nodes to; |
|
an array of Plane, NULL terminated. |
Returns : |
1 if visu_data_createAllNodes() should be called.
|
gboolean planesGet_visibility (Plane **listOfPlanes
,float point[3]
);
Compute the visibility of the given point
, following the masking scheme
of the given plane list.
|
an array of Plane, NULL terminated ; |
|
three cartesian coordinates. |
Returns : |
TRUE if the point is not masked. |
gboolean planesGet_intersection (Plane **listOfPlanes
,float pointA[3]
,float pointB[3]
,float inter[3]
,gboolean inside
);
Compute the location of the intersection point of segment AB with list of
planes listOfPlanes
. If there are several intersections, the closest to
point A is returned. If inside
is TRUE, then the intersection
point must be within the line [AB].
|
an array of Plane, NULL terminated ; |
|
three cartesian coordinates. |
|
three cartesian coordinates. |
|
a location to store the intersection point. |
|
a boolean. |
Returns : |
TRUE if there is an intersection. |
gboolean planesGet_orderedIntersections (int nPlanes
,Plane **listOfPlanes
,float pointA[3]
,float pointB[3]
,float *inter
,int *index
);
Compute the location of the intersection points of segment AB with list of
planes listOfPlanes
. If there are several intersections, they are ordered
by the proximity to point A.
|
the number of planes (must be consistent with the number of planes in listOfPlanes!) |
|
an array of Plane, NULL terminated ; |
|
three cartesian coordinates. |
|
three cartesian coordinates. |
|
a pointer to the location to store the intersection points. Supposing you know the number of intersection points ! |
|
a pointer to the location to store the indices of ordering of the planes. |
Returns : |
TRUE if the intersections are found. |
int planeSet_hidingMode (Plane_hidingMode mode
);
This method is used to set the hiding mode flag. In union mode, elements
are not drwn if they are hidden by one plane at least. In intersection mode,
elements are only hidden if masked by all planes. This flag has no
relevence if planeShowHide()
is used, but only if planeShowHide_all()
is
called.
|
a value related to the hiding mode (look at the enum Plane_hidingMode). |
Returns : |
1 if planeShowHide_all() should be called.
|
gboolean planesParse_XMLFile (gchar *filename
,Plane ***list
,GError **error
);
Read the given file (syntax in XML) and create a list of planes. This list is an
allocated array that should be deallocated with g_free()
. This array has always
one argument, since it is NULL terminated.
|
the file to parse ; |
|
a pointer to store the parsed list (will be allocated and NULL terminated) ; |
|
a pointer to store the error (can be NULL). |
Returns : |
TRUE if everything goes right, if not and error (if not NULL)
is set and contains the message of the error.
|
gboolean planesExport_XMLFile (gchar *filename
,Plane **list
,GError **error
);
Export in XML format the given list of planes to the given file.
|
the file to export to ; |
|
an array (NULL terminated) to export ; |
|
a pointer to store the error (can be NULL). |
Returns : |
TRUE if everything goes right, if not and error (if not NULL)
is set and contains the message of the error.
|
"moved"
signalvoid user_function (Plane *plane, gpointer user_data) : Run Last / No Recursion / No Hooks
This signal is emitted each time the plane position is changed (either distance or normal).
|
the object emitting the signal. |
|
user data set when the signal handler was connected. |
Since 3.3