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-30 21:18:15 +00:00
|
|
|
#include <list>
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-31 10:50:57 +00:00
|
|
|
namespace CSVRender
|
|
|
|
{
|
|
|
|
class SceneWidget;
|
|
|
|
}
|
|
|
|
|
2014-10-17 19:16:48 +00:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
|
|
|
class PhysicsSystem
|
|
|
|
{
|
2014-10-24 09:14:02 +00:00
|
|
|
static PhysicsSystem *mPhysicsSystemInstance;
|
2014-10-29 12:02:38 +00:00
|
|
|
std::map<std::string, std::string> mSceneNodeToRefId;
|
2014-10-30 21:18:15 +00:00
|
|
|
std::map<std::string, std::map<Ogre::SceneManager *, std::string> > mRefIdToSceneNode;
|
2014-10-28 21:13:13 +00:00
|
|
|
std::map<std::string, std::string> mSceneNodeToMesh;
|
2014-10-30 21:18:15 +00:00
|
|
|
std::list<Ogre::SceneManager *> mSceneManagers; // FIXME: change to list per OEngine
|
2014-10-31 10:50:57 +00:00
|
|
|
std::list<CSVRender::SceneWidget *> mSceneWidgets; // FIXME: change to list per OEngine
|
2014-10-17 19:16:48 +00:00
|
|
|
OEngine::Physic::PhysicEngine* mEngine;
|
2014-10-31 13:03:09 +00:00
|
|
|
std::multimap<std::string, Ogre::SceneManager *> mTerrain;
|
2014-10-26 19:50:51 +00:00
|
|
|
|
2014-10-17 19:16:48 +00:00
|
|
|
public:
|
|
|
|
|
2014-10-30 21:18:15 +00:00
|
|
|
PhysicsSystem();
|
2014-10-17 19:16:48 +00:00
|
|
|
~PhysicsSystem();
|
|
|
|
|
2014-10-24 09:14:02 +00:00
|
|
|
static PhysicsSystem *instance();
|
|
|
|
|
2014-10-31 10:50:57 +00:00
|
|
|
void addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * scene);
|
2014-10-24 09:14:02 +00:00
|
|
|
|
2014-10-28 21:13:13 +00:00
|
|
|
void addObject(const std::string &mesh,
|
|
|
|
const std::string &sceneNodeName, 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-29 12:02:38 +00:00
|
|
|
void removeObject(const std::string &sceneNodeName);
|
2014-10-23 04:35:01 +00:00
|
|
|
|
2014-10-29 12:02:38 +00:00
|
|
|
void moveObject(const std::string &sceneNodeName,
|
2014-10-28 21:13:13 +00:00
|
|
|
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation);
|
|
|
|
|
2014-10-31 13:03:09 +00:00
|
|
|
void addHeightField(Ogre::SceneManager *sceneManager,
|
|
|
|
float* heights, int x, int y, float yoffset, float triSize, float sqrtVerts);
|
2014-10-25 11:09:19 +00:00
|
|
|
|
2014-10-31 13:03:09 +00:00
|
|
|
void removeHeightField(Ogre::SceneManager *sceneManager, int x, int y);
|
2014-10-25 20:56:51 +00:00
|
|
|
|
2014-10-30 21:18:15 +00:00
|
|
|
void toggleDebugRendering(Ogre::SceneManager *sceneMgr);
|
2014-10-21 20:11:04 +00:00
|
|
|
|
2014-10-30 21:18:15 +00:00
|
|
|
// return the object's SceneNode name and position for the given SceneManager
|
2014-10-28 21:13:13 +00:00
|
|
|
std::pair<std::string, Ogre::Vector3> castRay(float mouseX,
|
2014-10-30 21:18:15 +00:00
|
|
|
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera);
|
2014-10-26 19:50:51 +00:00
|
|
|
|
2014-10-29 12:02:38 +00:00
|
|
|
std::string sceneNodeToRefId(std::string sceneNodeName);
|
2014-10-31 10:50:57 +00:00
|
|
|
|
2014-10-28 21:13:13 +00:00
|
|
|
std::string sceneNodeToMesh(std::string sceneNodeName);
|
2014-10-26 21:08:33 +00:00
|
|
|
|
2014-10-26 19:50:51 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
void updateSelectionHighlight(std::string sceneNode, const Ogre::Vector3 &position);
|
2014-10-30 21:18:15 +00:00
|
|
|
std::string refIdToSceneNode(std::string referenceId, Ogre::SceneManager *sceneMgr);
|
2014-10-17 19:16:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CSV_WORLD_PHYSICSSYSTEM_H
|