Project

General

Profile

SO3Engine
SO3ShapeCone.cpp
Go to the documentation of this file.
1
12
13namespace SO3
14{
15
16SShapeCone::SShapeCone() : SShape("", SShape::SO3_NULL_COLLISION)
17{
18 // Forbiden, private.
19}
20
21SShapeCone::SShapeCone(const std::string& shapeName, SNode* node, const Ogre::Real& radius, const Ogre::Real& height) : SShape(shapeName, SShape::SO3_CONE_COLLISION)
22{
23 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
24 if ((node != 0) && node->GetNodeType() == SNode::ENTITY_TYPE_ID)
25 {
26 SEntity* entity = static_cast<SEntity*> (node);
27 poffset = entity->getOgreEntityPointer()->getBoundingBox().getCenter();
28 }
29#ifdef USE_COLLISION_NOSCALE
30 Ogre::Vector3 scale = node->GetGlobalScale();
31 mComputedOffset = poffset * scale;
32 mRadius = std::max(radius, 0.0001f) * scale.x;
33 mHeight = std::max(height, 0.0001f) * scale.y;
34#else
35 mComputedOffset = poffset;
36 mRadius = std::max(radius, 0.0001f);
37 mHeight = std::max(height, 0.0001f);
38#endif
39
41}
42
43SShapeCone::SShapeCone(const std::string& shapeName, SNode* node, const Ogre::Real& radius, const Ogre::Real& height, const Ogre::Vector3& offset, const Ogre::Quaternion& quat) : SShape(shapeName, SShape::SO3_CONE_COLLISION)
44{
45 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
46 if ((node != 0) && node->GetNodeType() == SNode::ENTITY_TYPE_ID)
47 {
48 SEntity* entity = static_cast<SEntity*> (node);
49 poffset = entity->getOgreEntityPointer()->getBoundingBox().getCenter();
50 }
51
52 mBaseOffset = offset;
53#ifdef USE_COLLISION_NOSCALE
54 Ogre::Vector3 scale = node->GetGlobalScale();
55 mComputedOffset = (poffset + offset) * scale;
56 mRadius = std::max(radius, 0.0001f) * scale.x;
57 mHeight = std::max(height, 0.0001f) * scale.y;
58#else
59 mComputedOffset = poffset + offset;
60 mRadius = std::max(radius, 0.0001f);
61 mHeight = std::max(height, 0.0001f);
62#endif
63 mBaseRotation = quat;
64
66}
67
71
73{
74 return mRadius;
75}
76
78{
79 return mHeight;
80}
81
82}
Ogre::Entity * getOgreEntityPointer()
SScene * GetParentScene()
NodeType GetNodeType()
virtual Ogre::Vector3 GetGlobalScale()
OgreNewt::World * GetPhysicWorld()
SPhysicWorld * GetPhysicsWorld()
Ogre::Real GetHeight()
Ogre::Real GetRadius()
Ogre::Vector3 mComputedOffset
Definition SO3Shape.h:70
OgreNewt::CollisionPtr mCollisionPtr
Definition SO3Shape.h:66
Ogre::Vector3 mBaseOffset
Definition SO3Shape.h:68
Ogre::Quaternion mBaseRotation
Definition SO3Shape.h:67
Manage physics shape .
Collision * CollisionPtr