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