X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fyoink;a=blobdiff_plain;f=src%2FMoof%2FScene.cc;h=b8cb23388c24b3ea8c41665bda818566eb504ce6;hp=5f4a440c4ce0d06655afe62ed06de1b9b1d456db;hb=29e3d45f7bbbf31eadf793c41ff2b3d9c47b7539;hpb=16d1a05b0777e97a45c48e2874aa4e5cc791282e diff --git a/src/Moof/Scene.cc b/src/Moof/Scene.cc index 5f4a440..b8cb233 100644 --- a/src/Moof/Scene.cc +++ b/src/Moof/Scene.cc @@ -32,11 +32,11 @@ #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" @@ -48,7 +48,7 @@ namespace Mf { class Scene::SceneImpl : public Mippleton { - class Scenery : public Drawable, public Cullable + class Scenery : public Entity { public: Scenery(const Matrix4& transform, const std::string& textureName) : @@ -118,7 +118,7 @@ class Scene::SceneImpl : public Mippleton } } - void draw(Scalar alpha) + void draw(Scalar alpha) const { glPushMatrix(); //std::cout << "transforming..." << std::endl; @@ -195,16 +195,31 @@ class Scene::SceneImpl : public Mippleton { (*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(); @@ -226,6 +241,9 @@ class Scene::SceneImpl : public Mippleton glEnd(); } + glDisable(GL_BLEND); + glDisable(GL_FOG); + glPopMatrix(); } @@ -253,7 +271,27 @@ class Scene::SceneImpl : public Mippleton 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); } } } @@ -268,6 +306,10 @@ public: loadFromFile(); } + ~SceneImpl() + { + } + void loadInstructions(SerializablePtr root) { @@ -289,7 +331,6 @@ public: if (instruction == "reset_transform") { transform.identity(); - //std::cout << "===================RESET=====================" << std::endl; } else if (instruction == "translate") { @@ -313,8 +354,6 @@ public: Matrix4 translation; cml::matrix_translation(translation, vec); transform = translation * transform; - //std::cout << "TRANSLATE\t" << vec << std::endl - //<< transform << std::endl; } } else if (instruction == "scale") @@ -333,8 +372,6 @@ public: 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) { @@ -353,8 +390,6 @@ public: Matrix4 scaling; cml::matrix_scale(scaling, vec); transform = scaling * transform; - //std::cout << "SCALE\t\t" << vec << std::endl - //<< transform << std::endl; } } } @@ -370,28 +405,30 @@ public: 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; } } } @@ -402,9 +439,6 @@ public: } else if (instruction == "tilemap") { - //std::cout << "TILEMAP\t" << texture<< std::endl; - //std::cout << transform << std::endl; - it++; TilePanel* tilePanel = new TilePanel(transform, texture, *it); @@ -413,9 +447,6 @@ public: } else if (instruction == "billboard") { - //std::cout << "BILLBOARD\t" << texture << std::endl; - //std::cout << transform << std::endl; - it++; Billboard* billboard = new Billboard(transform, texture, *it); @@ -458,6 +489,9 @@ public: } } } + + std::cout << "playfield: " << playfieldBounds.min << " ... " << + playfieldBounds.max << std::endl; } @@ -470,6 +504,14 @@ public: //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); } @@ -486,12 +528,18 @@ Scene::Scene(const std::string& name) : 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