Changeset 3102 for GTP


Ignore:
Timestamp:
11/05/08 18:49:31 (16 years ago)
Author:
mattausch
Message:

orthocam not working yet

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp

    r3089 r3102  
    368368                ambient.x = ambient.y = ambient.z = 0.2f; 
    369369                diffuse.x = diffuse.y = diffuse.z = 1.0f; 
    370                 black.x = black.y = black.z = .0f; 
     370                black.x   = black.y   = black.z  = .0f; 
    371371 
    372372                // only write rgb part of the material 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3071 r3102  
    228228                        </File> 
    229229                        <File 
    230                                 RelativePath=".\src\RenderTraverser.cpp" 
    231                                 > 
    232                                 <FileConfiguration 
    233                                         Name="Debug|Win32" 
    234                                         > 
    235                                         <Tool 
    236                                                 Name="VCCLCompilerTool" 
    237                                                 ObjectFile="$(IntDir)\$(InputName)1.obj" 
    238                                                 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
    239                                         /> 
    240                                 </FileConfiguration> 
    241                                 <FileConfiguration 
    242                                         Name="Release|Win32" 
    243                                         > 
    244                                         <Tool 
    245                                                 Name="VCCLCompilerTool" 
    246                                                 ObjectFile="$(IntDir)\$(InputName)1.obj" 
    247                                                 XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
    248                                         /> 
    249                                 </FileConfiguration> 
    250                         </File> 
    251                         <File 
    252230                                RelativePath=".\src\SampleGenerator.cpp" 
    253231                                > 
     
    325303                                </File> 
    326304                                <File 
    327                                         RelativePath=".\src\CHCTraverser.cpp" 
    328                                         > 
    329                                         <FileConfiguration 
    330                                                 Name="Debug|Win32" 
    331                                                 > 
    332                                                 <Tool 
    333                                                         Name="VCCLCompilerTool" 
    334                                                         ObjectFile="$(IntDir)\$(InputName)1.obj" 
    335                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
    336                                                 /> 
    337                                         </FileConfiguration> 
    338                                         <FileConfiguration 
    339                                                 Name="Release|Win32" 
    340                                                 > 
    341                                                 <Tool 
    342                                                         Name="VCCLCompilerTool" 
    343                                                         ObjectFile="$(IntDir)\$(InputName)1.obj" 
    344                                                         XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
    345                                                 /> 
    346                                         </FileConfiguration> 
    347                                 </File> 
    348                                 <File 
    349305                                        RelativePath=".\src\CHCTraverser.h" 
    350306                                        > 
     
    389345                                </File> 
    390346                                <File 
     347                                        RelativePath=".\src\CHCTraverser.cpp" 
     348                                        > 
     349                                        <FileConfiguration 
     350                                                Name="Debug|Win32" 
     351                                                > 
     352                                                <Tool 
     353                                                        Name="VCCLCompilerTool" 
     354                                                        ObjectFile="$(IntDir)\$(InputName)1.obj" 
     355                                                        XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
     356                                                /> 
     357                                        </FileConfiguration> 
     358                                        <FileConfiguration 
     359                                                Name="Release|Win32" 
     360                                                > 
     361                                                <Tool 
     362                                                        Name="VCCLCompilerTool" 
     363                                                        ObjectFile="$(IntDir)\$(InputName)1.obj" 
     364                                                        XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
     365                                                /> 
     366                                        </FileConfiguration> 
     367                                </File> 
     368                                <File 
    391369                                        RelativePath=".\src\FrustumCullingTraverser.cpp" 
     370                                        > 
     371                                        <FileConfiguration 
     372                                                Name="Debug|Win32" 
     373                                                > 
     374                                                <Tool 
     375                                                        Name="VCCLCompilerTool" 
     376                                                        ObjectFile="$(IntDir)\$(InputName)1.obj" 
     377                                                        XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
     378                                                /> 
     379                                        </FileConfiguration> 
     380                                        <FileConfiguration 
     381                                                Name="Release|Win32" 
     382                                                > 
     383                                                <Tool 
     384                                                        Name="VCCLCompilerTool" 
     385                                                        ObjectFile="$(IntDir)\$(InputName)1.obj" 
     386                                                        XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc" 
     387                                                /> 
     388                                        </FileConfiguration> 
     389                                </File> 
     390                                <File 
     391                                        RelativePath=".\src\RenderTraverser.cpp" 
    392392                                        > 
    393393                                        <FileConfiguration 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h

    r3074 r3102  
    528528        */ 
    529529        inline BvhNode *GetRoot(); 
    530  
     530        /** Returns the static root node of the bvh. 
     531        */ 
     532        inline BvhNode *GetStaticRoot(); 
     533        /** Returns the dynamic root node of the bvh. 
     534        */ 
    531535        inline BvhNode *GetDynamicRoot(); 
    532536        /** Returns the bounding box of this bvh. 
     
    850854 
    851855 
     856BvhNode *Bvh::GetStaticRoot() 
     857{  
     858        return mStaticRoot;  
     859} 
     860 
     861 
    852862const AxisAlignedBox3 &Bvh::GetBox() const  
    853863{  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp

    r3063 r3102  
    276276void Camera::GetProjectionMatrix(Matrix4x4 &m)const 
    277277{ 
     278        //glGetFloatv(GL_PROJECTION_MATRIX, (float *)m.x); 
    278279        m = mProjection; 
    279280} 
    280281 
    281282 
    282 /*********************************************************/ 
    283 /*       Class PerspectiveCamera implementation           */ 
     283 
     284/*********************************************************/ 
     285/*       Class PerspectiveCamera implementation          */ 
    284286/*********************************************************/ 
    285287 
     
    385387 
    386388 
     389void PerspectiveCamera::UpdateProjectionMatrix() 
     390{ 
     391        mProjection = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 
     392} 
     393 
     394 
     395 
    387396void PerspectiveCamera::ComputePoints(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 
    388397                                                                          Vector3 &ntl, Vector3 &ntr, Vector3 &nbl, Vector3 &nbr, 
     
    397406 
    398407 
    399 void PerspectiveCamera::UpdateProjectionMatrix() 
    400 { 
    401         mProjection = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 
    402 } 
    403  
    404  
    405 } 
     408 
     409/*********************************************************/ 
     410/*          Class OrthoCamera implementation             */ 
     411/*********************************************************/ 
     412 
     413 
     414OrthoCamera::OrthoCamera():  
     415mLeft(0), mRight(1), mBottom(0), mTop(1) 
     416{ 
     417        mNear = 0; mFar = 1; 
     418        UpdateProjectionMatrix(); 
     419} 
     420 
     421 
     422OrthoCamera::OrthoCamera(float l, float r, float b, float t):  
     423mLeft(l), mRight(r), mBottom(b), mTop(t) 
     424{ 
     425        mNear = 0; mFar = 1; 
     426        UpdateProjectionMatrix(); 
     427} 
     428 
     429 
     430OrthoCamera::OrthoCamera(float l, float r, float b, float t, float n, float f):  
     431mLeft(l), mRight(r), mBottom(b), mTop(t) 
     432{ 
     433        mNear = n; mFar = f; 
     434        UpdateProjectionMatrix(); 
     435} 
     436 
     437 
     438void OrthoCamera::UpdateProjectionMatrix() 
     439{ 
     440        mProjection = GetOrtho(mLeft, mRight, mBottom, mTop, mNear, mFar); 
     441} 
     442 
     443 
     444} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h

    r3063 r3102  
    195195}; 
    196196 
    197  
     197/** Classs representing an orthographics camera. 
     198*/ 
     199class OrthoCamera: public Camera 
     200{ 
     201        friend class ShadowMap; 
     202 
     203public: 
     204        /** Default constructor. 
     205        */ 
     206        OrthoCamera(); 
     207        /** Camera taking the frustum left, right, bottom, top. 
     208        */ 
     209        OrthoCamera(float l, float r, float b, float t); 
     210 
     211        /** Camera taking the frustum left, right, bottom, top, near, far. 
     212        */ 
     213        OrthoCamera(float l, float r, float b, float t, float n, float f); 
     214 
     215 
     216protected: 
     217        /** Calculates the current projection matrix. 
     218        */ 
     219        virtual void UpdateProjectionMatrix(); 
     220 
     221 
     222        ////////// 
     223        //-- members 
     224 
     225        float mLeft; 
     226        float mRight; 
     227        float mBottom; 
     228        float mTop; 
     229}; 
    198230} 
    199231#endif 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp

    r3078 r3102  
    751751 
    752752 
    753 /** The resultig matrix that is equal to the result of glOrtho 
     753/** The resulting matrix is equal to the result of glOrtho 
    754754*/ 
    755 Matrix4x4 GetOrtho(float left, float right, float bottom, float top, float far, float near) 
     755Matrix4x4 GetOrtho(float left, float right, float bottom, float top, float near, float far) 
    756756{ 
    757757        Matrix4x4 m; 
     
    778778        m.x[3][0] = (right + left) * xDif; 
    779779        m.x[3][1] = (top + bottom) * yDif; 
    780         m.x[3][2] = (far + near) * zDif; 
     780        m.x[3][2] = (far + near)   * zDif; 
    781781        m.x[3][3] = 1.0f; 
    782782 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.h

    r3062 r3102  
    165165Matrix4x4 GetFrustum(float left, float right, float bottom, float top, float near, float far); 
    166166Matrix4x4 LookAt(const Vector3 &pos, const Vector3 &dir, const Vector3& up); 
    167 Matrix4x4 GetOrtho(float fov, float aspect, float near, float far); 
     167Matrix4x4 GetOrtho(float left, float right, float bottom, float top, float near, float far); 
    168168Matrix4x4 GetPerspective(float fov, float aspect, float near, float far); 
    169169 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp

    r3074 r3102  
    5252mShowBounds(false), 
    5353mRenderQueue(NULL), 
    54 mMaxVisibleDistance(.0f) 
     54mMaxVisibleDistance(.0f), 
     55mRenderDynamicObjects(true) 
    5556{ 
    5657} 
     
    156157 
    157158        // add root node to queue 
    158         EnqueueNode(mBvh->GetRoot()); 
     159        if (mRenderDynamicObjects) 
     160                EnqueueNode(mBvh->GetRoot()); 
     161        else 
     162                EnqueueNode(mBvh->GetStaticRoot()); 
     163 
    159164         
    160165 
     
    278283 
    279284 
    280 } 
     285void RenderTraverser::SetRenderDynamicObjects(bool dynamic) 
     286{ 
     287        mRenderDynamicObjects = dynamic; 
     288} 
     289 
     290} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h

    r3065 r3102  
    137137        */ 
    138138        float GetMaxVisibleDistance() const { return mMaxVisibleDistance; } 
     139        /** Render also dynamic objects. 
     140        */ 
     141        void SetRenderDynamicObjects(bool dynamic); 
    139142 
    140143 
     
    210213 
    211214        bool mUseDepthPass; 
     215 
     216        bool mRenderDynamicObjects; 
    212217}; 
    213218 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r3101 r3102  
    4444        for (int i = 0; i < l; ++ i) 
    4545        { 
    46                 if (mLODLevels[i].GetSquaredDistance() > dist) 
    47                         break; 
    48  
     46                if (mLODLevels[i].GetSquaredDistance() > dist) break; 
    4947                mCurrentLODLevel = i; 
    5048        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r3085 r3102  
    9696        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; } 
    9797 
     98        static bool GetUseLODs() { return sUseLODs; } 
     99 
     100 
    98101 
    99102protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp

    r3101 r3102  
    77#include "FrameBufferObject.h" 
    88#include "RenderState.h" 
     9#include "SceneEntity.h" 
     10 
    911 
    1012#include <IL/il.h> 
     
    140142        const float ylen = mSceneBox.Size().y * .5f; 
    141143         
    142         PerspectiveCamera *orthoCam = new PerspectiveCamera(xlen / ylen); 
    143         //orthoCam->SetOrtho(true); 
    144  
    145         orthoCam->SetNear(0.0f); 
    146         orthoCam->Yaw(.5 * M_PI); 
    147         orthoCam->SetDirection(Vector3(0, 0, -1)); 
    148  
    149144        Vector3 pos = Vector3(mSceneBox.Center().x, mSceneBox.Center().y, mSceneBox.Max().z); 
    150         orthoCam->SetPosition(pos); 
    151145 
    152146        FrameBufferObject *fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32, true); 
     
    166160        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    167161 
    168         // hack: disable cull face because of alpha textured balconies 
    169         glDisable(GL_CULL_FACE); 
    170         mRenderState->LockCullFaceEnabled(true); 
    171  
    172         //glDisable(GL_CULL_FACE); 
    173         //glEnable(GL_DEPTH_TEST); 
    174  
    175162        glMatrixMode(GL_MODELVIEW); 
    176163        glPushMatrix(); 
    177         glLoadIdentity(); 
     164        //glLoadIdentity(); 
    178165 
    179166        glMatrixMode(GL_PROJECTION); 
    180167        glPushMatrix(); 
    181         glLoadIdentity(); 
    182  
    183         glOrtho(xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z);  
    184         //glOrtho(xlen, .0f, ylen, .0f, .0f, mSceneBox.Size().z);  
    185  
    186         glMatrixMode(GL_MODELVIEW); 
    187  
    188         orthoCam->SetupCameraView(); 
     168        //glLoadIdentity(); 
     169 
     170        OrthoCamera *orthoCam = new OrthoCamera(xlen, -xlen, ylen, -ylen, .0f, mSceneBox.Size().z); 
     171         
     172        orthoCam->Yaw(.5 * M_PI); 
     173        orthoCam->SetDirection(Vector3(0, 0, -1)); 
     174        orthoCam->SetPosition(pos); 
     175 
     176        orthoCam->SetupViewProjection(); 
     177 
     178        //glOrtho(xlen, -xlen, ylen, -ylen, 0.0f, mSceneBox.Size().z);  
     179        //glMatrixMode(GL_MODELVIEW); 
     180        //orthoCam->SetupCameraView(); 
    189181 
    190182        mDepth = new float[texHeight * texWidth]; 
     
    196188        glEnableClientState(GL_NORMAL_ARRAY); 
    197189 
     190        // hack: use highest lod level for trees (billboards) 
     191        LODLevel::InitFrame(Vector3(1e6f)); 
     192 
    198193        // forward rendering 
    199194        mRenderState->SetRenderTechnique(0); 
     195        // temporarilly switch off 
     196        renderer->SetRenderDynamicObjects(false); 
    200197 
    201198        renderer->RenderScene(); 
     
    205202 
    206203        renderer->SetCamera(oldCam); 
    207          
    208         mRenderState->LockCullFaceEnabled(false); 
    209         //glEnable(GL_CULL_FACE); 
     204        // temporarilly switch off 
     205        renderer->SetRenderDynamicObjects(true); 
    210206 
    211207        glMatrixMode(GL_MODELVIEW); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3101 r3102  
    458458        //-- load some dynamic stuff 
    459459 
    460         LoadModel("hbuddha.dem", dynamicObjects); 
     460        /*LoadModel("hbuddha.dem", dynamicObjects); 
    461461        //LoadModel("hbuddha2.dem", dynamicObjects); 
    462462        buddha = dynamicObjects.back(); 
     
    484484        } 
    485485 
     486*/ 
    486487 
    487488        /////////// 
     
    883884 
    884885        Matrix4x4 mat = TranslationMatrix(planepos); 
    885         buddha->GetTransform()->SetMatrix(mat); 
     886        //buddha->GetTransform()->SetMatrix(mat); 
    886887 
    887888        Vector3 oldPos = camera->GetPosition(); 
     
    19871988        shadowMap->ComputeShadowMap(shadowTraverser, viewProjMat); 
    19881989 
    1989         glEnable(GL_CULL_FACE); 
    19901990        camera->SetFar(farDist); 
    19911991 
    19921992        renderState.SetUseAlphaToCoverage(true); 
    19931993        renderState.LockCullFaceEnabled(false); 
     1994        glEnable(GL_CULL_FACE); 
    19941995 
    19951996        glEnableClientState(GL_NORMAL_ARRAY); 
Note: See TracChangeset for help on using the changeset viewer.