SceneObject.h 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2013 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _SCENE_OBJECT_H_
  23. #define _SCENE_OBJECT_H_
  24. #ifndef _SCENE_H_
  25. #include "2d/scene/Scene.h"
  26. #endif
  27. #ifndef _DEBUG_STATS_H_
  28. #include "2d/scene/DebugStats.h"
  29. #endif
  30. #ifndef _SIMBASE_H_
  31. #include "sim/simBase.h"
  32. #endif
  33. #ifndef _MMATH_H_
  34. #include "math/mMath.h"
  35. #endif
  36. #ifndef _SCENE_WINDOW_H_
  37. #include "2d/gui/SceneWindow.h"
  38. #endif
  39. #ifndef _BATCH_RENDER_H_
  40. #include "2d/core/BatchRender.h"
  41. #endif
  42. #ifndef _UTILITY_H_
  43. #include "2d/core/Utility.h"
  44. #endif
  45. #ifndef _PHYSICS_PROXY_H_
  46. #include "2d/scene/PhysicsProxy.h"
  47. #endif
  48. #ifndef _SCENE_RENDER_OBJECT_H_
  49. #include "2d/scene/SceneRenderObject.h"
  50. #endif
  51. #ifndef _BEHAVIOR_COMPONENT_H_
  52. #include "component/behaviors/behaviorComponent.h"
  53. #endif
  54. #ifndef _BEHAVIORINSTANCE_H_
  55. #include "component/behaviors/behaviorInstance.h"
  56. #endif
  57. //-----------------------------------------------------------------------------
  58. struct tDestroyNotification
  59. {
  60. SceneObject* mpSceneObject;
  61. U32 mRefCount;
  62. };
  63. //-----------------------------------------------------------------------------
  64. typedef VectorPtr<b2FixtureDef*> typeCollisionFixtureDefVector;
  65. typedef VectorPtr<b2Fixture*> typeCollisionFixtureVector;
  66. typedef Vector<tDestroyNotification> typeDestroyNotificationVector;
  67. //-----------------------------------------------------------------------------
  68. const S32 GL_INVALID_BLEND_FACTOR = -1;
  69. const S32 INVALID_COLLISION_SHAPE_INDEX = -1;
  70. //-----------------------------------------------------------------------------
  71. extern EnumTable bodyTypeTable;
  72. extern EnumTable srcBlendFactorTable;
  73. extern EnumTable dstBlendFactorTable;
  74. extern EnumTable srcBlendFactorTable;
  75. extern EnumTable dstBlendFactorTable;
  76. //-----------------------------------------------------------------------------
  77. class SceneObject :
  78. public BehaviorComponent,
  79. public SceneRenderObject,
  80. public PhysicsProxy
  81. {
  82. private:
  83. typedef BehaviorComponent Parent;
  84. public:
  85. friend class Scene;
  86. friend class SceneWindow;
  87. friend class ContactFilter;
  88. friend class WorldQuery;
  89. friend class DebugDraw;
  90. friend class SceneObjectMoveToEvent;
  91. friend class SceneObjectRotateToEvent;
  92. protected:
  93. /// Scene.
  94. SimObjectPtr<Scene> mpScene;
  95. /// Target Scene.
  96. /// NOTE: Unfortunately this is required as the scene can be set via a field which
  97. /// occurs before the object is registered with the simulation therefore
  98. /// any simulation related functionality cannot be used such as TorqueScript
  99. /// callbacks.
  100. SimObjectPtr<Scene> mpTargetScene;
  101. /// Lifetime.
  102. F32 mLifetime;
  103. bool mLifetimeActive;
  104. /// Scene layers.
  105. U32 mSceneLayer;
  106. U32 mSceneLayerMask;
  107. F32 mSceneLayerDepth;
  108. /// Scene groups.
  109. U32 mSceneGroup;
  110. U32 mSceneGroupMask;
  111. /// Area.
  112. Vector2 mSize;
  113. bool mAutoSizing;
  114. b2AABB mPreTickAABB;
  115. b2AABB mCurrentAABB;
  116. Vector2 mLocalSizeOOBB[4];
  117. Vector2 mRenderOOBB[4];
  118. S32 mWorldProxyId;
  119. /// Position / Angle.
  120. Vector2 mPreTickPosition;
  121. F32 mPreTickAngle;
  122. Vector2 mRenderPosition;
  123. F32 mRenderAngle;
  124. bool mSpatialDirty;
  125. /// Body.
  126. b2Body* mpBody;
  127. b2BodyDef mBodyDefinition;
  128. U32 mWorldQueryKey;
  129. /// Collision control.
  130. U32 mCollisionLayerMask;
  131. U32 mCollisionGroupMask;
  132. bool mCollisionSuppress;
  133. b2FixtureDef mDefaultFixture;
  134. bool mGatherContacts;
  135. typeContactVector* mpCurrentContacts;
  136. /// General collision shape access.
  137. typeCollisionFixtureDefVector mCollisionFixtureDefs;
  138. typeCollisionFixtureVector mCollisionFixtures;
  139. /// Render visibility.
  140. bool mVisible;
  141. /// Render blending.
  142. bool mBlendMode;
  143. S32 mSrcBlendFactor;
  144. S32 mDstBlendFactor;
  145. ColorF mBlendColor;
  146. F32 mAlphaTest;
  147. /// Render sorting.
  148. Vector2 mSortPoint;
  149. /// Input events.
  150. bool mUseInputEvents;
  151. /// Script callbacks.
  152. bool mUpdateCallback;
  153. bool mCollisionCallback;
  154. bool mSleepingCallback;
  155. bool mLastAwakeState;
  156. /// Debug mode.
  157. U32 mDebugMask;
  158. /// Camera mounting.
  159. SceneWindow* mpAttachedCamera;
  160. /// GUI attachment.
  161. bool mAttachedGuiSizeControl;
  162. GuiControl* mpAttachedGui;
  163. SceneWindow* mpAttachedGuiSceneWindow;
  164. /// Pathing.
  165. SimObjectPtr<SceneObject> mAttachedToPath;
  166. /// Safe deletion.
  167. bool mBeingSafeDeleted;
  168. bool mSafeDeleteReady;
  169. /// Destroy notifications.
  170. typeDestroyNotificationVector mDestroyNotifyList;
  171. /// Miscellaneous.
  172. bool mBatchIsolated;
  173. U32 mSerialiseKey;
  174. bool mEditorTickAllowed;
  175. bool mPickingAllowed;
  176. bool mAlwaysInScope;
  177. S32 mPeriodicTimerID;
  178. U32 mMoveToEventId;
  179. U32 mRotateToEventId;
  180. U32 mSerialId;
  181. StringTableEntry mRenderGroup;
  182. protected:
  183. static S32 QSORT_CALLBACK sceneObjectLayerDepthSort(const void* a, const void* b);
  184. /// Scene (un)registering.
  185. virtual void OnRegisterScene( Scene* pScene );
  186. virtual void OnUnregisterScene( Scene* pScene );
  187. /// Ticking.
  188. void resetTickSpatials( const bool resize = false );
  189. inline bool getSpatialDirty( void ) const { return mSpatialDirty; }
  190. /// Contact processing.
  191. void initializeContactGathering( void );
  192. /// Taml callbacks.
  193. virtual void onTamlCustomWrite( TamlCustomProperties& customProperties );
  194. virtual void onTamlCustomRead( const TamlCustomProperties& customProperties );
  195. public:
  196. SceneObject();
  197. virtual ~SceneObject();
  198. /// Engine.
  199. virtual bool onAdd();
  200. virtual void onRemove();
  201. virtual void onDestroyNotify( SceneObject* pSceneObject );
  202. static void initPersistFields();
  203. /// Integration.
  204. virtual void preIntegrate( const F32 totalTime, const F32 elapsedTime, DebugStats* pDebugStats );
  205. virtual void integrateObject( const F32 totalTime, const F32 elapsedTime, DebugStats* pDebugStats );
  206. virtual void postIntegrate(const F32 totalTime, const F32 elapsedTime, DebugStats *pDebugStats);
  207. virtual void interpolateObject( const F32 timeDelta );
  208. inline bool getIsEditorTickAllowed( void ) const { return mEditorTickAllowed; }
  209. /// Render batching.
  210. inline void setBatchIsolated( const bool batchIsolated ) { mBatchIsolated = batchIsolated; }
  211. virtual bool getBatchIsolated( void ) { return mBatchIsolated; }
  212. virtual bool isBatchRendered( void ) { return true; }
  213. virtual bool validRender( void ) const { return true; }
  214. virtual bool shouldRender( void ) const { return false; }
  215. /// Render Output.
  216. virtual bool canPrepareRender( void ) const { return false; }
  217. virtual void scenePrepareRender( const SceneRenderState* pSceneRenderState, SceneRenderQueue* pSceneRenderQueue ) {}
  218. virtual void sceneRender( const SceneRenderState* pSceneRenderState, const SceneRenderRequest* pSceneRenderRequest, BatchRender* pBatchRenderer ) {}
  219. virtual void sceneRenderFallback( const SceneRenderState* pSceneRenderState, const SceneRenderRequest* pSceneRenderRequest, BatchRender* pBatchRenderer );
  220. virtual void sceneRenderOverlay( const SceneRenderState* pSceneRenderState );
  221. /// Networking.
  222. virtual U32 packUpdate(NetConnection * conn, U32 mask, BitStream *stream);
  223. virtual void unpackUpdate(NetConnection * conn, BitStream *stream);
  224. /// Scene.
  225. inline Scene* const getScene( void ) const { return mpScene; }
  226. inline F32 getSceneTime( void ) const { if ( mpScene ) return mpScene->getSceneTime(); else return 0.0f; }
  227. /// Enabled.
  228. virtual void setEnabled( const bool enabled );
  229. /// Lifetime.
  230. void setLifetime( const F32 lifetime );
  231. inline F32 getLifetime( void ) const { return mLifetime; }
  232. void updateLifetime( const F32 elapsedTime );
  233. /// Scene layers.
  234. void setSceneLayer( const U32 sceneLayer );
  235. inline U32 getSceneLayer(void) const { return mSceneLayer; }
  236. inline U32 getSceneLayerMask( void ) const { return mSceneLayerMask; }
  237. /// Scene Layer depth.
  238. inline void setSceneLayerDepth( const F32 order ) { mSceneLayerDepth = order; };
  239. inline F32 getSceneLayerDepth( void ) const { return mSceneLayerDepth; }
  240. bool setSceneLayerDepthFront( void );
  241. bool setSceneLayerDepthBack( void );
  242. bool setSceneLayerDepthForward( void );
  243. bool setSceneLayerDepthBackward( void );
  244. /// Scene groups.
  245. void setSceneGroup( const U32 sceneGroup );
  246. inline U32 getSceneGroup(void ) const { return mSceneGroup; }
  247. inline U32 getSceneGroupMask( void ) const { return mSceneGroupMask; }
  248. /// Area.
  249. virtual void setArea( const Vector2& corner1, const Vector2& corner2 );
  250. inline bool getAutoSizing( void ) const { return mAutoSizing; }
  251. virtual void setSize( const Vector2& size );
  252. inline void setSize( const F32 width, const F32 height ){ setSize( Vector2(width, height) ); }
  253. inline Vector2 getSize( void ) const { return mSize; }
  254. inline Vector2 getHalfSize( void ) const { return mSize * 0.5f; }
  255. inline b2AABB getAABB( void ) const { return mCurrentAABB; }
  256. inline RectF getAABBRectangle( void ) const { const b2Vec2 size = mCurrentAABB.upperBound-mCurrentAABB.lowerBound; return RectF( mCurrentAABB.lowerBound.x, mCurrentAABB.lowerBound.y, size.x, size.y ); }
  257. inline S32 getWorldProxy( void ) const { return mWorldProxyId; }
  258. /// Position / Angle.
  259. virtual void setPosition( const Vector2& position );
  260. inline Vector2 getPosition(void) const { if ( mpScene ) return mpBody->GetPosition(); else return mBodyDefinition.position; }
  261. inline Vector2 getRenderPosition(void) const { return mRenderPosition; }
  262. inline F32 getRenderAngle(void) const { return mRenderAngle; }
  263. inline const b2Vec2* getRenderOOBB(void) const { return mRenderOOBB; }
  264. inline const b2Vec2* getLocalSizedOOBB( void ) const { return mLocalSizeOOBB; }
  265. virtual void setAngle( const F32 radians );
  266. inline F32 getAngle(void) const { if ( mpScene ) return mpBody->GetAngle(); else return mBodyDefinition.angle; }
  267. virtual void setFixedAngle( const bool fixed ) { if ( mpScene ) mpBody->SetFixedRotation( fixed ); else mBodyDefinition.fixedRotation = fixed; }
  268. inline bool getFixedAngle(void) const { if ( mpScene ) return mpBody->IsFixedRotation(); else return mBodyDefinition.fixedRotation; }
  269. b2Transform getTransform( void ) const { if ( mpScene ) return mpBody->GetTransform(); else return b2Transform( mBodyDefinition.position, b2Rot(mBodyDefinition.angle) ); }
  270. b2Transform getRenderTransform( void ) const { return b2Transform( getRenderPosition(), b2Rot( getRenderAngle()) ); }
  271. inline Vector2 getLocalCenter(void) const { if ( mpScene ) return mpBody->GetLocalCenter(); else return b2Vec2_zero; }
  272. inline Vector2 getWorldCenter(void) const { if ( mpScene ) return mpBody->GetWorldCenter(); else return mBodyDefinition.position; }
  273. Vector2 getLocalPoint( const Vector2& worldPoint );
  274. Vector2 getWorldPoint( const Vector2& localPoint );
  275. Vector2 getLocalVector( const Vector2& worldVector );
  276. Vector2 getWorldVector( const Vector2& localVector );
  277. bool getIsPointInOOBB( const Vector2& worldPoint );
  278. bool getIsPointInCollisionShape( const U32 shapeIndex, const Vector2& worldPoint );
  279. /// Body.
  280. virtual ePhysicsProxyType getPhysicsProxyType( void ) const { return PhysicsProxy::PHYSIC_PROXY_SCENEOBJECT; }
  281. inline b2Body* getBody( void ) const { return mpBody; }
  282. void setBodyType( const b2BodyType type );
  283. inline b2BodyType getBodyType(void) const { if ( mpScene ) return mpBody->GetType(); else return mBodyDefinition.type; }
  284. inline void setActive( const bool active ) { if ( mpScene ) mpBody->SetActive( active ); else mBodyDefinition.active = active; }
  285. inline bool getActive(void) const { if ( mpScene ) return mpBody->IsActive(); else return mBodyDefinition.active; }
  286. inline void setAwake( const bool awake ) { if ( mpScene ) mpBody->SetAwake( awake ); else mBodyDefinition.awake = awake; }
  287. inline bool getAwake(void) const { if ( mpScene ) return mpBody->IsAwake(); else return mBodyDefinition.awake; }
  288. inline void setBullet( const bool bullet ) { if ( mpScene ) mpBody->SetBullet( bullet ); else mBodyDefinition.bullet = bullet; }
  289. inline bool getBullet(void) const { if ( mpScene ) return mpBody->IsBullet(); else return mBodyDefinition.bullet; }
  290. inline void setSleepingAllowed( const bool allowed ) { if ( mpScene ) mpBody->SetSleepingAllowed( allowed ); else mBodyDefinition.allowSleep = allowed; }
  291. inline bool getSleepingAllowed(void) const { if ( mpScene ) return mpBody->IsSleepingAllowed(); else return mBodyDefinition.allowSleep; }
  292. inline F32 getMass( void ) const { if ( mpScene ) return mpBody->GetMass(); else return 0.0f; }
  293. inline F32 getInertia( void ) const { if ( mpScene ) return mpBody->GetInertia(); else return 0.0f; }
  294. /// Collision control.
  295. void setCollisionMasks( const U32 groupMask, const U32 layerMask = MASK_ALL );
  296. void setCollisionAgainst( const SceneObject* pSceneObject, const bool clearMasks );
  297. inline void setCollisionLayers( const U32 layerMask ) { setCollisionMasks(getCollisionGroupMask(), layerMask); }
  298. inline void setCollisionGroups( const U32 groupMask ) { setCollisionMasks(groupMask, getCollisionLayerMask()); }
  299. inline U32 getCollisionGroupMask(void) const { return mCollisionGroupMask; }
  300. inline U32 getCollisionLayerMask(void) const { return mCollisionLayerMask; }
  301. void setDefaultDensity( const F32 density, const bool updateShapes = true );
  302. inline F32 getDefaultDensity( void ) const { return mDefaultFixture.density; }
  303. void setDefaultFriction( const F32 friction, const bool updateShapes = true );
  304. inline F32 getDefaultFriction( void ) const { return mDefaultFixture.friction; }
  305. void setDefaultRestitution( const F32 restitution, const bool updateShapes = true );
  306. inline F32 getDefaultRestitution( void ) const { return mDefaultFixture.restitution; }
  307. inline void setCollisionSuppress( const bool status ) { mCollisionSuppress = status; }
  308. inline bool getCollisionSuppress(void) const { return mCollisionSuppress; }
  309. inline const typeContactVector* getCurrentContacts( void ) const { return mpCurrentContacts; }
  310. inline U32 getCurrentContactCount( void ) const { if ( mpCurrentContacts != NULL ) return mpCurrentContacts->size(); else return 0; }
  311. virtual void setGatherContacts( const bool gatherContacts ) { mGatherContacts = gatherContacts; initializeContactGathering(); }
  312. inline bool getGatherContacts( void ) const { return mGatherContacts; }
  313. virtual void onBeginCollision( const TickContact& tickContact );
  314. virtual void onEndCollision( const TickContact& tickContact );
  315. /// Velocities.
  316. inline void setLinearVelocity( const Vector2& velocity ) { if ( mpScene ) mpBody->SetLinearVelocity( velocity ); else mBodyDefinition.linearVelocity = velocity; }
  317. inline Vector2 getLinearVelocity(void) const { if ( mpScene ) return mpBody->GetLinearVelocity(); else return mBodyDefinition.linearVelocity; }
  318. inline Vector2 getLinearVelocityFromWorldPoint( const Vector2& worldPoint ) { if ( mpScene ) return mpBody->GetLinearVelocityFromWorldPoint( worldPoint ); else return mBodyDefinition.linearVelocity; }
  319. inline Vector2 getLinearVelocityFromLocalPoint( const Vector2& localPoint ) { if ( mpScene ) return mpBody->GetLinearVelocityFromLocalPoint( localPoint ); else return mBodyDefinition.linearVelocity; }
  320. inline void setAngularVelocity( const F32 velocity ) { if ( mpScene ) mpBody->SetAngularVelocity( velocity ); else mBodyDefinition.angularVelocity = velocity; }
  321. inline F32 getAngularVelocity(void) const { if ( mpScene ) return mpBody->GetAngularVelocity(); else return mBodyDefinition.angularVelocity; }
  322. inline void setLinearDamping( const F32 damping ) { if ( mpScene ) mpBody->SetLinearDamping( damping ); else mBodyDefinition.linearDamping = damping; }
  323. inline F32 getLinearDamping(void) const { if ( mpScene ) return mpBody->GetLinearDamping(); else return mBodyDefinition.linearDamping; }
  324. inline void setAngularDamping( const F32 damping ) { if ( mpScene ) mpBody->SetAngularDamping( damping ); else mBodyDefinition.angularDamping = damping; }
  325. inline F32 getAngularDamping(void) const { if ( mpScene ) return mpBody->GetAngularDamping(); else return mBodyDefinition.angularDamping; }
  326. /// Move/Rotate to.
  327. bool moveTo( const Vector2& targetWorldPoint, const U32 time = 1000, const bool autoStop = true, const bool warpToTarget = true );
  328. bool rotateTo( const F32 targetAngle, const U32 time = 1000, const bool autoStop = true, const bool warpToTarget = true );
  329. void cancelMoveTo( const bool autoStop = true );
  330. void cancelRotateTo( const bool autoStop = true );
  331. inline bool isMoveToComplete( void ) const { return mMoveToEventId == 0; }
  332. inline bool isRotateToComplete( void ) const { return mRotateToEventId == 0; }
  333. /// Force and impulse.
  334. void applyForce( const Vector2& worldForce, const bool wake = true );
  335. void applyForce( const Vector2& worldForce, const Vector2& worldPoint, const bool wake = true);
  336. void applyTorque( const F32 torque, const bool wake = true );
  337. void applyLinearImpulse( const Vector2& worldImpulse, const bool wake = true );
  338. void applyLinearImpulse( const Vector2& worldImpulse, const Vector2& worldPoint, const bool wake = true );
  339. void applyAngularImpulse( const F32 impulse, const bool wake = true );
  340. /// Gravity scaling.
  341. inline void setGravityScale( const F32 scale ) { if ( mpScene ) mpBody->SetGravityScale( scale ); else mBodyDefinition.gravityScale = scale; }
  342. inline F32 getGravityScale(void) const { if ( mpScene ) return mpBody->GetGravityScale(); else return mBodyDefinition.gravityScale; }
  343. /// General collision shape access.
  344. void deleteCollisionShape( const U32 shapeIndex );
  345. void clearCollisionShapes( void );
  346. inline U32 getCollisionShapeCount( void ) const { if ( mpScene ) return mCollisionFixtures.size(); else return mCollisionFixtureDefs.size(); }
  347. b2Shape::Type getCollisionShapeType( const U32 shapeIndex ) const;
  348. S32 getCollisionShapeIndex( const b2Fixture* pFixture ) const;
  349. void setCollisionShapeDefinition( const U32 shapeIndex, const b2FixtureDef& fixtureDef );
  350. b2FixtureDef getCollisionShapeDefinition( const U32 shapeIndex ) const;
  351. const b2CircleShape* getCollisionCircleShape( const U32 shapeIndex ) const;
  352. const b2PolygonShape* getCollisionPolygonShape( const U32 shapeIndex ) const;
  353. const b2ChainShape* getCollisionChainShape( const U32 shapeIndex ) const;
  354. const b2EdgeShape* getCollisionEdgeShape( const U32 shapeIndex ) const;
  355. void setCollisionShapeDensity( const U32 shapeIndex, const F32 density );
  356. F32 getCollisionShapeDensity( const U32 shapeIndex ) const;
  357. void setCollisionShapeFriction( const U32 shapeIndex, const F32 friction );
  358. F32 getCollisionShapeFriction( const U32 shapeIndex ) const;
  359. void setCollisionShapeRestitution( const U32 shapeIndex, const F32 restitution );
  360. F32 getCollisionShapeRestitution( const U32 shapeIndex ) const;
  361. void setCollisionShapeIsSensor( const U32 shapeIndex, const bool isSensor );
  362. bool getCollisionShapeIsSensor( const U32 shapeIndex ) const;
  363. /// Circle collision shape creation.
  364. S32 createCircleCollisionShape( const F32 radius );
  365. S32 createCircleCollisionShape( const F32 radius, const b2Vec2& localPosition );
  366. /// Circle collision shape access.
  367. F32 getCircleCollisionShapeRadius( const U32 shapeIndex ) const;
  368. Vector2 getCircleCollisionShapeLocalPosition( const U32 shapeIndex ) const;
  369. /// Polygon collision shape creation.
  370. S32 createPolygonCollisionShape( const U32 pointCount, const b2Vec2* localPoints );
  371. S32 createPolygonBoxCollisionShape( const F32 width, const F32 height );
  372. S32 createPolygonBoxCollisionShape( const F32 width, const F32 height, const b2Vec2& localCentroid );
  373. S32 createPolygonBoxCollisionShape( const F32 width, const F32 height, const b2Vec2& localCentroid, const F32 rotation );
  374. /// Polygon collision shape access.
  375. U32 getPolygonCollisionShapePointCount( const U32 shapeIndex ) const;
  376. Vector2 getPolygonCollisionShapeLocalPoint( const U32 shapeIndex, const U32 pointIndex ) const;
  377. /// Chain collision shape creation.
  378. S32 createChainCollisionShape( const U32 pointCount, const b2Vec2* localPoints );
  379. S32 createChainCollisionShape( const U32 pointCount, const b2Vec2* localPoints,
  380. const bool hasAdjacentLocalPositionStart, const bool hasAdjacentLocalPositionEnd,
  381. const b2Vec2& adjacentLocalPositionStart, const b2Vec2& adjacentLocalPositionEnd );
  382. /// Chain collision shape access.
  383. U32 getChainCollisionShapePointCount( const U32 shapeIndex ) const;
  384. Vector2 getChainCollisionShapeLocalPoint( const U32 shapeIndex, const U32 pointIndex ) const;
  385. bool getChainCollisionShapeHasAdjacentStart( const U32 shapeIndex ) const;
  386. bool getChainCollisionShapeHasAdjacentEnd( const U32 shapeIndex ) const;
  387. Vector2 getChainCollisionShapeAdjacentStart( const U32 shapeIndex ) const;
  388. Vector2 getChainCollisionShapeAdjacentEnd( const U32 shapeIndex ) const;
  389. /// Edge collision shape creation.
  390. S32 createEdgeCollisionShape( const b2Vec2& localPositionStart, const b2Vec2& localPositionEnd );
  391. S32 createEdgeCollisionShape( const b2Vec2& localPositionStart, const b2Vec2& localPositionEnd,
  392. const bool hasAdjacentLocalPositionStart, const bool hasAdjacentLocalPositionEnd,
  393. const b2Vec2& adjacentLocalPositionStart, const b2Vec2& adjacentLocalPositionEnd );
  394. /// Edge collision shape access.
  395. Vector2 getEdgeCollisionShapeLocalPositionStart( const U32 shapeIndex ) const;
  396. Vector2 getEdgeCollisionShapeLocalPositionEnd( const U32 shapeIndex ) const;
  397. bool getEdgeCollisionShapeHasAdjacentStart( const U32 shapeIndex ) const;
  398. bool getEdgeCollisionShapeHasAdjacentEnd( const U32 shapeIndex ) const;
  399. Vector2 getEdgeCollisionShapeAdjacentStart( const U32 shapeIndex ) const;
  400. Vector2 getEdgeCollisionShapeAdjacentEnd( const U32 shapeIndex ) const;
  401. /// Render visibility.
  402. inline void setVisible( const bool status ) { mVisible = status; }
  403. inline bool getVisible(void) const { return mVisible; }
  404. /// Render blending.
  405. inline void setBlendMode( const bool blendMode ) { mBlendMode = blendMode; }
  406. inline bool getBlendMode( void ) const { return mBlendMode; }
  407. inline void setSrcBlendFactor( const S32 blendFactor ) { mSrcBlendFactor = blendFactor; }
  408. inline S32 getSrcBlendFactor( void ) const { return mSrcBlendFactor; }
  409. inline void setDstBlendFactor( const S32 blendFactor ) { mDstBlendFactor = blendFactor; }
  410. inline S32 getDstBlendFactor( void ) const { return mDstBlendFactor; }
  411. inline void setBlendColor( const ColorF& blendColor ) { mBlendColor = blendColor; }
  412. inline const ColorF& getBlendColor( void ) const { return mBlendColor; }
  413. inline void setBlendAlpha( const F32 alpha ) { mBlendColor.alpha = alpha; }
  414. inline F32 getBlendAlpha( void ) const { return mBlendColor.alpha; }
  415. inline void setAlphaTest( const F32 alpha ) { mAlphaTest = alpha; }
  416. inline F32 getAlphaTest( void ) const { return mAlphaTest; }
  417. void setBlendOptions( void );
  418. static void resetBlendOptions( void );
  419. /// Render sorting.
  420. inline void setSortPoint( const Vector2& pt ) { mSortPoint = pt; }
  421. inline const Vector2& getSortPoint(void) const { return mSortPoint; }
  422. inline void setRenderGroup( const char* pRenderGroup ) { mRenderGroup = StringTable->insert(pRenderGroup); }
  423. inline StringTableEntry getRenderGroup( void ) const { return mRenderGroup; }
  424. /// Input events.
  425. inline void setUseInputEvents( bool mouseStatus ) { mUseInputEvents = mouseStatus; }
  426. inline bool getUseInputEvents( void ) const { return mUseInputEvents; }
  427. virtual void onInputEvent( StringTableEntry name, const GuiEvent& event, const Vector2& worldMousePoint );
  428. // Script callbacks.
  429. inline void setUpdateCallback( bool status ) { mUpdateCallback = status; }
  430. inline bool getUpdateCallback( void ) const { return mUpdateCallback; }
  431. inline void setCollisionCallback( const bool status ) { mCollisionCallback = status; }
  432. inline bool getCollisionCallback(void) const { return mCollisionCallback; }
  433. inline void setSleepingCallback( bool status ) { mSleepingCallback = status; }
  434. inline bool getSleepingCallback( void ) const { return mSleepingCallback; }
  435. /// Debug mode.
  436. inline void setDebugOn( const U32 debugMask ) { mDebugMask |= debugMask; }
  437. inline void setDebugOff( const U32 debugMask ) { mDebugMask &= ~debugMask; }
  438. inline U32 getDebugMask( void ) const { return mDebugMask; }
  439. /// Camera mounting.
  440. inline void addCameraMountReference( SceneWindow* pAttachedCamera ) { mpAttachedCamera = pAttachedCamera; }
  441. inline void removeCameraMountReference( void ) { mpAttachedCamera = NULL; }
  442. inline void dismountCamera( void ) { if ( mpAttachedCamera ) mpAttachedCamera->dismountMe( this ); }
  443. // GUI attachment.
  444. void attachGui( GuiControl* pGuiControl, SceneWindow* pSceneWindow, const bool sizeControl );
  445. void detachGui( void );
  446. inline void updateAttachedGui( void );
  447. /// Pathing.
  448. inline void setAttachedToPath(SceneObject* path){ mAttachedToPath = path; }
  449. inline SceneObject* getAttachedToPath() const { return mAttachedToPath; }
  450. /// Cloning.
  451. virtual void copyFrom( SceneObject* pSceneObject, const bool copyDynamicFields );
  452. virtual void copyTo( SimObject* object );
  453. S32 copyCollisionShapes( SceneObject* pSceneObject, const bool clearTargetShapes = true, const S32 shapeIndex = -1 );
  454. /// Safe deletion.
  455. inline void setSafeDelete( const bool status ) { mSafeDeleteReady = status; }
  456. inline bool getSafeDelete( void ) const { return mSafeDeleteReady; }
  457. inline bool isBeingDeleted( void ) const { return mBeingSafeDeleted; }
  458. virtual void safeDelete( void );
  459. /// Destroy notifications.
  460. void addDestroyNotification( SceneObject* pSceneObject );
  461. void removeDestroyNotification( SceneObject* pSceneObject );
  462. void processDestroyNotifications( void );
  463. /// Component notifications.
  464. void notifyComponentsAddToScene( void );
  465. void notifyComponentsRemoveFromScene( void );
  466. void notifyComponentsUpdate( void );
  467. /// Miscellaneous.
  468. inline const char* scriptThis(void) const { return Con::getIntArg(getId()); }
  469. inline bool getIsPickingAllowed(void) const { return mPickingAllowed; }
  470. inline bool getIsAlwaysInScope(void) const { return mAlwaysInScope; }
  471. inline void setPeriodicTimerID( S32 timerID ) { mPeriodicTimerID = timerID; }
  472. inline S32 getPeriodicTimerID( void ) const { return mPeriodicTimerID; }
  473. inline void setWorldQueryKey( const U32 key ) { mWorldQueryKey = key; }
  474. inline U32 getWorldQueryKey( void ) const { return mWorldQueryKey; }
  475. BehaviorInstance* behavior(const char *name);
  476. static U32 getGlobalSceneObjectCount( void );
  477. inline U32 getSerialId( void ) const { return mSerialId; }
  478. // Read / Write fields.
  479. virtual bool writeField(StringTableEntry fieldname, const char* value);
  480. static b2BodyType getBodyTypeEnum(const char* label);
  481. static const char* getBodyTypeDescription(const b2BodyType bodyType);
  482. static b2Shape::Type getCollisionShapeTypeEnum(const char* label);
  483. static const char* getCollisionShapeTypeDescription(const b2Shape::Type collisionShapeType);
  484. static S32 getSrcBlendFactorEnum(const char* label);
  485. static S32 getDstBlendFactorEnum(const char* label);
  486. static const char* getSrcBlendFactorDescription(const GLenum factor);
  487. static const char* getDstBlendFactorDescription(const GLenum factor);
  488. /// Declare Console Object.
  489. DECLARE_CONOBJECT( SceneObject );
  490. protected:
  491. S32 copyCircleCollisionShapeTo( SceneObject* pSceneObject, const b2FixtureDef& fixtureDef ) const;
  492. S32 copyPolygonCollisionShapeTo( SceneObject* pSceneObject, const b2FixtureDef& fixtureDef ) const;
  493. S32 copyChainCollisionShapeTo( SceneObject* pSceneObject, const b2FixtureDef& fixtureDef ) const;
  494. S32 copyEdgeCollisionShapeTo( SceneObject* pSceneObject, const b2FixtureDef& fixtureDef ) const;
  495. protected:
  496. /// Lifetime.
  497. static bool setLifetime(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setLifetime(dAtof(data)); return false; }
  498. static bool writeLifetime( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getLifetime() > 0.0f ; }
  499. /// Scene layers.
  500. static bool setSceneLayer(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setSceneLayer(dAtoi(data)); return false; }
  501. static bool writeSceneLayer( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getSceneLayer() > 0 ; }
  502. static bool setSceneLayerDepth(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setSceneLayerDepth(dAtof(data)); return false; }
  503. static bool writeSceneLayerDepth( void* obj, StringTableEntry pFieldName ) { return mNotZero(static_cast<SceneObject*>(obj)->getSceneLayerDepth()); }
  504. /// Scene groups.
  505. static bool setSceneGroup(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setSceneGroup(dAtoi(data)); return false; }
  506. static bool writeSceneGroup( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getSceneGroup() > 0 ; }
  507. /// Area.
  508. static bool setSize(void* obj, const char* data)
  509. {
  510. SceneObject* pSceneObject = static_cast<SceneObject*>(obj);
  511. if ( pSceneObject->getAutoSizing() )
  512. {
  513. Con::warnf( "Cannot set the size of a type '%s' as it automatically sizes itself.", pSceneObject->getClassName() );
  514. return false;
  515. }
  516. pSceneObject->setSize(Vector2(data));
  517. return false;
  518. }
  519. static bool writeSize( void* obj, StringTableEntry pFieldName ) { SceneObject* pSceneObject = static_cast<SceneObject*>(obj); return !pSceneObject->getAutoSizing() && pSceneObject->getSize().notEqual(Vector2::getOne()); }
  520. /// Position / Angle.
  521. static bool setPosition(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setPosition(Vector2(data)); return false; }
  522. static const char* getPosition(void* obj, const char* data) { return static_cast<SceneObject*>(obj)->getPosition().scriptThis(); }
  523. static bool writePosition( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getPosition().notZero(); }
  524. static bool setAngle(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setAngle(mDegToRad(dAtof(data))); return false; }
  525. static const char* getAngle(void* obj, const char* data) { return Con::getFloatArg( mRadToDeg(static_cast<SceneObject*>(obj)->getAngle() ) ); }
  526. static bool writeAngle( void* obj, StringTableEntry pFieldName ) { return mNotZero(static_cast<SceneObject*>(obj)->getAngle()); }
  527. static bool setFixedAngle(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setFixedAngle(dAtob(data)); return false; }
  528. static const char* getFixedAngle(void* obj, const char* data) { return Con::getBoolArg( static_cast<SceneObject*>(obj)->getFixedAngle() ); }
  529. static bool writeFixedAngle( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getFixedAngle() == true; }
  530. /// Body.
  531. static bool setBodyType(void* obj, const char* data)
  532. {
  533. // Fetch body type.
  534. const b2BodyType type = getBodyTypeEnum( data );
  535. // Check for error.
  536. if ( type != b2_staticBody && type != b2_kinematicBody && type != b2_dynamicBody )
  537. return false;
  538. static_cast<SceneObject*>(obj)->setBodyType(type);
  539. return false;
  540. }
  541. static const char* getBodyType(void* obj, const char* data) { return getBodyTypeDescription( static_cast<SceneObject*>(obj)->getBodyType() ); }
  542. static bool writeBodyType( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getBodyType() != b2_dynamicBody; }
  543. static bool setActive(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setActive(dAtob(data)); return false; }
  544. static const char* getActive(void* obj, const char* data) { return Con::getBoolArg( static_cast<SceneObject*>(obj)->getActive() ); }
  545. static bool writeActive( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getActive() == false; }
  546. static bool setAwake(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setAwake(dAtob(data)); return false; }
  547. static const char* getAwake(void* obj, const char* data) { return Con::getBoolArg( static_cast<SceneObject*>(obj)->getAwake() ); }
  548. static bool writeAwake( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getAwake() == false; }
  549. static bool setBullet(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setBullet(dAtob(data)); return false; }
  550. static const char* getBullet(void* obj, const char* data) { return Con::getBoolArg( static_cast<SceneObject*>(obj)->getBullet() ); }
  551. static bool writeBullet( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getBullet() == true; }
  552. static bool setSleepingAllowed(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setSleepingAllowed(dAtob(data)); return false; }
  553. static const char* getSleepingAllowed(void* obj, const char* data) { return Con::getBoolArg( static_cast<SceneObject*>(obj)->getSleepingAllowed() ); }
  554. static bool writeSleepingAllowed( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getSleepingAllowed() == false; }
  555. /// Collision control.
  556. static bool setDefaultDensity(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setDefaultDensity(dAtof(data)); return false; }
  557. static bool writeDefaultDensity( void* obj, StringTableEntry pFieldName ) { return mNotEqual(static_cast<SceneObject*>(obj)->getDefaultDensity(), 1.0f); }
  558. static bool setDefaultFriction(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setDefaultFriction(dAtof(data)); return false; }
  559. static bool writeDefaultFriction( void* obj, StringTableEntry pFieldName ) {return mNotEqual(static_cast<SceneObject*>(obj)->getDefaultFriction(), 0.2f); }
  560. static bool setDefaultRestitution(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setDefaultRestitution(dAtof(data)); return false; }
  561. static bool writeDefaultRestitution( void* obj, StringTableEntry pFieldName ) { return mNotEqual(static_cast<SceneObject*>(obj)->getDefaultRestitution(), 0.0f); }
  562. static bool setCollisionGroups(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setCollisionGroups(dAtoi(data)); return false; }
  563. static bool writeCollisionGroups( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getCollisionGroupMask() != MASK_ALL; }
  564. static bool setCollisionLayers(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setCollisionLayers(dAtoi(data)); return false; }
  565. static bool writeCollisionLayers( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getCollisionLayerMask() != MASK_ALL; }
  566. static bool writeCollisionSuppress( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getCollisionSuppress() == true; }
  567. static bool setGatherContacts(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setGatherContacts(dAtoi(data)); return false; }
  568. static bool writeGatherContacts( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getGatherContacts() == true; }
  569. /// Velocities.
  570. static bool setLinearVelocity(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setLinearVelocity(Vector2(data)); return false; }
  571. static const char* getLinearVelocity(void* obj, const char* data) { return static_cast<SceneObject*>(obj)->getLinearVelocity().scriptThis(); }
  572. static bool writeLinearVelocity( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getLinearVelocity().notZero(); }
  573. static bool setAngularVelocity(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setAngularVelocity(mDegToRad(dAtof(data))); return false; }
  574. static const char* getAngularVelocity(void* obj, const char* data) { return Con::getFloatArg( mRadToDeg(static_cast<SceneObject*>(obj)->getAngularVelocity() ) ); }
  575. static bool writeAngularVelocity( void* obj, StringTableEntry pFieldName ) { return mNotZero(static_cast<SceneObject*>(obj)->getAngularVelocity()); }
  576. static bool setLinearDamping(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setLinearDamping(dAtof(data)); return false; }
  577. static const char* getLinearDamping(void* obj, const char* data) { return Con::getFloatArg( static_cast<SceneObject*>(obj)->getLinearDamping() ); }
  578. static bool writeLinearDamping( void* obj, StringTableEntry pFieldName ) { return mNotZero(static_cast<SceneObject*>(obj)->getLinearDamping()); }
  579. static bool setAngularDamping(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setAngularDamping(dAtof(data)); return false; }
  580. static const char* getAngularDamping(void* obj, const char* data) { return Con::getFloatArg( static_cast<SceneObject*>(obj)->getAngularDamping() ); }
  581. static bool writeAngularDamping( void* obj, StringTableEntry pFieldName ) { return mNotZero(static_cast<SceneObject*>(obj)->getAngularDamping()); }
  582. /// Gravity scaling.
  583. static bool setGravityScale(void* obj, const char* data) { static_cast<SceneObject*>(obj)->setGravityScale(dAtof(data)); return false; }
  584. static const char* getGravityScale(void* obj, const char* data) { return Con::getFloatArg( static_cast<SceneObject*>(obj)->getGravityScale() ); }
  585. static bool writeGravityScale( void* obj, StringTableEntry pFieldName ) { return mNotEqual(static_cast<SceneObject*>(obj)->getGravityScale(), 1.0f); }
  586. /// Render visibility.
  587. static bool writeVisible( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getVisible() == false; }
  588. /// Render blending.
  589. static bool writeBlendMode( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getBlendMode() == false; }
  590. static bool writeSrcBlendFactor( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getSrcBlendFactor() != GL_SRC_ALPHA; }
  591. static bool writeDstBlendFactor( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getDstBlendFactor() != GL_ONE_MINUS_SRC_ALPHA; }
  592. static bool writeBlendColor( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getBlendColor() != ColorF(1.0f, 1.0f, 1.0f, 1.0f); }
  593. static bool writeAlphaTest( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getAlphaTest() >= 0.0f; }
  594. /// Render sorting.
  595. static bool writeSortPoint( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getSortPoint().notZero(); }
  596. static bool writeRenderGroup( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getRenderGroup() != StringTable->EmptyString; }
  597. /// Input events.
  598. static bool writeUseInputEvents( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getUseInputEvents() == true; }
  599. /// Script callbacks.
  600. static bool writeUpdateCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getUpdateCallback() == true; }
  601. static bool writeCollisionCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getCollisionCallback() == true; }
  602. static bool writeSleepingCallback( void* obj, StringTableEntry pFieldName ) { return static_cast<SceneObject*>(obj)->getSleepingCallback() == true; }
  603. /// Scene.
  604. static bool setScene(void* obj, const char* data)
  605. {
  606. Scene* pScene = dynamic_cast<Scene*>(Sim::findObject(data));
  607. SceneObject* object = static_cast<SceneObject*>(obj);
  608. if (pScene)
  609. {
  610. if (object->getScene()) object->getScene()->removeFromScene(object);
  611. // is the scene object registered?
  612. if ( object->isProperlyAdded() )
  613. {
  614. // Yes, so we can add to the scene now.
  615. pScene->addToScene(object);
  616. }
  617. else
  618. {
  619. // No, so just set the target scene directly and it will be added to that scene when registered.
  620. object->mpTargetScene = pScene;
  621. }
  622. }
  623. return false;
  624. }
  625. static bool writeScene( void* obj, StringTableEntry pFieldName ) { return false; }
  626. };
  627. #endif // _SCENE_OBJECT_H_