Changeset 1540


Ignore:
Timestamp:
09/29/06 11:02:43 (18 years ago)
Author:
gumbau
Message:

Demo updated with the new version of the programming interface.

Location:
GTP/trunk/App/Demos/Geom/Demo_LodTrees
Files:
29 added
2 edited

Legend:

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

    r1529 r1540  
    4343 
    4444 
    45 /*void DumpDataToOgreBuffers(Ogre::Mesh *original_mesh, Geometry::LodTreeLibrary *lodTreesLib) 
    46 { 
    47         // Copy to Ogre buffers including the degenerated triangles 
    48         Ogre::HardwareIndexBufferSharedPtr      ibuf; 
    49         Ogre::IndexData *indexes; 
    50         Ogre::RenderOperation mRenderOp; 
    51  
    52         for (int submesh=0; submesh < original_mesh->getNumSubMeshes(); submesh++) 
    53         { 
    54                 bool istrunk = lodTreesLib->GetLeavesSubMesh()!=submesh; 
    55                 original_mesh->getSubMesh(submesh)->_getRenderOperation(mRenderOp,0); 
    56  
    57                 // we will suppose this submesh is the foliage 
    58                 int indices_to_render = lodTreesLib->CurrentLOD_Foliage_IndexCount();            
    59                 int offset = 0; 
    60  
    61                 if (istrunk) 
    62                 { 
    63                         // this submesh is the trunk 
    64                         offset = lodTreesLib->GetValidTrunkOffset(submesh); 
    65                         indices_to_render = lodTreesLib->GetValidTrunkIndexCount(submesh); 
    66                 } 
    67  
    68                 ibuf = mRenderOp.indexData->indexBuffer; 
    69                 mRenderOp.indexData->indexStart = 0; 
    70                 mRenderOp.indexData->indexCount = indices_to_render;             
    71  
    72                 unsigned long* pIdx = static_cast<unsigned long*>(ibuf->lock(Ogre::HardwareBuffer::HBL_NORMAL)); 
    73  
    74                 for (int k=0; k<indices_to_render; k++) 
    75                         if (istrunk) 
    76                                 pIdx[k] = lodTreesLib->CurrentLOD_Trunk_Indices()->GetIndex(k+offset); 
    77                         else 
    78                                 pIdx[k] = lodTreesLib->CurrentLOD_Foliage_Indices()->GetIndex(k); 
    79  
    80                          
    81                 ibuf->unlock(); 
    82         } 
    83 }*/ 
    84  
    85 class FresnelFrameListener : public ExampleFrameListener 
     45 
     46class LodTreeFrameListener : public ExampleFrameListener 
    8647{ 
    8748        int manage; 
     
    8950public: 
    9051 
    91     FresnelFrameListener(RenderWindow* win, Camera* cam) 
     52    LodTreeFrameListener(RenderWindow* win, Camera* cam) 
    9253        : ExampleFrameListener(win, cam, false, false) 
    9354    { 
     
    153114                } 
    154115 
    155                 // Move the node 
    156                 if(mInputDevice->isKeyDown(Ogre::KC_UP)) 
     116                // Move the cam 
     117                if(mInputDevice->isKeyDown(Ogre::KC_UP) || 
     118                   mInputDevice->isKeyDown(Ogre::KC_W) || 
     119                   mInputDevice->isKeyDown(Ogre::KC_NUMPAD5)) 
    157120                  mTranslateVector.z = -mMoveScale; 
    158121 
    159  
    160                 if(mInputDevice->isKeyDown(Ogre::KC_DOWN)) 
     122                if(mInputDevice->isKeyDown(Ogre::KC_DOWN) || 
     123                   mInputDevice->isKeyDown(Ogre::KC_S) || 
     124                   mInputDevice->isKeyDown(Ogre::KC_NUMPAD2)) 
    161125                  mTranslateVector.z = mMoveScale; 
     126 
     127                if (mInputDevice->isKeyDown(Ogre::KC_A) || 
     128                        mInputDevice->isKeyDown(Ogre::KC_NUMPAD1)) 
     129                        mTranslateVector.x = -mMoveScale; 
     130 
     131                if (mInputDevice->isKeyDown(Ogre::KC_D) || 
     132                        mInputDevice->isKeyDown(Ogre::KC_NUMPAD3)) 
     133                        mTranslateVector.x = mMoveScale; 
    162134 
    163135                // Instead of moving the ship left and right, rotate it using yaw() 
     
    238210 
    239211 
    240 class FresnelApplication : public ExampleApplication 
     212class LodTreeApplication : public ExampleApplication 
    241213{ 
    242214protected: 
    243215public: 
    244     FresnelApplication() 
    245         { 
    246         } 
    247  
    248     ~FresnelApplication()  
    249     { 
    250     } 
     216    LodTreeApplication(){} 
     217    ~LodTreeApplication(){} 
     218 
    251219protected: 
    252220     
     
    353321    void createFrameListener(void) 
    354322    { 
    355         mFrameListener= new FresnelFrameListener(mWindow, mCamera); 
     323        mFrameListener= new LodTreeFrameListener(mWindow, mCamera); 
    356324        mFrameListener->showDebugOverlay(true); 
    357325        mRoot->addFrameListener(mFrameListener); 
     
    378346{ 
    379347    // Create application object 
    380     FresnelApplication app; 
     348    LodTreeApplication app; 
    381349 
    382350    try { 
Note: See TracChangeset for help on using the changeset viewer.