Mf::Scalar s = 16.0;
- glBegin(GL_QUADS);
+ glBegin(GL_TRIANGLE_FAN);
glTexCoord2f(coords[0], coords[1]);
glVertex3(state.position[0]-s, state.position[1]-s, z);
glTexCoord2f(coords[2], coords[3]);
entity->getAabb().max[2] < node->getAabb().max[2] &&
entity->getAabb().min[2] > node->getAabb().min[2]))
{
+ // TODO this check is only needed for the root node, if we're inside the
+ // volume of the root node, we'll be fully inside the child as
+ // determined by trying to insert the parent node
goto done;
}
#include <Moof/Aabb.hh>
#include <Moof/Drawable.hh>
#include <Moof/Entity.hh>
+#include <Moof/Log.hh>
#include <Moof/Math.hh>
#include <Moof/Sphere.hh>
public:
+ inline void print(OctreeNodeP node)
+ {
+ logDebug("-----");
+ logDebug("depth to node: %d", tree_.depth(node));
+ logDebug("size of node: %d", tree_.size(node));
+ }
+
inline static OctreeP alloc(const OctreeNode& rootNode)
{
return OctreeP(new Octree(rootNode));
*******************************************************************************/
-#include <iostream>
#include <map>
#include <vector>
#include "Camera.hh"
#include "Deserializer.hh"
#include "Entity.hh"
+#include "Log.hh"
#include "Math.hh"
#include "Mippleton.hh"
#include "OpenGL.hh"
if (!tilemap_.getTileCoords(tileIndex, texCoords_))
{
- std::cerr << "no coords for tile's texture" << std::endl;
+ logWarning("no index %d in texture %s", tileIndex,
+ texture.c_str());
+
+ texCoords_[0] = texCoords_[1] =
+ texCoords_[3] = texCoords_[6] = 0.0;
+ texCoords_[2] = texCoords_[4] =
+ texCoords_[5] = texCoords_[7] = 1.0;
}
aabb_.encloseVertices(vertices, 4);
if (!root->get(rootObj))
{
- std::cerr << "error loading scene instructions" << std::endl;
+ logError("scene instructions must be an array");
return;
}
if (!root->get(rootObj))
{
- std::cerr << "error loading scene tilemap object" << std::endl;
+ logError("invalid tilemap instruction");
return;
}
}
else
{
- std::cerr << "width is a required field of a tilemap" << std::endl;
+ logError("missing required field width for tilemap instruction");
return;
}
}
else
{
- std::cerr << "error loading tiles from tilemap object" << std::endl;
+ logError("invalid tiles in tilemap instruction");
return;
}
if (!root || !root->get(rootObj))
{
- std::cerr << "error loading scene file" << std::endl;
+ logError("no root map in scene file");
return;
}
}
else
{
- std::cerr << "maximum bounds required in scene" << std::endl;
+ logError("missing required maximum bounds");
return;
}
loadInstructions((*it).second);
}
+
+
octree->sort();
}
Mf::Scalar coeff[2] = {1.0, 0.0};
fadeIn.init(coeff, 0.1);
- testScene = new Mf::Scene("Test");
+ testScene = Mf::Scene::alloc("Test");
heroine->treeNode = testScene->getOctree()->insert(heroine);
}
{
//delete heroine;
delete font;
- delete testScene;
Mf::dispatcher::removeHandler(this);
}
heroine->update(t, dt);
heroine->treeNode = testScene->getOctree()->reinsert(heroine, heroine->treeNode);
+ testScene->getOctree()->print(heroine->treeNode);
//camera.lookAt(heroine->getSphere().point);
camera.setPosition(Mf::Vector3(-heroine->current.position[0], -heroine->current.position[1], -256));
Mf::Lerps fadeIn;
Mf::Camera camera;
- Mf::Scene* testScene;
+ Mf::SceneP testScene;
Mf::Scalar state;
Mf::Scalar prevstate;