2
0

Node.h 24 KB

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