2014-10-18 06:16:48 +11:00
|
|
|
#ifndef CSV_WORLD_PHYSICSSYSTEM_H
|
|
|
|
#define CSV_WORLD_PHYSICSSYSTEM_H
|
|
|
|
|
2014-10-23 18:51:31 +11:00
|
|
|
#include <string>
|
2014-10-18 06:16:48 +11:00
|
|
|
#include <map>
|
|
|
|
|
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class Vector3;
|
|
|
|
class Quaternion;
|
|
|
|
class SceneManager;
|
2014-10-22 07:11:04 +11:00
|
|
|
class Camera;
|
2014-10-18 06:16:48 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace OEngine
|
|
|
|
{
|
|
|
|
namespace Physic
|
|
|
|
{
|
|
|
|
class PhysicEngine;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-31 21:50:57 +11:00
|
|
|
namespace CSVRender
|
|
|
|
{
|
|
|
|
class SceneWidget;
|
|
|
|
}
|
|
|
|
|
2014-10-18 06:16:48 +11:00
|
|
|
namespace CSVWorld
|
|
|
|
{
|
|
|
|
class PhysicsSystem
|
|
|
|
{
|
2014-10-29 23:02:38 +11:00
|
|
|
std::map<std::string, std::string> mSceneNodeToRefId;
|
2014-10-31 08:18:15 +11:00
|
|
|
std::map<std::string, std::map<Ogre::SceneManager *, std::string> > mRefIdToSceneNode;
|
2014-10-29 08:13:13 +11:00
|
|
|
std::map<std::string, std::string> mSceneNodeToMesh;
|
2014-11-01 08:29:08 +11:00
|
|
|
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> mSceneWidgets;
|
2014-10-18 06:16:48 +11:00
|
|
|
OEngine::Physic::PhysicEngine* mEngine;
|
2014-11-01 00:03:09 +11:00
|
|
|
std::multimap<std::string, Ogre::SceneManager *> mTerrain;
|
2014-10-27 06:50:51 +11:00
|
|
|
|
2014-10-18 06:16:48 +11:00
|
|
|
public:
|
|
|
|
|
2014-10-31 08:18:15 +11:00
|
|
|
PhysicsSystem();
|
2014-10-18 06:16:48 +11:00
|
|
|
~PhysicsSystem();
|
2014-11-01 20:51:04 +11:00
|
|
|
|
2014-11-01 08:29:08 +11:00
|
|
|
void addSceneManager(Ogre::SceneManager *sceneMgr, CSVRender::SceneWidget * scene);
|
2014-11-01 20:51:04 +11:00
|
|
|
|
2014-11-01 07:29:16 +11:00
|
|
|
void removeSceneManager(Ogre::SceneManager *sceneMgr);
|
2014-10-24 19:14:02 +10:00
|
|
|
|
2014-10-29 08:13:13 +11: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-18 06:16:48 +11:00
|
|
|
|
2014-11-02 15:34:45 +11:00
|
|
|
void removeObject(const std::string &sceneNodeName);
|
2014-11-03 08:10:28 +11:00
|
|
|
void removePhysicsObject(const std::string &sceneNodeName);
|
2014-11-01 07:29:16 +11:00
|
|
|
|
2014-11-01 20:51:04 +11:00
|
|
|
void replaceObject(const std::string &sceneNodeName,
|
2014-11-02 15:34:45 +11:00
|
|
|
float scale, const Ogre::Vector3 &position,
|
2014-11-01 20:51:04 +11:00
|
|
|
const Ogre::Quaternion &rotation, bool placeable=false);
|
2014-10-23 15:35:01 +11:00
|
|
|
|
2014-10-29 23:02:38 +11:00
|
|
|
void moveObject(const std::string &sceneNodeName,
|
2014-10-29 08:13:13 +11:00
|
|
|
const Ogre::Vector3 &position, const Ogre::Quaternion &rotation);
|
|
|
|
|
2014-11-01 07:39:58 +11:00
|
|
|
void moveSceneNodes(const std::string sceneNodeName, const Ogre::Vector3 &position);
|
|
|
|
|
2014-11-01 00:03:09 +11:00
|
|
|
void addHeightField(Ogre::SceneManager *sceneManager,
|
|
|
|
float* heights, int x, int y, float yoffset, float triSize, float sqrtVerts);
|
2014-10-25 22:09:19 +11:00
|
|
|
|
2014-11-01 00:03:09 +11:00
|
|
|
void removeHeightField(Ogre::SceneManager *sceneManager, int x, int y);
|
2014-10-26 07:56:51 +11:00
|
|
|
|
2014-10-31 08:18:15 +11:00
|
|
|
void toggleDebugRendering(Ogre::SceneManager *sceneMgr);
|
2014-10-22 07:11:04 +11:00
|
|
|
|
2014-10-31 08:18:15 +11:00
|
|
|
// return the object's SceneNode name and position for the given SceneManager
|
2014-10-29 08:13:13 +11:00
|
|
|
std::pair<std::string, Ogre::Vector3> castRay(float mouseX,
|
2014-10-31 08:18:15 +11:00
|
|
|
float mouseY, Ogre::SceneManager *sceneMgr, Ogre::Camera *camera);
|
2014-10-27 06:50:51 +11:00
|
|
|
|
2014-10-29 23:02:38 +11:00
|
|
|
std::string sceneNodeToRefId(std::string sceneNodeName);
|
2014-10-31 21:50:57 +11:00
|
|
|
|
2014-11-01 20:51:04 +11:00
|
|
|
// for multi-scene manager per physics engine
|
2014-11-01 08:29:08 +11:00
|
|
|
std::map<Ogre::SceneManager*, CSVRender::SceneWidget *> sceneWidgets();
|
|
|
|
|
2014-10-27 06:50:51 +11:00
|
|
|
private:
|
|
|
|
|
2014-11-01 07:39:58 +11:00
|
|
|
void moveSceneNodeImpl(const std::string sceneNodeName,
|
|
|
|
const std::string referenceId, const Ogre::Vector3 &position);
|
|
|
|
|
2014-10-27 06:50:51 +11:00
|
|
|
void updateSelectionHighlight(std::string sceneNode, const Ogre::Vector3 &position);
|
2014-11-01 20:51:04 +11:00
|
|
|
|
2014-10-31 08:18:15 +11:00
|
|
|
std::string refIdToSceneNode(std::string referenceId, Ogre::SceneManager *sceneMgr);
|
2014-11-02 18:13:25 +11:00
|
|
|
|
|
|
|
Ogre::SceneManager *findSceneManager(std::string sceneNodeName);
|
2014-10-18 06:16:48 +11:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CSV_WORLD_PHYSICSSYSTEM_H
|