#include "Aabb.hh"
#include "Camera.hh"
-#include "Cullable.hh"
#include "Deserializer.hh"
-#include "Drawable.hh"
+#include "Entity.hh"
#include "Math.hh"
#include "Mippleton.hh"
+#include "Octree.hh"
#include "OpenGL.hh"
#include "Scene.hh"
#include "Serializable.hh"
class Scene::SceneImpl : public Mippleton<SceneImpl>
{
- class Scenery : public Drawable, public Cullable
+ class Scenery : public Entity
{
public:
Scenery(const Matrix4& transform, const std::string& textureName) :
}
}
- void draw(Scalar alpha)
+ void draw(Scalar alpha) const
{
glPushMatrix();
//std::cout << "transforming..." << std::endl;
{
(*it).second->get(uScale);
}
+ if ((it = rootObj.find("fog")) != rootObj.end())
+ {
+ (*it).second->get(fog);
+ }
+ if ((it = rootObj.find("blend")) != rootObj.end())
+ {
+ (*it).second->get(blending);
+ }
}
image.getTileCoords(index, texCoords);
}
- void draw(Scalar alpha)
+ void draw(Scalar alpha) const
{
glPushMatrix();
glMultMatrix(transformation.data());
+ if (blending)
+ {
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ /*if (fog) glEnable(GL_FOG);*/
+
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
image.bind();
glEnd();
}
+ glDisable(GL_BLEND);
+ glDisable(GL_FOG);
+
glPopMatrix();
}
if (numbers[0]->getNumber(num))
{
-
+ theBox.min[0] = Scalar(num);
+ }
+ if (numbers[1]->getNumber(num))
+ {
+ theBox.min[1] = Scalar(num);
+ }
+ if (numbers[2]->getNumber(num))
+ {
+ theBox.min[2] = Scalar(num);
+ }
+ if (numbers[3]->getNumber(num))
+ {
+ theBox.max[0] = Scalar(num);
+ }
+ if (numbers[4]->getNumber(num))
+ {
+ theBox.max[1] = Scalar(num);
+ }
+ if (numbers[5]->getNumber(num))
+ {
+ theBox.max[2] = Scalar(num);
}
}
}
loadFromFile();
}
+ ~SceneImpl()
+ {
+ }
+
void loadInstructions(SerializablePtr root)
{
if (instruction == "reset_transform")
{
transform.identity();
- //std::cout << "===================RESET=====================" << std::endl;
}
else if (instruction == "translate")
{
Matrix4 translation;
cml::matrix_translation(translation, vec);
transform = translation * transform;
- //std::cout << "TRANSLATE\t" << vec << std::endl
- //<< transform << std::endl;
}
}
else if (instruction == "scale")
Matrix4 scaling;
cml::matrix_uniform_scale(scaling, Scalar(value));
transform = scaling * transform;
- //std::cout << "SCALE\t\t" << value << std::endl
- //<< transform << std::endl;
}
else if (values.size() == 3)
{
Matrix4 scaling;
cml::matrix_scale(scaling, vec);
transform = scaling * transform;
- //std::cout << "SCALE\t\t" << vec << std::endl
- //<< transform << std::endl;
}
}
}
std::string axis;
size_t axisIndex = 0;
double value = 0.0;
+ Vector3 vec(0.0, 0.0, 0.0);
if (values[0]->get(axis))
{
if (axis == "x")
{
axisIndex = 0;
+ vec[0] = 1.0;
}
else if (axis == "y")
{
axisIndex = 1;
+ vec[1] = 1.0;
}
else if (axis == "z")
{
axisIndex = 2;
+ vec[2] = 1.0;
}
values[1]->getNumber(value);
}
- cml::matrix_rotate_about_local_axis(transform,
+ cml::matrix_rotate_about_world_axis(transform,
axisIndex, Scalar(value * cml::constantsd::rad_per_deg()));
- //std::cout << "ROTATE\t" << axis << " " << value << std::endl
- //<< transform << std::endl;
}
}
}
}
else if (instruction == "tilemap")
{
- //std::cout << "TILEMAP\t" << texture<< std::endl;
- //std::cout << transform << std::endl;
-
it++;
TilePanel* tilePanel = new TilePanel(transform, texture,
*it);
}
else if (instruction == "billboard")
{
- //std::cout << "BILLBOARD\t" << texture << std::endl;
- //std::cout << transform << std::endl;
-
it++;
Billboard* billboard = new Billboard(transform, texture,
*it);
}
}
}
+
+ std::cout << "playfield: " << playfieldBounds.min << " ... " <<
+ playfieldBounds.max << std::endl;
}
//std::cout << "draw object";
(*it)->draw(alpha);
}
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
+ playfieldBounds.draw(0.0);
+
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
impl_(Scene::SceneImpl::retain(name), &Scene::SceneImpl::release) {}
-void Scene::draw(Scalar alpha)
+void Scene::draw(Scalar alpha) const
{
// pass through
impl_->draw(alpha);
}
+void Scene::refresh()
+{
+ impl_->objects.clear();
+ impl_->loadFromFile();
+}
+
/**
* Specialized search location for scene files. They can be found in the