Scene.pkg 4.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. $#include "Scene.h"
  2. static const unsigned FIRST_REPLICATED_ID;
  3. static const unsigned LAST_REPLICATED_ID;
  4. static const unsigned FIRST_LOCAL_ID;
  5. static const unsigned LAST_LOCAL_ID;
  6. /// Root scene node, represents the whole scene.
  7. class Scene : public Node
  8. {
  9. public:
  10. /// Load from a binary file asynchronously. Return true if started successfully.
  11. bool LoadAsync(File* file);
  12. /// Load from an XML file asynchronously. Return true if started successfully.
  13. bool LoadAsyncXML(File* file);
  14. /// Stop asynchronous loading.
  15. void StopAsyncLoading();
  16. /// Clear.
  17. void Clear();
  18. /// Enable or disable scene update.
  19. void SetUpdateEnabled(bool enable);
  20. /// Set update time scale. 1.0 = real time (default.)
  21. void SetTimeScale(float scale);
  22. /// Set elapsed time in seconds. This can be used to prevent inaccuracy in the timer if the scene runs for a long time.
  23. void SetElapsedTime(float time);
  24. /// Set network client motion smoothing constant.
  25. void SetSmoothingConstant(float constant);
  26. /// Set network client motion smoothing snap threshold.
  27. void SetSnapThreshold(float threshold);
  28. /// Return node from the whole scene by ID, or null if not found.
  29. Node* GetNode(unsigned id) const;
  30. /// Return component from the whole scene by ID, or null if not found.
  31. Component* GetComponent(unsigned id) const;
  32. /// Return whether updates are enabled.
  33. bool IsUpdateEnabled() const;
  34. /// Return asynchronous loading flag.
  35. bool IsAsyncLoading() const;
  36. /// Return asynchronous loading progress between 0.0 and 1.0, or 1.0 if not in progress.
  37. float GetAsyncProgress() const;
  38. /// Return source file name.
  39. const String& GetFileName() const;
  40. /// Return source file checksum.
  41. unsigned GetChecksum() const;
  42. /// Return update time scale.
  43. float GetTimeScale() const;
  44. /// Return elapsed time in seconds.
  45. float GetElapsedTime() const;
  46. /// Return motion smoothing constant.
  47. float GetSmoothingConstant() const;
  48. /// Return motion smoothing snap threshold.
  49. float GetSnapThreshold() const;
  50. /// Return a node user variable name, or empty if not registered.
  51. const String& GetVarName(ShortStringHash hash) const;
  52. /// Update scene. Called by HandleUpdate.
  53. void Update(float timeStep);
  54. /// Begin a threaded update. During threaded update components can choose to delay dirty processing.
  55. void BeginThreadedUpdate();
  56. /// End a threaded update. Notify components that marked themselves for delayed dirty processing.
  57. void EndThreadedUpdate();
  58. /// Add a component to the delayed dirty notify queue. Is thread-safe.
  59. void DelayedMarkedDirty(Component* component);
  60. /// Return threaded update flag.
  61. bool IsThreadedUpdate() const;
  62. /// Get free node ID, either non-local or local.
  63. unsigned GetFreeNodeID(CreateMode mode);
  64. /// Get free component ID, either non-local or local.
  65. unsigned GetFreeComponentID(CreateMode mode);
  66. /// Node added. Assign scene pointer and add to ID map.
  67. void NodeAdded(Node* node);
  68. /// Node removed. Remove from ID map.
  69. void NodeRemoved(Node* node);
  70. /// Component added. Add to ID map.
  71. void ComponentAdded(Component* component);
  72. /// Component removed. Remove from ID map.
  73. void ComponentRemoved(Component* component);
  74. /// Set node user variable reverse mappings.
  75. void SetVarNamesAttr(String value);
  76. /// Return node user variable reverse mappings.
  77. String GetVarNamesAttr() const;
  78. /// Prepare network update by comparing attributes and marking replication states dirty as necessary.
  79. void PrepareNetworkUpdate();
  80. /// Clean up all references to a network connection that is about to be removed.
  81. void CleanupConnection(Connection* connection);
  82. /// Mark a node for attribute check on the next network update.
  83. void MarkNetworkUpdate(Node* node);
  84. /// Mark a comoponent for attribute check on the next network update.
  85. void MarkNetworkUpdate(Component* component);
  86. /// Mark a node dirty in scene replication states. The node does not need to have own replication state yet.
  87. void MarkReplicationDirty(Node* node);
  88. };
  89. Scene* GetScene();