SO3Engine
src
SO3PhysicGraph
SO3ShapeBox.cpp
Go to the documentation of this file.
1
8
#include "
SO3PhysicGraph/SO3ShapeBox.h
"
9
#include "
SO3SceneGraph/SO3NodeScol.h
"
10
#include "
SO3SceneGraph/SO3Entity.h
"
11
#include "
SO3SceneGraph/SO3Scene.h
"
12
13
namespace
SO3
14
{
15
16
SShapeBox::SShapeBox() :
SShape
(
""
,
SShape
::SO3_NULL_COLLISION)
17
{
18
// Forbiden, private.
19
}
20
21
SShapeBox::SShapeBox(
const
std::string& shapeName,
SNode
* node,
const
Ogre::Vector3& size) :
SShape
(shapeName,
SShape
::SO3_BOX_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
39
mCollisionPtr
=
OgreNewt::CollisionPtr
(
new
OgreNewt::CollisionPrimitives::Box
(node->
GetParentScene
()->
GetPhysicsWorld
()->
GetPhysicWorld
(), mSize, 0, Ogre::Quaternion::IDENTITY,
mComputedOffset
));
40
}
41
42
SShapeBox::SShapeBox(
const
std::string& shapeName,
SNode
* node,
const
Ogre::Vector3& size,
const
Ogre::Vector3& offset,
const
Ogre::Quaternion& quat) :
SShape
(shapeName,
SShape
::SO3_BOX_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
62
mCollisionPtr
=
OgreNewt::CollisionPtr
(
new
OgreNewt::CollisionPrimitives::Box
(node->
GetParentScene
()->
GetPhysicsWorld
()->
GetPhysicWorld
(), mSize, 0,
mBaseRotation
,
mComputedOffset
));
63
}
64
65
SShapeBox::~SShapeBox
()
66
{
67
}
68
69
Ogre::Vector3
SShapeBox::GetSize
()
70
{
71
return
mSize;
72
}
73
74
}
SO3Entity.h
SO3NodeScol.h
SO3Scene.h
SO3ShapeBox.h
OgreNewt::CollisionPrimitives::Box
standard primitive Box.
Definition
OgreNewt_CollisionPrimitives.h:45
SO3::SEntity
Definition
SO3Entity.h:43
SO3::SEntity::getOgreEntityPointer
Ogre::Entity * getOgreEntityPointer()
Definition
SO3Entity.cpp:684
SO3::SNode
Definition
SO3NodeScol.h:43
SO3::SNode::GetParentScene
SScene * GetParentScene()
Definition
SO3NodeScol.cpp:298
SO3::SNode::GetNodeType
NodeType GetNodeType()
Definition
SO3NodeScol.cpp:303
SO3::SNode::GetGlobalScale
virtual Ogre::Vector3 GetGlobalScale()
Definition
SO3NodeScol.cpp:784
SO3::SNode::ENTITY_TYPE_ID
@ ENTITY_TYPE_ID
Definition
SO3NodeScol.h:48
SO3::SPhysicWorld::GetPhysicWorld
OgreNewt::World * GetPhysicWorld()
Definition
SO3Physics.cpp:93
SO3::SScene::GetPhysicsWorld
SPhysicWorld * GetPhysicsWorld()
Definition
SO3Scene.cpp:1332
SO3::SShapeBox::GetSize
Ogre::Vector3 GetSize()
Definition
SO3ShapeBox.cpp:69
SO3::SShapeBox::~SShapeBox
~SShapeBox()
Definition
SO3ShapeBox.cpp:65
SO3::SShape
Definition
SO3Shape.h:47
SO3::SShape::mComputedOffset
Ogre::Vector3 mComputedOffset
Definition
SO3Shape.h:70
SO3::SShape::mCollisionPtr
OgreNewt::CollisionPtr mCollisionPtr
Definition
SO3Shape.h:66
SO3::SShape::mBaseOffset
Ogre::Vector3 mBaseOffset
Definition
SO3Shape.h:68
SO3::SShape::mBaseRotation
Ogre::Quaternion mBaseRotation
Definition
SO3Shape.h:67
SShape
Manage physics shape .
OgreNewt::CollisionPtr
Collision * CollisionPtr
Definition
OgreNewt_Collision.h:156
SO3
Definition
SO3DataScol.h:38
Generated by
1.9.8