2009-05-15 07:04:50 +00:00
|
|
|
class TerrainFrameListener : public FrameListener
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Updates the quad tree
|
|
|
|
*/
|
|
|
|
bool frameEnded(const FrameEvent& evt)
|
|
|
|
{
|
2009-05-16 18:47:49 +00:00
|
|
|
g_heightMap->update(evt.timeSinceLastFrame);
|
2009-05-15 07:04:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
// Add the frame listener
|
|
|
|
mRoot->addFrameListener(this);
|
|
|
|
|
2009-05-16 18:47:49 +00:00
|
|
|
// Create a root scene node first
|
|
|
|
Ogre::SceneNode *node = mSceneMgr->getRootSceneNode()
|
|
|
|
->createChildSceneNode("TERRAIN_ROOT");
|
2009-05-15 07:04:50 +00:00
|
|
|
|
2009-05-16 18:47:49 +00:00
|
|
|
// The main terrain object
|
|
|
|
g_heightMap = new HeightMap(node);
|
|
|
|
g_heightMap->load(TERRAIN_OUTPUT);
|
2009-05-15 07:04:50 +00:00
|
|
|
|
|
|
|
//fix settings
|
2009-05-16 18:47:49 +00:00
|
|
|
g_heightMap->setMorphingEnabled(false);
|
|
|
|
g_heightMap->setTextureFadingEnabled(false);
|
2009-05-15 07:04:50 +00:00
|
|
|
|
|
|
|
//create the quad node
|
2009-05-16 18:47:49 +00:00
|
|
|
g_heightMap->create();
|
2009-05-15 07:04:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* KILLME
|
|
|
|
void drawLine(std::string name, Ogre::Vector3 start, Ogre::Vector3 end)
|
|
|
|
{
|
|
|
|
Ogre::ManualObject* mo = mSceneMgr->createManualObject( name);
|
|
|
|
Ogre::SceneNode* node = mSceneMgr->getRootSceneNode()->createChildSceneNode( name+"node");
|
|
|
|
|
|
|
|
Ogre::MaterialPtr mat = Ogre::MaterialManager::getSingleton().create( name+"Material","debugger");
|
|
|
|
mat->setReceiveShadows(false);
|
|
|
|
mat->getTechnique(0)->setLightingEnabled(true);
|
|
|
|
mat->getTechnique(0)->getPass(0)->setDiffuse(0,0,1,0);
|
|
|
|
mat->getTechnique(0)->getPass(0)->setAmbient(0,0,1);
|
|
|
|
mat->getTechnique(0)->getPass(0)->setSelfIllumination(0,0,1);
|
|
|
|
|
|
|
|
mo->begin(name+"Material", Ogre::RenderOperation::OT_LINE_LIST);
|
|
|
|
mo->position(start);
|
|
|
|
mo->position(end);
|
|
|
|
mo->end();
|
|
|
|
node->attachObject(mo);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
};
|