SO3Engine
SO3NodeScol.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3NODESCOL_H__
33#define __SO3NODESCOL_H__
34
37#include <Ogre.h>
38
39namespace SO3
40{
41
42class _SO3_Export SNode : public SData
43{
44public:
46 {
47 NODE_TYPE_ID = 0,
48 ENTITY_TYPE_ID = 1,
49 CAMERA_TYPE_ID = 2,
50 LIGHT_TYPE_ID = 3,
51 SKELETON_TYPE_ID = 4,
52 BONE_TYPE_ID = 5,
53 PARTICLE_SYSTEM_TYPE_ID = 6,
54 DYNAMIC_CUBE_MAP_ID = 7,
55 DYNAMIC_REFLECTION_MAP_ID = 8,
56 RENDER_TO_TEXTURE_ID = 9,
57 LINE_ENTITY_TYPE_ID = 10,
58 VIRTUAL_POINTER_TYPE_ID = 11
59 };
61 {
62 SO3_LOCAL_TS = 0,
63 SO3_PARENT_TS = 1,
64 SO3_WORLD_TS = 2
65 };
66
67protected:
69 Ogre::SceneNode* O3SceneNode;
70 Ogre::MovableObject* ogreMovableObject;
72 unsigned short animationCounter;
73
74 //$BB initial PRS setInitialState use the local position, and keep this functionnality for animations
75 Ogre::Vector3 initialPosition;
76 Ogre::Quaternion initialOrientation;
77 Ogre::Vector3 initialScale;
78
79private:
80 const NodeType type;
81 SNode* nodeFather;
82 SNode* autoTrackTargetNode;
83 Ogre::StaticGeometry* staticGeometry;
84 bool staticVisibility;
85
86 SAnimMap animationList;
87 SAnimIndexMap animationListByIndex;
88 int mouseFlags;
89 bool isForeGround;
90 bool isMouseClick;
91 SNodeMap childNodeList;
92 bool mIsDirty;
93 int mFlags;
94 bool mPhysicsOverride;
95 bool mVisible;
96
97public:
98 /*
99 Constructor
100 */
101 SNode(SScene* parent, const std::string& nodeName, const bool& isRootNode=false);
102
105 virtual ~SNode();
106
109 SScene* GetParentScene();
110
113 Ogre::SceneNode* GetOgreSceneNodePointer();
114
117 Ogre::MovableObject* GetMovableObjectPointer();
118
121 bool GetSceneNodeIsMouseForeground();
122
125 void SetSceneNodeIsMouseForeground(const bool& mForeground);
126
129 bool GetSceneNodeIsMouseClick();
130
133 void SetSceneNodeIsMouseClick(const bool& mClickable);
134
137 int GetSceneNodeMouseFlags();
138
141 void SetSceneNodeMouseFlags(const int& flags);
142
145 bool GetSceneNodeHasBody();
146
149 SBody* GetSceneNodeBody();
150
153 void RestoreStaticGraph();
154
157 void SetAsStaticGeometry(const bool& state);
158
161 bool GetAsStaticGeometry();
162
165 Ogre::StaticGeometry* GetStaticGeometry();
166
169 void SetFlags(const int& flags);
170
171
174 void SetPhysicsOverride(bool state);
175
178 bool GetPhysicsOverride();
179
182 int GetFlags();
183
186 void UpdateNodeBody(const bool& bScale);
187
190 void DisableAutoTarget();
191
194 NodeType GetNodeType();
195
198 void AttachToParent(SNode* newParentNode);
199
202 void DetachFromParent();
203
206 SNode* GetParentSceneNode();
207
210 const SNodeMap GetChildrenNodes() const;
211
214 virtual int GetNumChildren();
215
218 void DetachAllChildren();
219
223 virtual void SetCastShadows(const bool& castShadows);
224
228 virtual bool GetCastShadows();
229
233 virtual void SetRenderingDistance(const float& distance);
234
238 virtual float GetRenderingDistance();
239
243 virtual Ogre::Vector3 GetBoundingBoxSize(const bool& childs = false);
244
248 virtual Ogre::Vector3 GetBoundingBoxCenter(const bool& childs = false);
249
253 virtual Ogre::Vector3 GetWorldBoundingBoxSize(const bool& childs = false);
254
258 virtual Ogre::Vector3 GetWorldBoundingBoxCenter(const bool& childs = false);
259
262 virtual Ogre::Matrix4 GetTransformationMatrix();
263
267 virtual Ogre::Vector3 GetPosition();
268
272 virtual void SetPosition(const Ogre::Vector3& pos);
273
277 virtual Ogre::Quaternion GetOrientation();
278
282 virtual void SetOrientation(const Ogre::Quaternion& quat);
283
287 virtual void AddOrientation(const Ogre::Quaternion& quat);
288
292 virtual Ogre::Vector3 GetScale();
293
297 virtual void SetScale(const Ogre::Vector3& scale);
298
302 virtual Ogre::Vector3 GetGlobalPosition();
303
307 virtual void SetGlobalPosition(const Ogre::Vector3& pos, bool updateBody = true);
308
312 virtual Ogre::Quaternion GetGlobalOrientation();
313
317 virtual void SetGlobalOrientation(const Ogre::Quaternion& quat, bool updateBody = true);
318
322 virtual Ogre::Vector3 GetGlobalScale();
323
327 virtual void SetGlobalScale(const Ogre::Vector3& scale, bool updateBody = true);
328
332 virtual void StoreInitialPRS();
333
337 virtual void ResetToInitialPRS();
338
342 void ResetToInitialPosition();
343
347 virtual void ResetToInitialOrientation();
348
352 void ResetToInitialScale();
353
357 virtual Ogre::Vector3 GetInitialPosition();
358
362 virtual Ogre::Quaternion GetInitialOrientation();
363
367 virtual Ogre::Vector3 GetInitialScale();
368
371 bool GetShowBoundingBox();
372
375 void SetShowBoundingBox(const bool& showBounding);
376
379 void SetAutoTracking(const bool& autoTrack, SNode* targetNode=0, const Ogre::Vector3& localDirectionVector=Ogre::Vector3::NEGATIVE_UNIT_Z, const Ogre::Vector3& offset=Ogre::Vector3::ZERO);
380
383 SNode* GetAutoTrackingTarget();
384
387 virtual void Pitch(const float& radianAngle, const SNode::NodeTransformSpace& relativeTo=SNode::SO3_LOCAL_TS);
388
391 virtual void Yaw(const float& radianAngle, const SNode::NodeTransformSpace& relativeTo=SNode::SO3_LOCAL_TS);
392
395 virtual void Roll(const float& radianAngle, const SNode::NodeTransformSpace& relativeTo=SNode::SO3_LOCAL_TS);
396
399 virtual void Rotate(const Ogre::Vector3& axis, const float& radianAngle, const SNode::NodeTransformSpace& relativeTo=SNode::SO3_LOCAL_TS);
400
403 virtual void Translate(const Ogre::Vector3& d, const SNode::NodeTransformSpace& relativeTo=SNode::SO3_PARENT_TS);
404
407 void SetDirection(const Ogre::Vector3& vec, const SNode::NodeTransformSpace& relativeTo=SNode::SO3_LOCAL_TS, const Ogre::Vector3& localDirectionVector = Ogre::Vector3::NEGATIVE_UNIT_Z);
408
411 Ogre::Vector3 GetDirection(bool derived = false, Ogre::Vector3 axis = Ogre::Vector3::NEGATIVE_UNIT_Z);
412
415 void LookAt(const Ogre::Vector3& targetPoint, const SNode::NodeTransformSpace& relativeTo, const Ogre::Vector3& localDirectionVector = Ogre::Vector3::NEGATIVE_UNIT_Z);
416
419 bool GetVisible();
420
423 void SetVisible(const bool& visible, const bool& cascade = true);
424
429 SNodeAnimation* CreateNodeAnimation(const std::string& animationName, const float& animationLength);
430
436 void DeleteAnimation(SAnim* existingAnimation);
437
440 size_t GetNumAnimations();
441
444 SAnim* GetAnimation(const std::string& animationName);
445
448 SAnim* GetAnimation(const unsigned short& animationIndex);
449
452 SAnimMap GetAnimations() const;
453
456 bool IsAnimated();
457
461 Ogre::Vector3 GetPositionFromNode(SNode* nodeRef);
462
466 Ogre::Quaternion GetOrientationFromNode(SNode* nodeRef);
467
471 Ogre::Vector3 GetScaleFromNode(SNode* nodeRef);
472
475 virtual void SetInheritOrientation(const bool& state);
476
479 virtual bool GetInheritOrientation();
480
483 virtual void ResetOrientation();
484
487 void DeleteBody();
488
491 SBody* CreateBoxBody(const Ogre::Vector3& boxsetting);
492
495 SBody* CreateBoxBody(const Ogre::Vector3& boxsetting, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
496
499 SBody* CreateConeBody(const Ogre::Real& radius, const Ogre::Real& height);
500
503 SBody* CreateConeBody(const Ogre::Real& radius, const Ogre::Real& height, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
504
507 SBody* CreateEllipsoidBody(const Ogre::Vector3& size);
508
511 SBody* CreateEllipsoidBody(const Ogre::Vector3& size, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
512
515 SBody* CreateCapsuleBody(const Ogre::Real& radius, const Ogre::Real& height);
516
519 SBody* CreateCapsuleBody(const Ogre::Real& radius, const Ogre::Real& height, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
520
523 SBody* CreateCylinderBody(const Ogre::Real& radius, const Ogre::Real& height);
524
527 SBody* CreateCylinderBody(const Ogre::Real& radius, const Ogre::Real& height, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
528
531 SBody* CreateChamferCylinderBody(const Ogre::Real& radius, const Ogre::Real& height);
532
535 SBody* CreateChamferCylinderBody(const Ogre::Real& radius, const Ogre::Real& height, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
536
539 SBody* CreatePyramidBody(const Ogre::Vector3& size);
540
543 SBody* CreatePyramidBody(const Ogre::Vector3& size, const Ogre::Vector3& offset, const Ogre::Quaternion& quat);
544
547 SBody* CreateConvexHullBody(const Ogre::Real& tolerance);
548
551 SBody* CreateConcaveHullBody(const Ogre::Real& tolerance);
552
555 SBody* CreateTreeBody(const bool& optimize);
556
559 bool IsDirty();
560
563 void SetDirty(bool state);
564
567 void UpdateNodeFromBody();
568
571 void ResetNode();
572protected:
576 SNode(SScene* parent, const std::string& nodeName, const NodeType& nodeType);
577
581 void AddAnimation(SAnim* existingAnimation);
582
586 void RemoveAnimation(SAnim* existingAnimation);
587
591 void RemoveAnimation(const std::string& animationName);
592
596 Ogre::Vector3 GetSonsBoundingBox();
597
601 Ogre::Vector3 GetSonsWorldBoundingBox();
602private:
606 SNode();
607
610 void AddChildNode(SNode* newChild);
611
614 void RemoveChildNode(SNode* existingChild);
615};
616
617}
618
619#endif
librairies include
SScene * currentScene
Definition SO3NodeScol.h:68
Ogre::SceneNode * O3SceneNode
Definition SO3NodeScol.h:69
Ogre::Vector3 initialPosition
Definition SO3NodeScol.h:75
unsigned short animationCounter
Definition SO3NodeScol.h:72
Ogre::MovableObject * ogreMovableObject
Definition SO3NodeScol.h:70
Ogre::Quaternion initialOrientation
Definition SO3NodeScol.h:76
Ogre::Vector3 initialScale
Definition SO3NodeScol.h:77
SBody * nodeBody
Definition SO3NodeScol.h:71
std::unordered_map< unsigned short, SAnim * > SAnimIndexMap
std::unordered_map< std::string, SNode * > SNodeMap
std::unordered_map< std::string, SAnim * > SAnimMap
STBI_EXTERN unsigned long flags
Definition stb_image.h:1182