Ignore:
Timestamp:
07/08/05 01:53:01 (19 years ago)
Author:
mattausch
Message:

added animation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r159 r160  
    1515#include <windows.h> 
    1616 
    17 /*******************************************************/ 
    18 /*     TestCullingTerrainApplication implementation    */ 
    19 /*******************************************************/ 
     17String currentObjectCaptions[] = 
     18{ 
     19        "robot", 
     20        "athene", 
     21        "ninja" 
     22        //"ogrehead" 
     23}; 
     24 
     25/*********************************************************/ 
     26/*      TestCullingTerrainApplication implementation     */ 
     27/*********************************************************/ 
     28 
     29 
    2030TestCullingTerrainApplication::TestCullingTerrainApplication(): 
    2131mTerrainContentGenerator(NULL) 
     
    3040                mTerrainContentGenerator = NULL; 
    3141        } 
    32         //if(mRenderTargetListener)     delete mRenderTargetListener; 
    3342} 
    3443//----------------------------------------------------------------------- 
     
    127136        setupGui(); 
    128137 
    129          
    130138        /* // occluder plane to test visibility 
    131         Plane plane; 
    132         plane.normal = Vector3::UNIT_Y; 
    133         plane.d = -60; 
     139        Plane plane; plane.normal = Vector3::UNIT_Y;    plane.d = -60; 
    134140        MeshManager::getSingleton().createPlane("Myplane", 
    135141                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 
     
    152158        mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 
    153159         
    154         // if no objects file generate yourself 
     160        // if no objects in file, we generate new objects 
    155161        if (!mTerrainContentGenerator->LoadObjects("objects.out")) 
    156162        { 
    157163                // to provide much occlusion, 
    158                 // height is restricted to 50, so no objects appear on peaks 
     164                // height is restricted to 50 => no objects appear on peaks 
    159165                mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 50.0f, 3000.0f)); 
    160166                mTerrainContentGenerator->SetOffset(0); 
    161167 
    162                 // the objects are generated on the whole terrain 
    163                 //mTerrainContentGenerator->GenerateScene(1500, "robot"); 
    164                 mTerrainContentGenerator->GenerateScene(1500, "athene"); 
    165                 //mTerrainContentGenerator->GenerateScene(500, "ninja"); 
     168                // the objects are generated randomly distributed over the terrain 
     169                generateScene(1500, 0); 
    166170        } 
    167171 
     
    169173        // objects also on peaks of terrain 
    170174        mTerrainContentGenerator->SetMaxPos(Vector3(3000.0f, 5000.0f, 3000.0f)); 
     175} 
     176//----------------------------------------------------------------------- 
     177void  TestCullingTerrainApplication::generateScene(int num, int objectType) 
     178{ 
     179        mTerrainContentGenerator->GenerateScene(num, currentObjectCaptions[objectType]); 
     180 
     181        if (objectType != 0) // from our objects, only robot has animation phases 
     182                return; 
     183 
     184        EntityList *entList = mTerrainContentGenerator->GetGeneratedEntities(); 
     185 
     186        //-- add animation state for new robots (located at the end of the list) 
     187        for (int i = entList->size() - num; i < entList->size(); ++i) 
     188        { 
     189                Entity *ent = (*entList)[i]; 
     190                AnimationState *st = ent->getAnimationState("Idle"); 
     191                st->setEnabled(true); 
     192                st->setLoop(true); 
     193 
     194                mAnimationStates.push_back(st); 
     195                mAnimationSpeed.push_back(Math::RangeRandom(0.5, 1.5)); 
     196        } 
     197} 
     198//----------------------------------------------------------------------- 
     199std::vector<AnimationState *> &TestCullingTerrainApplication::getAnimationStates() 
     200{ 
     201        return mAnimationStates; 
     202} 
     203//----------------------------------------------------------------------- 
     204std::vector<Real> &TestCullingTerrainApplication::getAnimationSpeed() 
     205{ 
     206        return mAnimationSpeed; 
    171207} 
    172208//----------------------------------------------------------------------- 
     
    189225{ 
    190226        mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr,  
    191                 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight); 
     227                mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight, this); 
    192228         
    193229        mRoot->addFrameListener(mTerrainFrameListener); 
    194230} 
    195231//----------------------------------------------------------------------- 
     232String TestCullingTerrainApplication::getCurrentObjectCaption(int id) 
     233{ 
     234        return currentObjectCaptions[id]; 
     235} 
     236//----------------------------------------------------------------------- 
    196237void TestCullingTerrainApplication::chooseSceneManager() 
    197238{ 
    198239        mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE); 
    199240} 
    200  
    201  
    202241/**************************************************************/ 
    203242/*      VisualizationRenderTargetListener implementation      */ 
Note: See TracChangeset for help on using the changeset viewer.