Experimental, compiles but does not work.
parent
5f11ccc298
commit
03a30c3f1d
@ -0,0 +1,64 @@
|
||||
#include "physicssystem.hpp"
|
||||
|
||||
#include <openengine/bullet/physic.hpp>
|
||||
//#include <openengine/bullet/BtOgreExtras.h>
|
||||
//#include <openengine/ogre/renderer.hpp>
|
||||
|
||||
#include <components/nifbullet/bulletnifloader.hpp>
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
PhysicsSystem::PhysicsSystem(Ogre::SceneManager *sceneMgr)
|
||||
{
|
||||
// Create physics. shapeLoader is deleted by the physic engine
|
||||
NifBullet::ManualBulletShapeLoader* shapeLoader = new NifBullet::ManualBulletShapeLoader();
|
||||
mEngine = new OEngine::Physic::PhysicEngine(shapeLoader);
|
||||
|
||||
mEngine->setSceneManager(sceneMgr); // needed for toggleDebugRendering()
|
||||
}
|
||||
|
||||
PhysicsSystem::~PhysicsSystem()
|
||||
{
|
||||
delete mEngine;
|
||||
}
|
||||
|
||||
// OpenMW | OpenCS
|
||||
// Ptr | ?
|
||||
// ptr.getClass().getModel(ptr) | ? // see Object::update()
|
||||
// ptr.getRefData().getBaseNode() | ?
|
||||
// ptr.getCellRef().getScale() | ?
|
||||
//
|
||||
// getModel() returns the mesh; each class has its own implementation
|
||||
//
|
||||
//void PhysicsSystem::addObject (const Ptr& ptr, bool placeable)
|
||||
void PhysicsSystem::addObject(const std::string &mesh,
|
||||
const std::string &name,
|
||||
float scale,
|
||||
const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &rotation,
|
||||
Ogre::Vector3* scaledBoxTranslation,
|
||||
Ogre::Quaternion* boxRotation,
|
||||
bool raycasting,
|
||||
bool placeable)
|
||||
{
|
||||
#if 0
|
||||
std::string mesh = ptr.getClass().getModel(ptr);
|
||||
Ogre::SceneNode* node = ptr.getRefData().getBaseNode();
|
||||
handleToMesh[node->getName()] = mesh;
|
||||
mEngine->createAndAdjustRigidBody(
|
||||
mesh, node->getName(), ptr.getCellRef().getScale(), node->getPosition(), node->getOrientation(), 0, 0, false, placeable);
|
||||
mEngine->createAndAdjustRigidBody(
|
||||
mesh, node->getName(), ptr.getCellRef().getScale(), node->getPosition(), node->getOrientation(), 0, 0, true, placeable);
|
||||
#endif
|
||||
mEngine->createAndAdjustRigidBody(mesh, name, scale, position, rotation,
|
||||
0, 0, false, placeable);
|
||||
mEngine->createAndAdjustRigidBody(mesh, name, scale, position, rotation,
|
||||
0, 0, true, placeable);
|
||||
}
|
||||
|
||||
void PhysicsSystem::toggleDebugRendering()
|
||||
{
|
||||
//mEngine->toggleDebugRendering();
|
||||
mEngine->setDebugRenderingMode(1);
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
#ifndef CSV_WORLD_PHYSICSSYSTEM_H
|
||||
#define CSV_WORLD_PHYSICSSYSTEM_H
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Vector3;
|
||||
class Quaternion;
|
||||
class SceneManager;
|
||||
}
|
||||
|
||||
namespace OEngine
|
||||
{
|
||||
namespace Physic
|
||||
{
|
||||
class PhysicEngine;
|
||||
}
|
||||
}
|
||||
|
||||
namespace CSVWorld
|
||||
{
|
||||
class PhysicsSystem
|
||||
{
|
||||
std::map<std::string, std::string> handleToMesh;
|
||||
OEngine::Physic::PhysicEngine* mEngine;
|
||||
//Ogre::SceneManager *mSceneMgr;
|
||||
|
||||
public:
|
||||
|
||||
PhysicsSystem(Ogre::SceneManager *sceneMgr);
|
||||
~PhysicsSystem();
|
||||
|
||||
void addObject(const std::string &mesh,
|
||||
const std::string &name,
|
||||
float scale,
|
||||
const Ogre::Vector3 &position,
|
||||
const Ogre::Quaternion &rotation,
|
||||
Ogre::Vector3* scaledBoxTranslation = 0,
|
||||
Ogre::Quaternion* boxRotation = 0,
|
||||
bool raycasting=false,
|
||||
bool placeable=false);
|
||||
|
||||
void toggleDebugRendering();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CSV_WORLD_PHYSICSSYSTEM_H
|
Loading…
Reference in New Issue