00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00035 #ifndef __SO3NODESCOL_H__
00036 #define __SO3NODESCOL_H__
00037
00038 #include "../SCOLBasic/SO3Prerequisites.h"
00039 #include "../SCOLBasic/SO3DataScol.h"
00040 #include <Ogre.h>
00041
00042 namespace SO3
00043 {
00044
00045 class SNode : public SData
00046 {
00047 public:
00048 enum NodeType
00049 {
00050 NODE_TYPE_ID = 0,
00051 ENTITY_TYPE_ID = 1,
00052 CAMERA_TYPE_ID = 2,
00053 LIGHT_TYPE_ID = 3,
00054 SCENENODE_TYPE_ID = 4,
00055 VIEWPORT_TYPE_ID = 5,
00056 BODY_TYPE_ID = 6,
00057 SKELETON_TYPE_ID = 7,
00058 BONE_TYPE_ID = 8,
00059 PARTICLE_SYSTEM_TYPE_ID = 9,
00060 DYNAMIC_CUBE_MAP_ID = 10,
00061 DYNAMIC_REFLECTION_MAP_ID = 11
00062 };
00063 enum NodeTransformSpace
00064 {
00065 SO3_LOCAL_TS = 0,
00066 SO3_PARENT_TS = 1,
00067 SO3_WORLD_TS = 2
00068 };
00069
00070 protected:
00071 SScene* currentScene;
00072 Ogre::SceneNode* O3SceneNode;
00073 Ogre::MovableObject* ogreMovableObject;
00074 SBody* nodeBody;
00075
00076 private:
00077 const NodeType type;
00078 SNode* nodeFather;
00079 SNode* autoTrackTargetNode;
00080 SAnimMap animationList;
00081 SAnimIndexMap animationListByIndex;
00082 int mouseFlags;
00083 bool isForeGround;
00084 bool isMouseClick;
00085 unsigned short animationCounter;
00086 SNodeMap childNodeList;
00087
00088
00089 Ogre::Vector3 initialPosition;
00090 Ogre::Quaternion initialOrientation;
00091 Ogre::Vector3 initialScale;
00092
00093 public:
00094
00095
00096
00097 SNode(SScene* parent, std::string nodeName, bool isRootNode=false);
00098
00101 ~SNode();
00102
00105 SScene* GetParentScene();
00106
00109 Ogre::SceneNode* GetOgreSceneNodePointer();
00110
00113 Ogre::MovableObject* GetMovableObjectPointer();
00114
00117 bool getSceneNodeIsMouseForeground();
00118
00121 void setSceneNodeIsMouseForeground(bool mForeground);
00122
00125 bool getSceneNodeIsMouseClick();
00126
00129 void setSceneNodeIsMouseClick(bool mClickable);
00130
00133 int getSceneNodeMouseFlags();
00134
00137 void setSceneNodeMouseFlags(int flags);
00138
00141 bool getSceneNodeHasBody();
00142
00145 SBody* getSceneNodeBody();
00146
00149 void UpdateNodeBody(bool bScale);
00150
00154 void destroyAssociatedMoveableObject();
00155
00158 void SNode::disableAutoTarget();
00159
00162 NodeType GetNodeType();
00163
00166 void AttachToParent(SNode* newParentNode);
00167
00170 void DetachFromParent();
00171
00174 SNode* GetParentSceneNode();
00175
00178 const SNodeMap GetChildrenNodes() const;
00179
00182 virtual int GetNumChildren();
00183
00186 void DetachAllChildren();
00187
00191 virtual void SetCastShadows(bool castShadows);
00192
00196 virtual bool GetCastShadows();
00197
00201 virtual void SetRenderingDistance(float distance);
00202
00206 virtual float GetRenderingDistance();
00207
00211 virtual Ogre::Vector3 GetBoundingBoxSize(bool childs = false);
00212
00216 virtual Ogre::Vector3 GetBoundingBoxCenter(bool childs = false);
00217
00220 virtual Ogre::Matrix4 GetTransformationMatrix();
00221
00225 virtual Ogre::Vector3 GetPosition();
00226
00230 virtual void SetPosition(Ogre::Vector3 pos);
00231
00235 virtual Ogre::Quaternion GetOrientation();
00236
00240 virtual void SetOrientation(Ogre::Quaternion quat);
00241
00245 virtual void AddOrientation(Ogre::Quaternion quat);
00246
00250 virtual Ogre::Vector3 GetScale();
00251
00255 virtual void SetScale(Ogre::Vector3 scale);
00256
00260 virtual Ogre::Vector3 GetGlobalPosition();
00261
00265 virtual void SetGlobalPosition(Ogre::Vector3 pos);
00266
00270 virtual Ogre::Quaternion GetGlobalOrientation();
00271
00275 virtual void SetGlobalOrientation(Ogre::Quaternion quat);
00276
00280 virtual Ogre::Vector3 GetGlobalScale();
00281
00285 virtual void SetGlobalScale(Ogre::Vector3 scale);
00286
00290 virtual void StoreInitialPRS();
00291
00295 virtual void ResetToInitialPRS();
00296
00300 void ResetToInitialPosition();
00301
00305 virtual void ResetToInitialOrientation();
00306
00310 void ResetToInitialScale();
00311
00315 virtual Ogre::Vector3 GetInitialPosition();
00316
00320 virtual Ogre::Quaternion GetInitialOrientation();
00321
00325 virtual Ogre::Vector3 GetInitialScale();
00326
00329 bool GetShowBoundingBox();
00330
00333 void SetShowBoundingBox(bool showBounding);
00334
00337 void SetAutoTracking(bool autoTrack, SNode* targetNode=0, Ogre::Vector3 localDirectionVector=Ogre::Vector3::NEGATIVE_UNIT_Z, Ogre::Vector3 offset=Ogre::Vector3::ZERO);
00338
00341 SNode* GetAutoTrackingTarget();
00342
00345 virtual void Pitch(float radianAngle, SNode::NodeTransformSpace relativeTo=SNode::SO3_LOCAL_TS);
00346
00349 virtual void Yaw(float radianAngle, SNode::NodeTransformSpace relativeTo=SNode::SO3_LOCAL_TS);
00350
00353 virtual void Roll(float radianAngle, SNode::NodeTransformSpace relativeTo=SNode::SO3_LOCAL_TS);
00354
00357 virtual void Rotate(Ogre::Vector3 axis, float radianAngle, SNode::NodeTransformSpace relativeTo=SNode::SO3_LOCAL_TS);
00358
00361 virtual void Translate(Ogre::Vector3 d, SNode::NodeTransformSpace relativeTo=SNode::SO3_PARENT_TS);
00362
00365 void SetDirection(Ogre::Vector3 vec, SNode::NodeTransformSpace relativeTo=SNode::SO3_LOCAL_TS, Ogre::Vector3 localDirectionVector = Ogre::Vector3::NEGATIVE_UNIT_Z);
00366
00369 void LookAt(Ogre::Vector3 targetPoint, SNode::NodeTransformSpace relativeTo, Ogre::Vector3 localDirectionVector = Ogre::Vector3::NEGATIVE_UNIT_Z);
00370
00373 bool GetVisible();
00374
00377 void SetVisible(bool visible, bool cascade = true);
00378
00383 SNodeAnimation* CreateNodeAnimation(std::string animationName, float animationLength);
00384
00390 void DeleteAnimation(SAnim* existingAnimation);
00391
00394 unsigned short GetNumAnimations();
00395
00398 SAnim* GetAnimation(std::string animationName);
00399
00402 SAnim* GetAnimation(unsigned short animationIndex);
00403
00406 SAnimMap GetAnimations() const;
00407
00411 Ogre::Vector3 GetPositionFromNode(SNode* nodeRef);
00412
00416 Ogre::Quaternion GetOrientationFromNode(SNode* nodeRef);
00417
00421 Ogre::Vector3 GetScaleFromNode(SNode* nodeRef);
00422
00425 virtual void SetInheritOrientation(bool state);
00426
00429 virtual bool GetInheritOrientation();
00430
00433 virtual void ResetOrientation();
00434
00437 void DeleteBody();
00438
00441 SBody* CreateBoxBody(Ogre::Vector3 boxsetting);
00442
00445 SBody* CreateConeBody(Ogre::Real radius, Ogre::Real height);
00446
00449 SBody* CreateEllipsoidBody(Ogre::Vector3 size);
00450
00453 SBody* CreateCapsuleBody(Ogre::Real radius, Ogre::Real height);
00454
00457 SBody* CreateCylinderBody(Ogre::Real radius, Ogre::Real height);
00458
00461 SBody* CreateChamferCylinderBody(Ogre::Real radius, Ogre::Real height);
00462
00465 SBody* CreatePyramidBody(Ogre::Vector3 size);
00466
00469 SBody* CreateConvexHullBody(Ogre::Real tolerance);
00470
00473 SBody* CreateTreeBody(bool optimize);
00474
00475 protected:
00479 SNode(SScene* parent, std::string nodeName, NodeType nodeType);
00480
00484 void AddAnimation(SAnim* existingAnimation);
00485
00489 void RemoveAnimation(SAnim* existingAnimation);
00490
00494 void RemoveAnimation(std::string animationName);
00495
00499 Ogre::Vector3 GetSonsBoundingBox();
00500 private:
00504 SNode();
00505
00508 void AddChildNode(SNode* newChild);
00509
00512 void RemoveChildNode(SNode* existingChild);
00513 };
00514
00515 }
00516
00517 #endif