2014-10-17 19:16:48 +00:00
|
|
|
#ifndef CSV_WORLD_PHYSICSSYSTEM_H
|
|
|
|
#define CSV_WORLD_PHYSICSSYSTEM_H
|
|
|
|
|
2014-10-23 07:51:31 +00:00
|
|
|
#include <string>
|
2014-10-17 19:16:48 +00:00
|
|
|
#include <map>
|
2014-10-22 19:59:14 +00:00
|
|
|
#include <vector>
|
2014-10-17 19:16:48 +00:00
|
|
|
|
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class Vector3;
|
|
|
|
class Quaternion;
|
|
|
|
class SceneManager;
|
2014-10-21 20:11:04 +00:00
|
|
|
class Camera;
|
2014-10-17 19:16:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace OEngine
|
|
|
|
{
|
|
|
|
namespace Physic
|
|
|
|
{
|
|
|
|
class PhysicEngine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace CSVWorld
|
|
|
|
{
|
|
|
|
class PhysicsSystem
|
|
|
|
{
|
2014-10-24 09:14:02 +00:00
|
|
|
static PhysicsSystem *mPhysicsSystemInstance;
|
2014-10-24 10:18:29 +00:00
|
|
|
std::map<std::string, std::string> mRefToSceneNode;
|
2014-10-17 19:16:48 +00:00
|
|
|
OEngine::Physic::PhysicEngine* mEngine;
|
2014-10-26 19:50:51 +00:00
|
|
|
|
2014-10-22 19:59:14 +00:00
|
|
|
Ogre::SceneManager *mSceneMgr;
|
2014-10-23 07:51:31 +00:00
|
|
|
std::map<std::string, std::vector<std::string> > mSelectedEntities;
|
2014-10-17 19:16:48 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2014-10-24 09:14:02 +00:00
|
|
|
PhysicsSystem(Ogre::SceneManager *sceneMgr = NULL);
|
2014-10-17 19:16:48 +00:00
|
|
|
~PhysicsSystem();
|
|
|
|
|
2014-10-24 09:14:02 +00:00
|
|
|
static PhysicsSystem *instance();
|
|
|
|
|
|
|
|
void setSceneManager(Ogre::SceneManager *sceneMgr);
|
|
|
|
|
2014-10-26 19:50:51 +00:00
|
|
|
void addObject(const std::string &mesh, const std::string &name,
|
|
|
|
const std::string &referenceId, float scale,
|
|
|
|
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation,
|
|
|
|
bool placeable=false);
|
2014-10-17 19:16:48 +00:00
|
|
|
|
2014-10-23 04:35:01 +00:00
|
|
|
void removeObject(const std::string &name);
|
|
|
|
|
2014-10-25 11:09:19 +00:00
|
|
|
void addHeightField(float* heights, int x, int y, float yoffset,
|
2014-10-26 19:50:51 +00:00
|
|
|
float triSize, float sqrtVerts);
|
2014-10-25 11:09:19 +00:00
|
|
|
|
2014-10-25 20:56:51 +00:00
|
|
|
void removeHeightField(int x, int y);
|
|
|
|
|
2014-10-17 19:16:48 +00:00
|
|
|
void toggleDebugRendering();
|
2014-10-21 20:11:04 +00:00
|
|
|
|
2014-10-26 10:15:47 +00:00
|
|
|
std::pair<std::string, Ogre::Vector3> castRay(float mouseX, float mouseY,
|
|
|
|
Ogre::Vector3* normal, std::string* hit, Ogre::Camera *camera);
|
2014-10-26 19:50:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
void initDebug();
|
|
|
|
void updateSelectionHighlight(std::string sceneNode, const Ogre::Vector3 &position);
|
2014-10-17 19:16:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CSV_WORLD_PHYSICSSYSTEM_H
|