39 class X3DPrototypeInstance;
49 typedef HAPI::Collision::IntersectionInfo IntersectionInfo;
71 virtual Node* clone (
bool deepCopy=
true,
DeepCopyMap *deepCopyMap = NULL );
77 static Node *newInstance() {
return new N; }
117 bool _override_no_collision =
false,
118 bool _collide_invisible =
false ) :
119 user_data( _user_data ),
120 override_no_collision( _override_no_collision ),
121 collide_invisible( _collide_invisible ) {
122 current_matrix.push( Matrix4f() );
152 geometry_transforms.push_back( getCurrentTransform() );
157 return geometry_transforms;
163 return current_matrix.top();
169 current_matrix.push( current_matrix.top() * matrix );
174 current_matrix.pop();
180 for(
unsigned int i = 0; i < result.size(); ++i ) {
181 result[i].point = geometry_transforms[i] * result[i].point;
182 result[i].normal = geometry_transforms[i].getRotationPart() *
190 bool add_transform =
true ) {
191 result.push_back( temp_result );
192 theNodes.push_back( the_node );
202 geometry_transforms.clear();
203 while( !current_matrix.empty() )
204 current_matrix.pop();
205 current_matrix.push( Matrix4f() );
228 bool _detect_pt_device =
false,
229 void *_user_data = 0,
230 bool _collide_invisible =
false ) :
232 _collide_invisible ),
233 detect_pt_device( _detect_pt_device ) {}
244 list< Node * > x3dptd;
245 list< Node * > lowest_enabled;
246 Matrix4f global_to_local;
252 if( !current_pt_device.empty() )
253 temp_struct = current_pt_device.top();
254 current_pt_device.push( tmp );
255 list< Node * > &tmp_list = current_pt_device.top().x3dptd;
256 for( list< Node * >::iterator i = tmp_list.begin();
257 i != tmp_list.end(); ++i ) {
258 current_pt_device.top().lowest_enabled.push_back( *i );
260 tmp_list.insert( tmp_list.end(),
261 temp_struct.x3dptd.begin(),
262 temp_struct.x3dptd.end() );
267 current_pt_device.pop();
272 if( detect_pt_device && !current_pt_device.empty() ) {
273 geom_ptd_map[ (
unsigned int) result.size() - 1 ] = current_pt_device.top();
277 typedef map<
unsigned int,
278 PointingDeviceResultStruct > GeomX3DPtdMap;
288 NodeIntersectResult::clearData();
289 while( !current_pt_device.empty() )
290 current_pt_device.pop();
295 return !current_pt_device.empty();
310 virtual bool lineIntersect(
const Vec3f &from,
319 virtual void closestPoint(
const Vec3f &p,
330 virtual bool movingSphereIntersect(
H3DFloat radius,
343 virtual Field *getField(
const string &_name )
const;
347 int addDestructCallback(
void (*func)(
Node *,
void * ),
void *args );
351 int removeDestructCallback(
void (*func)(
Node *,
void * ),
void *args );
353 static int getClosestPointIndex( NodeIntersectResult* result, Vec3f& point ){
355 unsigned int index = 0;
356 for(
unsigned int i = 0; i < result->result.size(); ++i ) {
368 template <
class Type>
370 template <
class Type>
372 template<
class RefClass,
class BaseField>
373 friend class RefCountSField;
377 return nr_nodes_alive;
382 return nr_nodes_created;
397 static Node* getClonedInstance (
Node* original,
bool deepCopy, DeepCopyMap& deepCopyMap );
403 void cloneFieldValue (
Field& _from,
Field& _to,
bool deepCopy, DeepCopyMap& deepCopyMap );
407 static int nr_nodes_created;
408 typedef vector< pair< void (*)(
Node *,
void *),
void * > > DestructCallbacks;
409 DestructCallbacks destruct_callbacks;
413 static unsigned int nr_nodes_alive;
Header file for H3DNodeDatabase.
Contains the Inst struct.
Header file for TraverseInfo.
The Field class.
Definition: Field.h:46
Node is the base class for all classes that can be part of the H3D scene-graph.
Definition: Node.h:46
std::map< Node *, Node * > DeepCopyMap
A map type used during a deep copy clone() to map from original nodes to cloned nodes.
Definition: Node.h:53
static int nrNodesCreated()
Returns the number of nodes created in total since the start of the program.
Definition: Node.h:381
virtual void render()
the render() function is used for the depth-first rendering traversal of the scene-graph.
Definition: Node.h:94
X3DPrototypeInstance * getProtoInstanceParent()
If this node is the root node in the proto body of a X3DPrototypeInstance then this will return that ...
Definition: Node.h:82
virtual string defaultXMLContainerField()
Returns the default xml containerField attribute value.
Definition: Node.h:338
static unsigned int nrNodesAlive()
Returns the nr of nodes currently alive, i.e. nodes created but not destructed.
Definition: Node.h:376
void setProtoInstanceParent(X3DPrototypeInstance *p)
Set the X3DPrototypeInstance this node is the the root node if applicaple.
Definition: Node.h:88
TraverseInfo is a structure that is passed along when traversing the scene graph.
Definition: TraverseInfo.h:57
This abstract node type is the base type for all prototype instances in the X3D system.
Definition: X3DPrototypeInstance.h:65
H3D API namespace.
Definition: Anchor.h:38
The H3DNodeDatabase contains a mapping between a name of a Node and the constructor for the Node with...
Definition: H3DNodeDatabase.h:194
Contains a list of Nodes (X3DPointingDeviceNodes) and a transformation matrix from global space to lo...
Definition: Node.h:243
Used as input to lineIntersect functions.
Definition: Node.h:224
virtual void clearData()
Clears data so the struct can be used in a closestPoint function again.
Definition: Node.h:287
bool hasCurrentPointingDevice()
Check if there aer any pointing device sensors added.
Definition: Node.h:294
stack< PointingDeviceResultStruct > current_pt_device
The top of the stack contains the X3DPointingDeviceNodes that is to be considered.
Definition: Node.h:301
bool detect_pt_device
Flag used to know if lineintersect should bother with keeping track of X3DPointingDeviceSensorNodes.
Definition: Node.h:237
GeomX3DPtdMap geom_ptd_map
Used in order to keep track of DEF/USE feature of X3D.
Definition: Node.h:283
LineIntersectResult(bool _override_no_collision=false, bool _detect_pt_device=false, void *_user_data=0, bool _collide_invisible=false)
Constructor.
Definition: Node.h:227
void addPtDevMap()
Add current pointing device struct to geom_ptd_map.
Definition: Node.h:271
void pushCurrentPtDevice(PointingDeviceResultStruct &tmp)
Push struct to current_pt_device stack.
Definition: Node.h:250
void popCurrentPtDevice()
Pop struct from current_pt_device stack.
Definition: Node.h:266
Used as input to intersection functions.
Definition: Node.h:114
bool override_no_collision
Flag used to know if collision function should be called for the children in the Collision Node regar...
Definition: Node.h:142
vector< Node * > theNodes
A vector of pointers to nodes.
Definition: Node.h:127
void addResults(IntersectionInfo &temp_result, Node *the_node, bool add_transform=true)
Convenience function to add results to the struct.
Definition: Node.h:188
virtual void clearData()
Clears data so the struct can be used in a closestPoint function again.
Definition: Node.h:199
void * user_data
Optional user_data in case someone want to do add some extra feature to collision functions in one or...
Definition: Node.h:138
void popTransform()
Remove the top on the stack of current transforms.
Definition: Node.h:173
const Matrix4f & getCurrentTransform()
Get the current matrix that transforms from local coordinate space to global coordinate space.
Definition: Node.h:162
const vector< Matrix4f > & getGeometryTransforms()
Get the info in geometry_transforms.
Definition: Node.h:156
vector< IntersectionInfo > result
A vector of HAPI::IntersectionInfo that stores result of intersection such as point and normal.
Definition: Node.h:134
void transformResult()
Transforms point and normal in the IntersectionInfo vector from local to global space.
Definition: Node.h:179
vector< Matrix4f > geometry_transforms
A vector of matrices from the local coordinate space to global space for each node that the line inte...
Definition: Node.h:212
stack< Matrix4f > current_matrix
The top of the stack is the current matrix that transforms from the local coordinate space where this...
Definition: Node.h:217
void pushTransform(const Matrix4f &matrix)
Push onto stack of current transforms.
Definition: Node.h:168
bool collide_invisible
Flag used to know if collision function should be called for the children in a ToogleGroup Node even ...
Definition: Node.h:147
void addTransform()
Adds the current transform from local coordinate space to global coordinate space to geometry_transfo...
Definition: Node.h:151