Node.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  1. #ifndef NODE_H_
  2. #define NODE_H_
  3. #include "Transform.h"
  4. #include "Camera.h"
  5. #include "Light.h"
  6. #include "Model.h"
  7. #include "Form.h"
  8. #include "ParticleEmitter.h"
  9. #include "PhysicsRigidBody.h"
  10. #include "PhysicsCollisionObject.h"
  11. #include "BoundingBox.h"
  12. #include "AIAgent.h"
  13. namespace gameplay
  14. {
  15. class AudioSource;
  16. class Bundle;
  17. class Scene;
  18. class Form;
  19. class Terrain;
  20. /**
  21. * Defines a basic hierarchical structure of transformation spaces.
  22. */
  23. class Node : public Transform, public Ref
  24. {
  25. friend class Scene;
  26. friend class Bundle;
  27. friend class MeshSkin;
  28. public:
  29. /**
  30. * Defines the types of nodes.
  31. */
  32. enum Type
  33. {
  34. NODE = 1,
  35. JOINT
  36. };
  37. /**
  38. * Creates a new node with the specified ID.
  39. *
  40. * @param id The ID for the new node.
  41. * @script{create}
  42. */
  43. static Node* create(const char* id = NULL);
  44. /**
  45. * Gets the identifier for the node.
  46. *
  47. * @return The node identifier.
  48. */
  49. const char* getId() const;
  50. /**
  51. * Sets the identifier for the node.
  52. *
  53. * @param id The identifier to set for the node.
  54. */
  55. void setId(const char* id);
  56. /**
  57. * Returns the type of the node.
  58. */
  59. virtual Node::Type getType() const;
  60. /**
  61. * Adds a child node.
  62. *
  63. * @param child The child to add.
  64. */
  65. virtual void addChild(Node* child);
  66. /**
  67. * Removes a child node.
  68. *
  69. * @param child The child to remove.
  70. */
  71. virtual void removeChild(Node* child);
  72. /**
  73. * Removes all child nodes.
  74. */
  75. virtual void removeAllChildren();
  76. /**
  77. * Returns the first child for this node.
  78. *
  79. * @return The first child.
  80. */
  81. Node* getFirstChild() const;
  82. /**
  83. * Returns the first sibling of this node.
  84. *
  85. * @return The first sibling.
  86. */
  87. Node* getNextSibling() const;
  88. /**
  89. * Returns the previous sibling to this node.
  90. *
  91. * @return The previous sibling.
  92. */
  93. Node* getPreviousSibling() const;
  94. /**
  95. * Returns the parent of this node.
  96. *
  97. * @return The parent.
  98. */
  99. Node* getParent() const;
  100. /**
  101. * Determines if a custom tag with the specified name is set.
  102. *
  103. * @param name Name of the tag to query.
  104. *
  105. * @return true if the tag is set, false otherwise.
  106. */
  107. bool hasTag(const char* name) const;
  108. /**
  109. * Returns the value of the custom tag with the given name.
  110. *
  111. * @param name Name of the tag to return.
  112. *
  113. * @return The value of the given tag, or NULL if the tag is not set.
  114. */
  115. const char* getTag(const char* name) const;
  116. /**
  117. * Sets a custom tag on this Node.
  118. *
  119. * Custom tags can be used for a variety of purposes within a game. For example,
  120. * a tag called "transparent" can be added to nodes, to indicate which nodes in
  121. * a scene are transparent. This tag can then be read during rendering to sort
  122. * transparent and opaque objects for correct drawing order. Another example
  123. * is using a "visible" tag to mark nodes as invisible to be skipped during
  124. * rendering.
  125. *
  126. * Setting a tag to NULL removes the tag from the Node.
  127. *
  128. * @param name Name of the tag to set.
  129. * @param value Optional value of the tag (empty string by default).
  130. */
  131. void setTag(const char* name, const char* value = "");
  132. /**
  133. * Returns the user pointer for this node.
  134. *
  135. * @return The user pointer for this node.
  136. * @see setUserPointer(void*)
  137. * @script{ignore}
  138. */
  139. void* getUserPointer() const;
  140. /**
  141. * Sets the user pointer for this node.
  142. *
  143. * The user pointer is initially NULL and can be set to anything.
  144. * This is normally used to store game-specific data, such as
  145. * game state for a particular node. For example, attributes
  146. * for a game character, such as hit points, stamina, etc can
  147. * be defined in a game structure and stored in this field.
  148. *
  149. * When a node is deleted, the (optional) cleanup callback
  150. * function passed to this function is called to allow the
  151. * user to free any memory associated with the user pointer.
  152. *
  153. * @param pointer User pointer.
  154. * @param cleanupCallback Optional callback that is called when the
  155. * Node is being destroyed (or when the user pointer changes),
  156. * to allow the user to cleanup any memory associated with the
  157. * user pointer.
  158. * @script{ignore}
  159. */
  160. void setUserPointer(void* pointer, void (*cleanupCallback)(void*) = NULL);
  161. /**
  162. * Returns the number of direct children of this item.
  163. *
  164. * @return The number of children.
  165. */
  166. unsigned int getChildCount() const;
  167. /**
  168. * Returns the first child node that matches the given ID.
  169. *
  170. * This method checks the specified ID against its immediate child nodes
  171. * but does not check the ID against itself.
  172. * If recursive is true, it also traverses the Node's hierarchy with a breadth first search.
  173. *
  174. * @param id The ID of the child to find.
  175. * @param recursive True to search recursively all the node's children, false for only direct children.
  176. * @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
  177. * or false if nodes that start with the given ID are returned.
  178. *
  179. * @return The Node found or NULL if not found.
  180. */
  181. Node* findNode(const char* id, bool recursive = true, bool exactMatch = true) const;
  182. /**
  183. * Returns all child nodes that match the given ID.
  184. *
  185. * @param id The ID of the node to find.
  186. * @param nodes A vector of nodes to be populated with matches.
  187. * @param recursive true if a recursive search should be performed, false otherwise.
  188. * @param exactMatch true if only nodes whose ID exactly matches the specified ID are returned,
  189. * or false if nodes that start with the given ID are returned.
  190. *
  191. * @return The number of matches found.
  192. * @script{ignore}
  193. */
  194. unsigned int findNodes(const char* id, std::vector<Node*>& nodes, bool recursive = true, bool exactMatch = true) const;
  195. /**
  196. * Gets the scene.
  197. *
  198. * @return The scene.
  199. */
  200. Scene* getScene() const;
  201. /**
  202. * Gets the top level node in this node's parent hierarchy.
  203. */
  204. Node* getRootNode() const;
  205. /**
  206. * Gets the world matrix corresponding to this node.
  207. *
  208. * @return The world matrix of this node.
  209. */
  210. virtual const Matrix& getWorldMatrix() const;
  211. /**
  212. * Gets the world view matrix corresponding to this node.
  213. *
  214. * @return The world view matrix of this node.
  215. */
  216. const Matrix& getWorldViewMatrix() const;
  217. /**
  218. * Gets the inverse transpose world matrix corresponding to this node.
  219. *
  220. * This matrix is typically used to transform normal vectors into world space.
  221. *
  222. * @return The inverse world matrix of this node.
  223. */
  224. const Matrix& getInverseTransposeWorldMatrix() const;
  225. /**
  226. * Gets the inverse transpose world view matrix corresponding to this node.
  227. *
  228. * This matrix is typically used to transform normal vectors into view space.
  229. *
  230. * @return The inverse world view matrix of this node.
  231. */
  232. const Matrix& getInverseTransposeWorldViewMatrix() const;
  233. /**
  234. * Gets the view matrix corresponding to this node based
  235. * on the scene's active camera.
  236. *
  237. * @return The view matrix of this node.
  238. */
  239. const Matrix& getViewMatrix() const;
  240. /**
  241. * Gets the inverse view matrix corresponding to this node based
  242. * on the scene's active camera.
  243. *
  244. * @return The inverse view matrix of this node.
  245. */
  246. const Matrix& getInverseViewMatrix() const;
  247. /**
  248. * Gets the projection matrix corresponding to this node based
  249. * on the scene's active camera.
  250. *
  251. * @return The projection matrix of this node.
  252. */
  253. const Matrix& getProjectionMatrix() const;
  254. /**
  255. * Gets the view * projection matrix corresponding to this node based
  256. * on the scene's active camera.
  257. *
  258. * @return The view * projection matrix of this node.
  259. */
  260. const Matrix& getViewProjectionMatrix() const;
  261. /**
  262. * Gets the inverse view * projection matrix corresponding to this node based
  263. * on the scene's active camera.
  264. *
  265. * @return The inverse view * projection matrix of this node.
  266. */
  267. const Matrix& getInverseViewProjectionMatrix() const;
  268. /**
  269. * Gets the world * view * projection matrix corresponding to this node based
  270. * on the scene's active camera.
  271. *
  272. * @return The world * view * projection matrix of this node.
  273. */
  274. const Matrix& getWorldViewProjectionMatrix() const;
  275. /**
  276. * Gets the translation vector (or position) of this Node in world space.
  277. *
  278. * @return The world translation vector.
  279. */
  280. Vector3 getTranslationWorld() const;
  281. /**
  282. * Gets the translation vector (or position) of this Node in view space.
  283. *
  284. * @return The view space translation vector.
  285. */
  286. Vector3 getTranslationView() const;
  287. /**
  288. * Returns the forward vector of the Node in world space.
  289. *
  290. * @return The forward vector in world space.
  291. */
  292. Vector3 getForwardVectorWorld() const;
  293. /**
  294. * Returns the forward vector of the Node in view space.
  295. *
  296. * @return The forward vector in view space.
  297. */
  298. Vector3 getForwardVectorView() const;
  299. /**
  300. * Returns the right vector of the Node in world space.
  301. *
  302. * @return The right vector in world space.
  303. */
  304. Vector3 getRightVectorWorld() const;
  305. /**
  306. * Returns the up vector of the Node in world space.
  307. *
  308. * @return The up vector in world space.
  309. */
  310. Vector3 getUpVectorWorld() const;
  311. /**
  312. * Returns the translation vector of the currently active camera for this node's scene.
  313. *
  314. * @return The translation vector of the scene's active camera.
  315. */
  316. Vector3 getActiveCameraTranslationWorld() const;
  317. /**
  318. * Returns the view-space translation vector of the currently active camera for this node's scene.
  319. *
  320. * @return The translation vector of the scene's active camera, in view-space.
  321. */
  322. Vector3 getActiveCameraTranslationView() const;
  323. /**
  324. * Gets the first animation in the node hierarchy with the specified ID.
  325. *
  326. * @param id The ID of the animation to get. Returns the first animation if ID is NULL.
  327. * @return The first animation with the specified ID.
  328. */
  329. Animation* getAnimation(const char* id = NULL) const;
  330. /**
  331. * Returns the pointer to this node's camera.
  332. *
  333. * @return The pointer to this node's camera or NULL.
  334. */
  335. Camera* getCamera() const;
  336. /**
  337. * Assigns a camera to this node.
  338. *
  339. * This will increase the reference count of the new camera and decrease
  340. * the reference count of the old camera.
  341. *
  342. * @param camera A pointer to a camera. May be NULL.
  343. */
  344. void setCamera(Camera* camera);
  345. /**
  346. * Returns the pointer to this node's light.
  347. *
  348. * @return The pointer to this node's light or NULL.
  349. */
  350. Light* getLight() const;
  351. /**
  352. * Assigns a light to this node.
  353. *
  354. * This will increase the reference count of the new light and decrease
  355. * the reference count of the old light.
  356. *
  357. * @param light The new light. May be NULL.
  358. */
  359. void setLight(Light* light);
  360. /**
  361. * Returns the pointer to this node's model.
  362. *
  363. * @return The pointer to this node's model or NULL.
  364. */
  365. Model* getModel() const;
  366. /**
  367. * Assigns a model to this node.
  368. *
  369. * This will increase the reference count of the new model and decrease
  370. * the reference count of the old model.
  371. *
  372. * @param model The new model. May be NULL.
  373. */
  374. void setModel(Model* model);
  375. /**
  376. * Returns the pointer to this node's terrain.
  377. *
  378. * @return The pointer to this node's terrain.
  379. */
  380. Terrain* getTerrain() const;
  381. /**
  382. * Assigns a terrain to this node.
  383. *
  384. * This will increase the reference count of the new terrain and decrease
  385. * the reference count of the old terrain.
  386. *
  387. * @param terrain The new terrain. May be NULL.
  388. */
  389. void setTerrain(Terrain* terrain);
  390. /**
  391. * Returns the pointer to this node's form.
  392. *
  393. * @return The pointer to this node's form or NULL.
  394. */
  395. Form* getForm() const;
  396. /**
  397. * Assigns a form to this node.
  398. *
  399. * @param form The form pointer. May be NULL.
  400. */
  401. void setForm(Form* form);
  402. /**
  403. * Returns the pointer to this node's audio source.
  404. *
  405. * @return The pointer to this node's audio source or NULL.
  406. */
  407. AudioSource* getAudioSource() const;
  408. /**
  409. * Assigns an audio source to this node.
  410. *
  411. * This will increase the reference count of the new audio source and decrease
  412. * the reference count of the old audio source.
  413. *
  414. * @param audio The new audio source. May be NULL.
  415. */
  416. void setAudioSource(AudioSource* audio);
  417. /**
  418. * Returns the pointer to this node's particle emitter.
  419. *
  420. * @return The pointer to this node's particle emitter or NULL.
  421. */
  422. ParticleEmitter* getParticleEmitter() const;
  423. /**
  424. * Assigns a particle emitter to this node.
  425. *
  426. * This will increase the reference count of the new particle emitter and decrease
  427. * the reference count of the old particle emitter.
  428. *
  429. * @param emitter The new particle emitter. May be NULL.
  430. */
  431. void setParticleEmitter(ParticleEmitter* emitter);
  432. /**
  433. * Returns the pointer to this node's physics collision object.
  434. *
  435. * The type of the returned collision object can be queried using
  436. * the PhysicsCollisionObject::getType() method.
  437. *
  438. * @return The pointer to this node's physics collision object.
  439. */
  440. PhysicsCollisionObject* getCollisionObject() const;
  441. /**
  442. * Sets (or disables) the physics collision object for this node.
  443. *
  444. * The supported collision object types include rigid bodies, ghost objects,
  445. * characters, vehicles, and vehicle wheels.
  446. *
  447. * Rigid bodies are used to represent most physical objects in a game. The important
  448. * feature of rigid bodies is that they can be simulated by the physics system as other
  449. * rigid bodies or collision objects collide with them. To support this physics simulation,
  450. * rigid bodies require additional parameters, such as mass, friction and restitution to
  451. * define their physical features. These parameters can be passed into the
  452. * 'rigidBodyParameters' parameter.
  453. *
  454. * Vehicles consist of a rigid body with wheels. The rigid body parameters can be passed-in
  455. * via the 'rigidBodyParameters' parameter, and wheels can be added to the vehicle.
  456. *
  457. * Ghost objects are a simple type of collision object that are not simulated. By default
  458. * they pass through other objects in the scene without affecting them. Ghost objects do
  459. * receive collision events however, which makes them useful for representing non-simulated
  460. * entities in a game that still require collision events, such as volumetric triggers,
  461. * power-ups, etc.
  462. *
  463. * Characters are an extension of ghost objects which provide a number of additional features
  464. * for animating and moving characters within a game. Characters are represented as ghost
  465. * objects instead of rigid bodies to allow more direct control over character movement,
  466. * since attempting to model a physics character with a simulated rigid body usually results
  467. * in unresponsive and unpredictable character movement. Unlike normal ghost objects,
  468. * characters to react to other characters and rigid bodies in the world. Characters react
  469. * to gravity and collide (and respond) with rigid bodies to allow them to walk on the ground,
  470. * slide along walls and walk up/down slopes and stairs.
  471. *
  472. * @param type The type of the collision object to set; to disable the physics
  473. * collision object, pass PhysicsCollisionObject::NONE.
  474. * @param shape Definition of a physics collision shape to be used for this collision object.
  475. * Use the static shape methods on the PhysicsCollisionShape class to specify a shape
  476. * definition, such as PhysicsCollisionShape::box().
  477. * @param rigidBodyParameters If type is PhysicsCollisionObject::RIGID_BODY or
  478. * PhysicsCollisionObject::VEHICLE, this must point to a valid rigid body
  479. * parameters object containing information about the rigid body;
  480. * otherwise, this parameter may be NULL.
  481. */
  482. PhysicsCollisionObject* setCollisionObject(PhysicsCollisionObject::Type type, const PhysicsCollisionShape::Definition& shape = PhysicsCollisionShape::box(),
  483. PhysicsRigidBody::Parameters* rigidBodyParameters = NULL);
  484. /**
  485. * Sets the physics collision object for this node using the data from the Properties object defined at the specified URL,
  486. * where the URL is of the format "<file-path>.<extension>#<namespace-id>/<namespace-id>/.../<namespace-id>"
  487. * (and "#<namespace-id>/<namespace-id>/.../<namespace-id>" is optional).
  488. *
  489. * @param url The URL pointing to the Properties object defining the physics collision object.
  490. */
  491. PhysicsCollisionObject* setCollisionObject(const char* url);
  492. /**
  493. * Sets the physics collision object for this node from the given properties object.
  494. *
  495. * @param properties The properties object defining the collision object.
  496. */
  497. PhysicsCollisionObject* setCollisionObject(Properties* properties);
  498. /**
  499. * Returns the number of advertised descendants held in this node.
  500. *
  501. * Descendant nodes can advertise themselves to others using this
  502. * mechanism, such as how the wheels are bound to a physics vehicle
  503. * via their common ancestor.
  504. *
  505. * @return the number of advertised descendants held in this node.
  506. */
  507. unsigned int getNumAdvertisedDescendants() const;
  508. /**
  509. * Returns the advertised descendant at the specified index.
  510. *
  511. * Descendant nodes can advertise themselves to others using this
  512. * mechanism, such as how the wheels are bound to a physics vehicle
  513. * via their common ancestor.
  514. *
  515. * @param i the index to look-up.
  516. *
  517. * @return the advertised descendant at the specified index.
  518. */
  519. Node* getAdvertisedDescendant(unsigned int i) const;
  520. /**
  521. * Adds the specified node to the list of advertised descendants.
  522. *
  523. * Descendant nodes can advertise themselves to others using this
  524. * mechanism, such as how the wheels are bound to a physics vehicle
  525. * via their common ancestor.
  526. *
  527. * @param node the node reference to add.
  528. */
  529. void addAdvertisedDescendant(Node* node);
  530. /**
  531. * Returns the AI agent assigned to this node.
  532. *
  533. * @return The AI agent for this node.
  534. */
  535. AIAgent* getAgent() const;
  536. /**
  537. * Sets the AI agent for this node.
  538. *
  539. * @param agent The AI agent to set.
  540. */
  541. void setAgent(AIAgent* agent);
  542. /**
  543. * Returns the bounding sphere for the Node, in world space.
  544. *
  545. * The bounding sphere for a node represents the area, in world
  546. * space, that the node contains. This includes the space occupied
  547. * by any child nodes as well as the space occupied by any data
  548. * inside the node (such as models).
  549. *
  550. * Bounding spheres for nodes are rough approximations of the data
  551. * contained within a node and they are intended for visibility
  552. * testing or first-pass intersection testing only. They are not
  553. * appropriate for accurate collision detection since they most often
  554. * do not tightly contain a node's content.
  555. *
  556. * A node that does not occupy any space will return a bounding sphere
  557. * with a center point equal to the node translation and a radius of zero.
  558. *
  559. * @return The world-space bounding sphere for the node.
  560. */
  561. const BoundingSphere& getBoundingSphere() const;
  562. /**
  563. * Clones the node and all of its child nodes.
  564. *
  565. * @return A new node.
  566. * @script{create}
  567. */
  568. Node* clone() const;
  569. protected:
  570. /**
  571. * Constructor.
  572. */
  573. Node(const char* id);
  574. /**
  575. * Destructor.
  576. */
  577. virtual ~Node();
  578. /**
  579. * Clones a single node and its data but not its children.
  580. *
  581. * @param context The clone context.
  582. *
  583. * @return Pointer to the newly created node.
  584. */
  585. virtual Node* cloneSingleNode(NodeCloneContext &context) const;
  586. /**
  587. * Recursively clones this node and its children.
  588. *
  589. * @param context The clone context.
  590. *
  591. * @return The newly created node.
  592. */
  593. Node* cloneRecursive(NodeCloneContext &context) const;
  594. /**
  595. * Copies the data from this node into the given node.
  596. *
  597. * @param node The node to copy the data to.
  598. * @param context The clone context.
  599. */
  600. void cloneInto(Node* node, NodeCloneContext &context) const;
  601. /**
  602. * Removes this node from its parent.
  603. */
  604. void remove();
  605. /**
  606. * Called when this Node's transform changes.
  607. */
  608. void transformChanged();
  609. /**
  610. * Called when this Node's hierarchy changes.
  611. */
  612. void hierarchyChanged();
  613. /**
  614. * Marks the bounding volume of the node as dirty.
  615. */
  616. void setBoundsDirty();
  617. private:
  618. /**
  619. * Hidden copy constructor.
  620. */
  621. Node(const Node& copy);
  622. /**
  623. * Hidden copy assignment operator.
  624. */
  625. Node& operator=(const Node&);
  626. protected:
  627. /**
  628. * Defines a pointer and cleanup callback to custom user data that can be store in a Node.
  629. */
  630. struct UserData
  631. {
  632. /**
  633. * Constructor.
  634. */
  635. UserData() : pointer(NULL), cleanupCallback(NULL) {}
  636. /**
  637. * A pointer to custom user data.
  638. */
  639. void* pointer;
  640. /**
  641. * Cleanup callback.
  642. */
  643. void (*cleanupCallback)(void*);
  644. };
  645. /**
  646. * The Scene this node belongs to.
  647. */
  648. Scene* _scene;
  649. /**
  650. * The Node's ID.
  651. */
  652. std::string _id;
  653. /**
  654. * Pointer to the Node's first child.
  655. */
  656. Node* _firstChild;
  657. /**
  658. * Pointer to the Node's next child.
  659. */
  660. Node* _nextSibling;
  661. /**
  662. * Pointer to the Node's previous sibling.
  663. */
  664. Node* _prevSibling;
  665. /**
  666. * Pointer to the Node's parent.
  667. */
  668. Node* _parent;
  669. /**
  670. * The number of children belonging to the Node.
  671. */
  672. unsigned int _childCount;
  673. /**
  674. * List of custom tags for a node.
  675. */
  676. std::map<std::string, std::string>* _tags;
  677. /**
  678. * Pointer to the Camera attached to the Node.
  679. */
  680. Camera* _camera;
  681. /**
  682. * Pointer to the Light attached to the Node.
  683. */
  684. Light* _light;
  685. /**
  686. * Pointer to the Model attached to the Node.
  687. */
  688. Model* _model;
  689. /**
  690. * Pointer to the Terrain attached to the Node.
  691. */
  692. Terrain* _terrain;
  693. /**
  694. * Pointer to the Form attached to the Node.
  695. */
  696. Form* _form;
  697. /**
  698. * Pointer to the AudioSource attached to the Node.
  699. */
  700. AudioSource* _audioSource;
  701. /**
  702. * Pointer to the ParticleEmitter attached to the Node.
  703. */
  704. ParticleEmitter* _particleEmitter;
  705. /**
  706. * Pointer to the PhysicsCollisionObject attached to the Node.
  707. */
  708. PhysicsCollisionObject* _collisionObject;
  709. /**
  710. * Pointer to the AI agent attached to the Node.
  711. */
  712. AIAgent* _agent;
  713. /**
  714. * World Matrix representation of the Node.
  715. */
  716. mutable Matrix _world;
  717. /**
  718. * Dirty bits flag for the Node.
  719. */
  720. mutable int _dirtyBits;
  721. /**
  722. * A flag indicating if the Node's hierarchy has changed.
  723. */
  724. bool _notifyHierarchyChanged;
  725. /**
  726. * The Bounding Sphere containing the Node.
  727. */
  728. mutable BoundingSphere _bounds;
  729. /**
  730. * Pointer to custom UserData and cleanup call back that can be stored in a Node.
  731. */
  732. UserData* _userData;
  733. /**
  734. * A linear collection of descendants who wish to advertise themselves, typically
  735. * to other descendants. This allows nodes of common ancestry to bond. One example
  736. * of this is a physics vehicle and its wheels, which are associated via their
  737. * lowest common ancestor.
  738. */
  739. std::vector<Node*> _advertisedDescendants;
  740. };
  741. /**
  742. * NodeCloneContext represents the context data that is kept when cloning a node.
  743. *
  744. * The NodeCloneContext is used to make sure objects don't get cloned twice.
  745. */
  746. class NodeCloneContext
  747. {
  748. public:
  749. /**
  750. * Constructor.
  751. */
  752. NodeCloneContext();
  753. /**
  754. * Destructor.
  755. */
  756. ~NodeCloneContext();
  757. /**
  758. * Finds the cloned animation of the given animation or NULL if this animation was not registered with this context.
  759. *
  760. * @param animation The animation to search for the cloned copy of.
  761. *
  762. * @return The cloned animation or NULL if not found.
  763. */
  764. Animation* findClonedAnimation(const Animation* animation);
  765. /**
  766. * Registers the cloned animation with this context so that it doesn't get cloned twice.
  767. *
  768. * @param original The pointer to the original animation.
  769. * @param clone The pointer to the cloned animation.
  770. */
  771. void registerClonedAnimation(const Animation* original, Animation* clone);
  772. /**
  773. * Finds the cloned node of the given node or NULL if this node was not registered with this context.
  774. *
  775. * @param node The node to search for the cloned copy of.
  776. *
  777. * @return The cloned node or NULL if not found.
  778. */
  779. Node* findClonedNode(const Node* node);
  780. /**
  781. * Registers the cloned node with this context so that it doens't get cloned twice.
  782. *
  783. * @param original The pointer to the original node.
  784. * @param clone The pointer to the cloned node.
  785. */
  786. void registerClonedNode(const Node* original, Node* clone);
  787. private:
  788. /**
  789. * Hidden copy constructor.
  790. */
  791. NodeCloneContext(const NodeCloneContext&);
  792. /**
  793. * Hidden copy assignment operator.
  794. */
  795. NodeCloneContext& operator=(const NodeCloneContext&);
  796. std::map<const Animation*, Animation*> _clonedAnimations;
  797. std::map<const Node*, Node*> _clonedNodes;
  798. };
  799. }
  800. #endif