SO3Engine
SO3ShapeChamferCylinder.cpp
Go to the documentation of this file.
1
12
13namespace SO3
14{
15
16SShapeChamferCylinder::SShapeChamferCylinder() : SShape("", SShape::SO3_NULL_COLLISION)
17{
18 // Forbiden, private.
19}
20
21SShapeChamferCylinder::SShapeChamferCylinder(const std::string& shapeName, SNode* node, const Ogre::Real& radius, const Ogre::Real& height) : SShape(shapeName, SShape::SO3_CHAMFERCYLINDRE_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
30#ifdef USE_COLLISION_NOSCALE
31 Ogre::Vector3 scale = node->GetGlobalScale();
32 mComputedOffset = poffset * scale;
33 mRadius = std::max(radius, 0.0001f) * scale.x;
34 mHeight = std::max(height, 0.0001f) * scale.y;
35#else
36 mComputedOffset = poffset;
37 mRadius = std::max(radius, 0.0001f);
38 mHeight = std::max(height, 0.0001f);
39#endif
40
42}
43
44SShapeChamferCylinder::SShapeChamferCylinder(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_CHAMFERCYLINDRE_COLLISION)
45{
46 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
47 if ((node != 0) && node->GetNodeType() == SNode::ENTITY_TYPE_ID)
48 {
49 SEntity* entity = static_cast<SEntity*> (node);
50 poffset = entity->getOgreEntityPointer()->getBoundingBox().getCenter();
51 }
52
53 mBaseOffset = offset;
54#ifdef USE_COLLISION_NOSCALE
55 Ogre::Vector3 scale = node->GetGlobalScale();
56 mComputedOffset = (poffset + offset) * scale;
57 mRadius = std::max(radius, 0.0001f) * scale.x;
58 mHeight = std::max(height, 0.0001f) * scale.y;
59#else
60 mComputedOffset = poffset + offset;
61 mRadius = std::max(radius, 0.0001f);
62 mHeight = std::max(height, 0.0001f);
63#endif
64 mBaseRotation = quat;
65
67}
68
72
74{
75 return mRadius;
76}
77
79{
80 return mHeight;
81}
82
83}
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
Manage physics shape .
Collision * CollisionPtr