00001
00008 #include "SO3ShapeConvexHull.h"
00009 #include "../SO3SceneGraph/SO3NodeScol.h"
00010 #include "../SO3SceneGraph/SO3Entity.h"
00011 #include "../SO3SceneGraph/SO3Scene.h"
00012
00013 namespace SO3
00014 {
00015
00016 SShapeConvexHull::SShapeConvexHull() : SShape("", SShape::SO3_NULL_COLLISION)
00017 {
00018
00019 }
00020
00021 SShapeConvexHull::SShapeConvexHull(std::string shapeName, SEntity* entity, Ogre::Real tolerance) : SShape(shapeName, SShape::SO3_SHAPE_COLLISION)
00022 {
00023 Ogre::Vector3 poffset = Ogre::Vector3::ZERO;
00024 mCollisionPtr = OgreNewt::CollisionPtr(new OgreNewt::CollisionPrimitives::ConvexHull(entity->GetParentScene()->GetPhysicsWorld()->GetPhysicWorld(), entity->getOgreEntityPointer(), 0, Ogre::Quaternion::IDENTITY, poffset, tolerance, entity->GetGlobalScale()));
00025
00026 mTolerance = tolerance;
00027 }
00028
00029 SShapeConvexHull::~SShapeConvexHull()
00030 {
00031 }
00032
00033 Ogre::Real SShapeConvexHull::GetTolerance()
00034 {
00035 return mTolerance;
00036 }
00037
00038 Ogre::Vector3 SShapeConvexHull::CalculateInertialMatrix()
00039 {
00040 Ogre::Vector3 iner, off;
00041 (static_cast<OgreNewt::ConvexCollision*>(mCollisionPtr.get()))->calculateInertialMatrix(iner, off);
00042 return iner;
00043 }
00044
00045 Ogre::Vector3 SShapeConvexHull::CalculateOffset()
00046 {
00047 Ogre::Vector3 iner, off;
00048 (static_cast<OgreNewt::ConvexCollision*>(mCollisionPtr.get()))->calculateInertialMatrix(iner, off);
00049 return off;
00050 }
00051
00052 }