Permalink
Browse files

Merge branch 'master' of http://github.com/Phosfor/Pseudoform-2

  • Loading branch information...
max-frai committed Aug 29, 2010
2 parents 5ed83ee + ca6481f commit 532aa622fa3e56e8ee42314e987c4e795628bd84
View
@@ -53,12 +53,6 @@ class Utils : public singleton<Utils>
ptime getCurrentTime() const;
void writeTimestamp();
string getTimeDifference();
-
- string bool2string(bool var) { return(var ? "true" : "false"); }
- string vec2string(const vec3 &v) { return FORMAT("vec3(x=%1%;y=%2%;z=%3%)", v.x % v.y % v.z); }
- string vec2string(const vec2 &v) { return FORMAT("vec2(x=%1%;y=%2%)", v.x % v.y); }
- string quat2string(const quat &q) { return FORMAT("quat(w=%1%;x=%2%;y=%3%;z=%4%)", q.w % q.x % q.y % q.z); }
- string color2string(const colour &c) { return FORMAT("color(r=%1%;g=%2%;b=%3%;a=%4%)", c.r % c.g % c.b % c.a); }
};
#endif
@@ -35,11 +35,11 @@ class Camera : public Entity
Camera *loadFromFile(const string &filePath);
- void setCameraType(CameraType type);
- void setActive(bool state);
+ Camera *setCameraType(CameraType type);
+ Camera *setActive(bool state);
- void setMoveStep(float step);
- void setRotateStep(float step);
+ Camera *setMoveStep(float step);
+ Camera *setRotateStep(float step);
float getMoveStep();
float getRotateStep();
@@ -48,7 +48,7 @@ class Camera : public Entity
void onKeyPressed(const OIS::KeyEvent &e);
void onMouseMoved(const OIS::MouseEvent &e);
- void dump();
+ Camera *dump();
string type();
void update(float elapsed);
};
@@ -32,7 +32,7 @@ class Entity : private boost::noncopyable
virtual Entity *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
+ virtual Entity *dump() = 0; // Dumping type-related entity settings
public:
virtual ~Entity();
@@ -51,14 +51,14 @@ class Entity : private boost::noncopyable
const quat &getOrientation() const;
const vec3 &getScale() const;
- void setName(const string &entityName);
- void setMeshName(const string &meshPath);
- void setDrawable(bool state);
+ Entity *setName(const string &entityName);
+ Entity *setMeshName(const string &meshPath);
+ Entity *setDrawable(bool state);
- void setMaterial(const string &matName, const string &group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- void setPosition(const vec3 &pos = vec3());
- void setRotation(const quat &rot = quat());
- void setScale(const vec3 &scale = vec3());
+ Entity *setMaterial(const string &matName, const string &group = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ Entity *setPosition(const vec3 &pos = vec3());
+ Entity *setRotation(const quat &rot = quat());
+ Entity *setScale(const vec3 &scale = vec3());
};
@@ -21,17 +21,17 @@ class Light : public Entity
Ogre::Light *handle();
Light *loadFromFile(const string &filePath);
- void setDiffuse(const colour &diffuse);
- void setSpecular(const colour &specular);
- void setRadius(float value);
- void setPower(float value);
+ Light *setDiffuse(const colour &diffuse);
+ Light *setSpecular(const colour &specular);
+ Light *setRadius(float value);
+ Light *setPower(float value);
colour getDiffuse();
colour getSpecular();
float getRadius();
float getPower();
- void dump();
+ Light *dump();
string type();
void update(float elapsed);
};
@@ -15,11 +15,11 @@ class Object : public Entity
{
public:
Object(const string &entityName, const string &resGroup = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- void setImage(const string& imgPath);
+ Object *setImage(const string& imgPath);
// Inherited from Entity class
Object *loadFromFile(const string &filePath);
- void dump();
+ Object *dump();
string type();
void update(float elapsed);
};
@@ -33,14 +33,13 @@ class GameState : public State
{
public:
void init() {
- MakeCamera("MainCamera")->loadFromFile("Entities/MainCamera.info");
- MakeLight("DirectionalLight");
- MakeObject("ErrorObject")->loadFromFile("Entities/ErrorObject.info");
- MakeObject("TestLight")->loadFromFile("Entities/Light.info")->dump();
+ 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));
//GetCamera("MainCamera")->dump();
//GetObject("ErrorObject")->dump();
- GetObject("TestLight")->setPosition(vec3(0, 50, 0));
}
string type() { return "GameState"; }
@@ -56,39 +56,42 @@ Camera *Camera::loadFromFile(const string &filePath)
Ogre::Camera *Camera::handle() { return mCamera; }
Ogre::SceneNode *Camera::getPitchNode() { return mPitchNode; }
-void Camera::setActive(bool state)
+Camera *Camera::setActive(bool state)
{
// If false, set up base camera
if (state)
graphicSystem.getViewport()->setCamera(mCamera);
else
graphicSystem.getViewport()->setCamera(graphicSystem.getBaseCamera());
+
+ return this;
}
-void Camera::dump()
+Camera *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", "Auto aspect ratio" % mCamera->getAutoAspectRatio()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Active camera" % (graphicSystem.getViewport()->getCamera() == mCamera)));
LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Camera type" % mCamTypeStr));
+ return this;
}
float Camera::getMoveStep() { return mMove; }
float Camera::getRotateStep() { return mRotate; }
-void Camera::setMoveStep(float step) { mMove = step; }
-void Camera::setRotateStep(float step) { mRotate = step; }
+Camera *Camera::setMoveStep(float step) { mMove = step; return this; }
+Camera *Camera::setRotateStep(float step) { mRotate = step; return this; }
string Camera::type() { return "camera"; }
void Camera::update(float elapsed) { }
#define WIDTH graphicSystem.getWindow()->getWidth()
#define HEIGHT graphicSystem.getWindow()->getHeight()
-void Camera::setCameraType(CameraType type)
+Camera *Camera::setCameraType(CameraType type)
{
mCameraType = type;
@@ -99,6 +102,7 @@ void Camera::setCameraType(CameraType type)
CONNECT0(Engine::Events::GlobalUpdateEvent, "Updated", &Camera::onUpdated);
CONNECT0(Engine::Events::GlobalInitEvent, "Inited", &Camera::onInited);
}
+ return this;
}
void Camera::onInited()
@@ -48,34 +48,41 @@ const vec3 &Entity::getScale() const
// =============================================================================
// Setters
-void Entity::setName(const string &entityName)
+Entity *Entity::setName(const string &entityName)
{
mEntityName = entityName;
+ return this;
}
-void Entity::setMeshName(const string &meshPath)
+Entity *Entity::setMeshName(const string &meshPath)
{
mEntityMesh = meshPath;
+ return this;
}
-void Entity::setDrawable(bool state)
+Entity *Entity::setDrawable(bool state)
{
mDrawable = state;
+ return this;
}
-void Entity::setMaterial(const string &matName, const string &group)
+Entity *Entity::setMaterial(const string &matName, const string &group)
{
mEntity->setMaterialName(matName, group);
+ return this;
}
-void Entity::setPosition(const vec3 &pos)
+Entity *Entity::setPosition(const vec3 &pos)
{
mNode->setPosition(pos);
+ return this;
}
-void Entity::setRotation(const quat &rot)
+Entity *Entity::setRotation(const quat &rot)
{
mNode->setOrientation(rot);
+ return this;
}
-void Entity::setScale(const vec3 &scale)
+Entity *Entity::setScale(const vec3 &scale)
{
mNode->setScale(scale);
+ return this;
}
// =============================================================================
@@ -146,8 +153,8 @@ void Entity::defaultDump()
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())));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Visible" % isDrawable()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Position" % getPosition()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Orientation" % getOrientation()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Scale" % getScale()));
}
@@ -40,19 +40,25 @@ Light *Light::loadFromFile(const string &filePath)
return this;
}
-void Light::dump()
+Light *Light::dump()
{
defaultDump();
- // TODO: typeDump light
+ LOG_NOFORMAT("\t ---Type settings---\n");
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Diffuse" % mLight->getDiffuseColour()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Specular" % mLight->getSpecularColour()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Radius" % mLight->getAttenuationRange()));
+ LOG_NOFORMAT(FORMAT("\t%1%: %2%\n", "Power" % mLight->getPowerScale()));
+
+ return this;
}
Ogre::Light *Light::handle() { return mLight; }
// Setters
-void Light::setDiffuse(const colour &diffuse) { mLight->setDiffuseColour(diffuse); }
-void Light::setSpecular(const colour &specular) { mLight->setSpecularColour(specular); }
-void Light::setRadius(float value) { mLight->setAttenuation(value, 0, 0, 0); }
-void Light::setPower(float value) { mLight->setPowerScale(value); }
+Light *Light::setDiffuse(const colour &diffuse) { mLight->setDiffuseColour(diffuse); return this; }
+Light *Light::setSpecular(const colour &specular) { mLight->setSpecularColour(specular); return this; }
+Light *Light::setRadius(float value) { mLight->setAttenuation(value, 0, 0, 0); return this; }
+Light *Light::setPower(float value) { mLight->setPowerScale(value); return this; }
// Getters
colour Light::getDiffuse() { return mLight->getDiffuseColour(); }
@@ -35,17 +35,20 @@ Object *Object::loadFromFile(const string &filePath)
return this;
}
-void Object::dump()
+Object *Object::dump()
{
defaultDump();
+ return this;
}
-void Object::setImage(const string& imgPath)
+Object *Object::setImage(const string& imgPath)
{
Ogre::MaterialPtr textureMat = Ogre::MaterialManager::getSingleton().create("Material:" + mEntityName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
textureMat->getTechnique(0)->getPass(0)->createTextureUnitState(imgPath);
graphicSystem.getSceneMgr()->getEntity(mEntityName)->setMaterial(textureMat);
+
+ return this;
}
string Object::type() { return "object"; }

0 comments on commit 532aa62

Please sign in to comment.