Node.h 25 KB

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