Ignore:
Timestamp:
10/03/06 17:31:07 (18 years ago)
Author:
gumbau
Message:

Added F1 key functionality

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Geom/Demo_LodTrees/main.cpp

    r1540 r1561  
    1919// Distance values 
    2020#define dist_min 300 
    21 #define dist_max 700 
     21#define dist_max 900 
    2222 
    2323// Model name 
     
    4141OverlayElement* mInfo; 
    4242OverlayElement* mInfo2; 
     43OverlayElement* mHelp; 
     44 
     45char HelpString[]="(F1) Help\n" 
     46                        "This demo shows an example of the LodTree model in action. The trees in the scene\n" 
     47                        "are associated to a LodTree object that manage their level of detail of both the\n" 
     48                        "trunk and the leaves. The level of detail of the objects depend on the distance to\n" 
     49                        "the camera. When the camera goes away from them, the level of detail decreases, and\n" 
     50                        "when the camera gets closer to them the level of detail increases to restore the\n" 
     51                        "original geometry of the model.\n" 
     52                        "The current level of detail can be seen in real-time in the top-left corner of the screen.\n" 
     53                        "The level of detail begins to decrease at a certain distance of the forest, and stops\n" 
     54                        "decreasing when the objects reach the their minimum LOD. This 'lodding' distance is\n" 
     55                        "customizable from the source code of the demo."; 
     56 
     57char NoHelpString[]="(F1) Help\n"; 
    4358 
    4459 
     
    107122 
    108123                static float lodfactorBefore = -1.0f; 
    109                 if (fabsf(lodfactorBefore-lodfactor)>0.05f) 
     124                if (fabsf(lodfactorBefore-lodfactor)>0.1f) 
    110125                { 
    111126                        myTrees->GoToLod(lodfactor); 
     
    141156                if(mInputDevice->isKeyDown(Ogre::KC_RIGHT)) 
    142157                  mCamera->yaw(-mRotScale); 
     158 
     159                static bool newpush = true; 
     160                if (!mInputDevice->isKeyDown(Ogre::KC_F1)) 
     161                        newpush = true; 
     162 
     163                static bool showing_help = false; 
     164                if (mInputDevice->isKeyDown(Ogre::KC_F1) && newpush) 
     165                { 
     166                        newpush = false; 
     167                        if (showing_help = !showing_help) 
     168                mHelp->setCaption(HelpString); 
     169                        else 
     170                mHelp->setCaption(NoHelpString); 
     171                } 
     172 
    143173 
    144174                if(mInputDevice->isKeyDown(Ogre::KC_ESCAPE)) 
     
    230260        // Set ambient light 
    231261        mSceneMgr->setAmbientLight(ColourValue(0.4, 0.4, 0.4)); 
     262                theCam->setNearClipDistance(0.1f); 
    232263 
    233264        // Create a directional light 
     
    260291 
    261292                //Models 
    262         entity = mSceneMgr->createEntity(model_name, "../../../OgreStuff/media/GT/ML12m.mesh"); 
     293        entity = mSceneMgr->createEntity(model_name, "../../../OgreStuff/media/GT/ML11.mesh"); 
    263294 
    264295                ogreMesh = entity->getMesh().getPointer(); 
     
    266297                // load LOD info from the object 
    267298                meshloader=new Geometry::GeoMeshLoader; 
    268                 Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/ML12m.mesh"); 
     299                Geometry::Mesh *themesh = meshloader->load("../../../OgreStuff/media/GT/ML11.mesh"); 
    269300 
    270301                if (!meshloader->GetLodStripsData()) 
     
    284315                        bool istrunk = myTrees->GetLeavesSubMesh()!=submesh; 
    285316                        if (istrunk) 
    286                                 entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/trunk"); 
     317                                entity->getSubEntity(submesh)->setMaterialName("Examples/ML11/trunk"); 
    287318                        else 
    288                                 entity->getSubEntity(submesh)->setMaterialName("Examples/Populifolia/leaf"); 
     319                                entity->getSubEntity(submesh)->setMaterialName("Examples/ML11/leaf"); 
    289320                } 
    290321 
    291322                forest_center=Ogre::Vector3(150.0f,0.0f,0.0f); 
    292                 for (int i=1; i<8; i++) // 20 
    293                         for (int j=1; j<8; j++) // 20 
     323                for (int i=1; i<5; i++) // 20 
     324                        for (int j=1; j<5; j++) // 20 
    294325                        { 
    295326                                char newTreeName[16]=""; 
     
    301332                                auxnode->rotate(Ogre::Vector3(0,0,1),Ogre::Degree(rand()%360)); 
    302333                                auxnode->rotate(Ogre::Vector3(1,0,0),Ogre::Radian(-3.14159f*0.5f),Ogre::Node::TS_WORLD); 
    303                                 float randomsepx = (float)((rand()%18)-9); 
    304                                 float randomsepy = (float)((rand()%12)-6); 
    305                                 auxnode->translate(i*30.0f+randomsepx,0.0f,-j*30.0f-randomsepx); 
     334                                float randomsepx = (float)((rand()%38)-19); 
     335                                float randomsepy = (float)((rand()%32)-12); 
     336                                auxnode->translate(i*80.0f+randomsepx,0.0f,-j*80.0f-randomsepx); 
    306337                                auxent->setNormaliseNormals(true); 
    307338                        } 
     
    315346        mInfo = OverlayManager::getSingleton().getOverlayElement("Demo_LodStrips/Info_1"); 
    316347                mInfo2 = OverlayManager::getSingleton().getOverlayElement("Demo_LodStrips/Info_2"); 
     348                mHelp = OverlayManager::getSingleton().getOverlayElement("Demo_LodStrips/Help"); 
     349                mHelp->setCaption(NoHelpString); 
    317350            pOver->show(); 
    318351 
Note: See TracChangeset for help on using the changeset viewer.