Project

General

Profile

SO3Engine
SO3ShapePyramid.cpp
Go to the documentation of this file.
1
12
13namespace SO3
14{
15
16SShapePyramid::SShapePyramid() : SShape("", SShape::SO3_NULL_COLLISION)
17{
18 // Forbiden, private.
19}
20
21SShapePyramid::SShapePyramid(const std::string& shapeName, SNode* node, const Ogre::Vector3& size) : SShape(shapeName, SShape::SO3_PYRAMID_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 mSize = Ogre::Vector3(std::max(size.x, 0.0001f), std::max(size.y, 0.0001f), std::max(size.z, 0.0001f));
30
31#ifdef USE_COLLISION_NOSCALE
32 Ogre::Vector3 scale = node->GetGlobalScale();
33 mSize = mSize * scale;
34 mComputedOffset = poffset * scale;
35#else
36 mComputedOffset = poffset;
37#endif
38
40}
41
42SShapePyramid::SShapePyramid(const std::string& shapeName, SNode* node, const Ogre::Vector3& size, const Ogre::Vector3& offset, const Ogre::Quaternion& quat) : SShape(shapeName, SShape::SO3_PYRAMID_COLLISION)
43{
44 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
45 if ((node != 0) && node->GetNodeType() == SNode::ENTITY_TYPE_ID)
46 {
47 SEntity* entity = static_cast<SEntity*> (node);
48 poffset = entity->getOgreEntityPointer()->getBoundingBox().getCenter();
49 }
50 mSize = Ogre::Vector3(std::max(size.x, 0.0001f), std::max(size.y, 0.0001f), std::max(size.z, 0.0001f));
51
52 mBaseOffset = offset;
53#ifdef USE_COLLISION_NOSCALE
54 Ogre::Vector3 scale = node->GetGlobalScale();
55 mSize = mSize * scale;
56 mComputedOffset = (poffset + offset) * scale;
57#else
58 mComputedOffset = poffset + offset;
59#endif
60 mBaseRotation = quat;
61
63}
64
68
70{
71 return mSize;
72}
73
74}
Ogre::Entity * getOgreEntityPointer()
SScene * GetParentScene()
NodeType GetNodeType()
virtual Ogre::Vector3 GetGlobalScale()
OgreNewt::World * GetPhysicWorld()
SPhysicWorld * GetPhysicsWorld()
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
Ogre::Vector3 GetSize()
Manage physics shape .
Collision * CollisionPtr