Skip to content
Browse files

Tried to load Light from file; Now every entity has a debug mesh

  • Loading branch information...
1 parent ca6481f commit 07490055eb9579f9ece3c2cc61aaa0198832abb5 @Phosfor Phosfor committed Aug 29, 2010
View
BIN bin/media/Engine/Light.mesh
Binary file not shown.
View
16 bin/media/Entities/Light.info
@@ -1,16 +0,0 @@
-common_settigns
-{
- name Light
- type object
-
- position "0, 0, 0"
- orientation "Default"
- scale "1, 1, 1"
-
- visible true
-}
-
-type_settings
-{
- mesh "Light/Light.mesh"
-}
View
3 include/Managers/Entities/Entity.hpp
@@ -25,6 +25,7 @@ class Entity : private boost::noncopyable
// TODO: Move entity object to entity class only
Ogre::Entity *mEntity;
Ogre::SceneNode *mNode;
+ Ogre::Entity *mDebugEntity;
bool parseArguments(const string &argName, const string &argData, float *outData, vector<string> &storage);
@@ -59,6 +60,8 @@ class Entity : private boost::noncopyable
Entity *setPosition(const vec3 &pos = vec3());
Entity *setRotation(const quat &rot = quat());
Entity *setScale(const vec3 &scale = vec3());
+
+ Entity *showDebug(const bool show);
};
View
7 samples/pong-cpp/main.cpp
@@ -34,9 +34,10 @@ class GameState : public State
public:
void init() {
MakeCamera("MainCamera")->loadFromFile("Entities/MainCamera.info")->dump();
- MakeLight("DirectionalLight")->dump();
- MakeObject("ErrorObject")->loadFromFile("Entities/ErrorObject.info")->dump();
- MakeObject("TestLight")->loadFromFile("Entities/Light.info")->dump()->setPosition(vec3(0, 50, 0));
+ MakeLight("DirectionalLight")->loadFromFile("Entities/MainLight.info")->dump();
+ //MakeObject("ErrorObject")->loadFromFile("Entities/ErrorObject.info");//->dump();
+ MakeObject("Head")->loadFromFile("Entities/OgreHead.info")->dump();
+ MakeObject("TestLight")->loadFromFile("Entities/LightObject.info")->setPosition(vec3(0, 50, 0));//->dump();
//GetCamera("MainCamera")->dump();
//GetObject("ErrorObject")->dump();
View
14 src/Managers/Entities/Entity.cpp
@@ -85,6 +85,16 @@ Entity *Entity::setScale(const vec3 &scale)
return this;
}
+Entity *Entity::showDebug(const bool show)
+{
+ if(!mDebugEntity) return this;
+ if(show)
+ mNode->attachObject(mDebugEntity);
+ else
+ mNode->detachObject(mDebugEntity);
+ return this;
+}
+
// =============================================================================
// Settings loader
bool Entity::parseArguments(const string &argName, const string &argData, float *outData, vector<string> &storage)
@@ -124,8 +134,8 @@ ptree Entity::defaultLoader(const string &infoPath)
string argName;
vector<string> parseStorage;
- float storage[3];
- memset(storage, 0, sizeof(float)*3);
+ float storage[4];
+ memset(storage, 0, sizeof(float)*4);
// Position
argName = tree_handle.get<string>("common_settigns.position", "0, 0, 0");
View
22 src/Managers/Entities/Light.cpp
@@ -8,10 +8,11 @@ Light::Light(const string &entityName)
// TODO: Load not Error mesh in Light class (get some other mesh type)
mLight = graphicSystem.getSceneMgr()->createLight("Light:" + entityName);
- mEntity = graphicSystem.getSceneMgr()->createEntity("Error:" + entityName, CONFIG("resorces.ErrorMesh", string, "Engine/Error.mesh"));
+ mDebugEntity = graphicSystem.getSceneMgr()->createEntity("LightMesh:" + entityName, CONFIG("resorces.LightMesh", string, "Engine/Light.mesh"));
mNode = graphicSystem.getSceneMgr()->getRootSceneNode()->createChildSceneNode("Node:" + entityName);
- mNode->attachObject(mEntity);
+ showDebug(true);
+ mNode->attachObject(mLight);
}
Light *Light::loadFromFile(const string &filePath)
@@ -20,22 +21,21 @@ Light *Light::loadFromFile(const string &filePath)
string argName;
vector<string> parseStorage;
- float storage[3];
- memset(storage, 0, sizeof(float)*3);
+ float storage[4];
+ memset(storage, 0, sizeof(float)*4);
- argName = tree_handle.get<string>("type_settigns.diffuse", "1, 1, 1");
+ argName = tree_handle.get<string>("type_settings.diffuse", "1, 1, 1, 1");
if (parseArguments("diffuse", argName, storage, parseStorage))
- setDiffuse(colour(storage[0], storage[1], storage[2]));
+ setDiffuse(colour(storage[0], storage[1], storage[2], storage[3]));
- argName = tree_handle.get<string>("type_settigns.specular", "1, 1, 1");
+ argName = tree_handle.get<string>("type_settings.specular", "0, 0, 0, 1");
if (parseArguments("specular", argName, storage, parseStorage))
- setSpecular(colour(storage[0], storage[1], storage[2]));
+ setSpecular(colour(storage[0], storage[1], storage[2], storage[3]));
- setRadius(tree_handle.get<float>("type_settings.radius", 10));
+ setRadius(tree_handle.get<float>("type_settings.radius", 100000));
setPower(tree_handle.get<float>("type_settings.power", 1));
- mNode->detachObject(mEntity);
- mNode->attachObject(mLight);
+ showDebug(false);
return this;
}
View
1 src/Managers/Entities/Object.cpp
@@ -21,6 +21,7 @@ Object *Object::loadFromFile(const string &filePath)
// Detaching default node with real one
mNode->detachObject(mEntity);
+ graphicSystem.getSceneMgr()->destroyEntity(mEntity);
// Get the path for the real mesh
string meshLocation = tree_handle.get<string>("type_settings.mesh", CONFIG("resorces.ErrorMesh", string, "Engine/Error.mesh"));

0 comments on commit 0749005

Please sign in to comment.
Something went wrong with that request. Please try again.