Permalink
Browse files

Functions for dumping entities information. Finished: Camera, Object.…

… TODO: Light
  • Loading branch information...
1 parent bfd105d commit a550228bd72ebbf3a02d42009ca001ac25086f0e @max-frai max-frai committed Aug 29, 2010
View
@@ -29,9 +29,9 @@ engine
resources
{
- MediaFolder "pong-media/"
- MediaFolder1 "pong-media/Fonts"
- MediaFolder2 "pong-media/Materials"
- MediaFolder3 "pong-media/Entities"
- MyGUI "pong-media/MyGUI"
+ MediaFolder "media/"
+ MediaFolder1 "media/Fonts"
+ MediaFolder2 "media/Materials"
+ MediaFolder3 "media/Entities"
+ MyGUI "media/MyGUI"
}
@@ -14,6 +14,7 @@ class Camera : public Entity
protected:
Ogre::Camera *mCamera;
Ogre::SceneNode *mPitchNode;
+ string mCamTypeStr;
float mMove;
float mRotate;
@@ -47,6 +48,7 @@ class Camera : public Entity
void onKeyPressed(const OIS::KeyEvent &e);
void onMouseMoved(const OIS::MouseEvent &e);
+ void dump();
string type();
void update(float elapsed);
};
@@ -31,11 +31,15 @@ class Entity : private boost::noncopyable
ptree defaultLoader(const string &infoPath); // Predefined loading of common settings
virtual void loadFromFile(const string &filePath) = 0; // Loading entity type-derived settings
+ void defaultDump(); // Dumping default entity settings
+ virtual void dump() = 0; // Dumping type-related entity settings
+
public:
virtual ~Entity();
virtual void update(float elapsed) = 0;
virtual string type() = 0;
+ const string getResGroup() const;
const string getName() const;
const string getMeshName() const;
bool isDrawable() const;
@@ -31,6 +31,7 @@ class Light : public Entity
float getRadius();
float getPower();
+ void dump();
string type();
void update(float elapsed);
};
@@ -19,6 +19,7 @@ class Object : public Entity
// Inherited from Entity class
void loadFromFile(const string &filePath);
+ void dump();
string type();
void update(float elapsed);
};
@@ -36,6 +36,9 @@ class GameState : public State
MakeCamera("MainCamera")->loadFromFile("Entities/MainCamera.info");
MakeLight("DirectionalLight");
MakeObject("ErrorObject")->loadFromFile("Entities/ErrorObject.info");
+
+ GetCamera("MainCamera")->dump();
+ GetObject("ErrorObject")->dump();
}
string type() { return "GameState"; }
@@ -38,6 +38,7 @@ void Camera::loadFromFile(const string &filePath)
graphicSystem.getViewport()->setCamera(mCamera);
string type = tree_handle.get<string>("type_settings.camType", "DONT_USE");
+ mCamTypeStr = type;
if(type == "DONT_USE")
setCameraType(Camera::DONT_USE);
else if(type == "FREE")
@@ -61,6 +62,19 @@ void Camera::setActive(bool state)
else
graphicSystem.getViewport()->setCamera(graphicSystem.getBaseCamera());
}
+
+void Camera::dump()
+{
+ defaultDump();
+ LOG_NOFORMAT("\t ---Type settings---\n");
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "FOV" % mCamera->getFOVy()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Near clip distance" % mCamera->getNearClipDistance()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Far clip distance" % mCamera->getFarClipDistance()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Auto aspect ratio" % utils.bool2string(mCamera->getAutoAspectRatio())));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Active camera" % utils.bool2string(graphicSystem.getViewport()->getCamera() == mCamera)));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Camera type" % mCamTypeStr));
+}
+
float Camera::getMoveStep() { return mMove; }
float Camera::getRotateStep() { return mRotate; }
void Camera::setMoveStep(float step) { mMove = step; }
@@ -8,10 +8,17 @@ const string Entity::getName() const
{
return mEntityName;
}
+
+const string Entity::getResGroup() const
+{
+ return mResGroup;
+}
+
const string Entity::getMeshName() const
{
return mEntityMesh;
}
+
bool Entity::isDrawable() const
{
return mDrawable;
@@ -99,7 +106,7 @@ ptree Entity::defaultLoader(const string &infoPath)
{
if (!boost::filesystem::exists(utils.getMediaPath() + infoPath))
{
- LOG_META(FORMAT("The given location: `%1%` is invalid!", infoPath));
+ LOG_META(FORMAT("The given location: 1% is invalid!", infoPath));
return ptree();
}
@@ -135,3 +142,15 @@ ptree Entity::defaultLoader(const string &infoPath)
return tree_handle;
}
+
+void Entity::defaultDump()
+{
+ LOG(FORMAT("Dumping %1% entity settings of type %2%:", mEntityName % type()));
+ LOG_NOFORMAT("\t ---Common settings---\n");
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Resource group" % mResGroup));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Entity mesh" % mEntityMesh));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Visible" % utils.bool2string(isDrawable())));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Position" % utils.vec2string(getPosition())));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Orientation" % utils.quat2string(getOrientation())));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Scale" % utils.vec2string(getScale())));
+}
@@ -38,6 +38,12 @@ void Light::loadFromFile(const string &filePath)
mNode->attachObject(mLight);
}
+void Light::dump()
+{
+ defaultDump();
+ // TODO: typeDump light
+}
+
Ogre::Light *Light::handle() { return mLight; }
// Setters
@@ -33,6 +33,11 @@ void Object::loadFromFile(const string &filePath)
mNode->attachObject(mEntity);
}
+void Object::dump()
+{
+ defaultDump();
+}
+
void Object::setImage(const string& imgPath)
{
Ogre::MaterialPtr textureMat = Ogre::MaterialManager::getSingleton().create("Material:" + mEntityName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);

0 comments on commit a550228

Please sign in to comment.