Changeset 2961


Ignore:
Timestamp:
09/21/08 23:42:44 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
8 added
10 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln

    r2800 r2961  
    22Microsoft Visual Studio Solution File, Format Version 9.00 
    33# Visual Studio 2005 
    4 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "chc_revisited", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 
     4Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "friendlyculling", "FriendlyCulling.vcproj", "{03661866-4093-4B02-B26A-028EA91AF023}" 
     5EndProject 
     6Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcproj", "{93A522E1-76F0-4D46-9C97-30DC2DDB531D}" 
    57EndProject 
    68Global 
     
    1416                {03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.ActiveCfg = Release|Win32 
    1517                {03661866-4093-4B02-B26A-028EA91AF023}.Release|Win32.Build.0 = Release|Win32 
     18                {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Debug|Win32.ActiveCfg = Debug|Win32 
     19                {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Debug|Win32.Build.0 = Debug|Win32 
     20                {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Release|Win32.ActiveCfg = Release|Win32 
     21                {93A522E1-76F0-4D46-9C97-30DC2DDB531D}.Release|Win32.Build.0 = Release|Win32 
    1622        EndGlobalSection 
    1723        GlobalSection(SolutionProperties) = preSolution 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r2960 r2961  
    248248                        </File> 
    249249                        <File 
    250                                 RelativePath=".\src\ObjConverter.cpp" 
    251                                 > 
    252                         </File> 
    253                         <File 
    254                                 RelativePath=".\src\ObjConverter.h" 
    255                                 > 
    256                         </File> 
    257                         <File 
    258250                                RelativePath=".\src\PerformanceGraph.cpp" 
    259251                                > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjConverter.cpp

    r2959 r2961  
    66#include "Material.h" 
    77#include "Texture.h" 
    8 #include <map> 
    98 
    109 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ObjConverter.h

    r2957 r2961  
    1 #ifndef __ObjConverter_H 
    2 #define __ObjConverter_H 
     1#ifndef _OBJCONVERTER_H 
     2#define _OBJCONVERTER_H 
    33 
    44#include "common.h" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2957 r2961  
    4242        if (!hasTrafo) 
    4343        { 
     44                // identity 
    4445                trafo = new Transform3(); 
    4546        } 
     
    7273                str.read(reinterpret_cast<char *>(&numShapes), sizeof(int)); 
    7374 
     75                 
    7476                LODLevel *lodLevel = new LODLevel(dist); 
    7577 
     
    102104        int numTextures; 
    103105        str.read(reinterpret_cast<char *>(&numTextures), sizeof(int)); 
    104  
     106         
    105107        for (int i = 0; i < numTextures; ++ i) 
    106108        { 
    107                 // texture 
     109                // load texture name 
    108110                int texnameSize; 
    109  
    110111                str.read(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 
    111112 
     
    201202         
    202203        // end of file reached 
    203         if (str.eof()) 
    204                 return NULL; 
     204        if (str.eof()) return NULL; 
    205205 
    206206        //cout << "vertexcount: " << vertexCount << endl; 
     
    218218        { 
    219219                texcoords = new float[texCoordCount * 2]; 
    220                 str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * vertexCount * 2); 
     220                str.read(reinterpret_cast<char *>(texcoords), sizeof(float) * texCoordCount * 2); 
    221221        } 
    222222        else 
     
    225225        } 
    226226         
    227 #if 0 
    228         // construct normals 
    229         for (int i = 0; i < vertexCount; i += 3) 
    230         { 
    231                 Triangle3 tri(vertices[i], vertices[i + 1], vertices[i + 2]); 
    232  
    233                 normals[i] = tri.GetNormal(); 
    234                 normals[i+1] = tri.GetNormal(); 
    235                 normals[i+2] = tri.GetNormal(); 
    236         } 
    237 #endif 
    238227 
    239228        return new Geometry(vertices, normals, texcoords, vertexCount, true); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r2957 r2961  
    152152AxisAlignedBox3 SceneEntity::GetTransformedBoundingBox() const 
    153153{ 
    154         if (mTransform->IsIdentity()) 
    155                 return mBox; 
     154        if (mTransform->IsIdentity()) return mBox; 
    156155 
    157156        Matrix4x4 mat = mTransform->GetMatrix(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp

    r2960 r2961  
    114114 
    115115        const float scaleFactor = 80.0f; 
     116        //const float scaleFactor = 5.0f; 
    116117 
    117118        position.z -= 3 * scaleFactor; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.h

    r2957 r2961  
    3838        /** See Get 
    3939        */ 
    40         inline void SetMatrix(const Matrix4x4 &trafo) { mMatrix = trafo; } 
     40        inline void SetMatrix(const Matrix4x4 &trafo) { mIsIdentity = false; mMatrix = trafo; } 
    4141        /** Right multiplies with the given matrix. 
    4242        */ 
    43         inline void MultMatrix(const Matrix4x4 &trafo); 
     43        void MultMatrix(const Matrix4x4 &trafo); 
    4444        /** Resets trafo to identiy. 
    4545        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2960 r2961  
    1 // occquery.cpp : Defines the entry point for the console application. 
     1// chcdemo.cpp : Defines the entry point for the console application. 
    22// 
    33#include "glInterface.h" 
     
    149149bool flyMode = true; 
    150150 
    151 SceneEntityContainer skyGeometry; 
    152  
    153151bool leftKeyPressed = false; 
    154152bool rightKeyPressed = false; 
     
    415413 
    416414 
     415        glEnable(GL_MULTISAMPLE_ARB); 
     416        glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); 
     417 
     418        LeftMotion(0, 0); 
     419        MiddleMotion(0, 0); 
     420 
     421        perfGraph = new PerformanceGraph(1000); 
     422 
     423        loader = new ResourceManager(); 
     424 
     425        //const string filename("data/city/model/city.dem"); 
     426        const string filename = string(model_path + "city.dem"); 
     427 
     428        if (loader->Load(filename, sceneEntities)) 
     429                cout << "scene " << filename << " loaded" << endl; 
     430        else 
     431        { 
     432                cerr << "loading scene " << filename << " failed" << endl; 
     433                CleanUp(); 
     434                exit(0); 
     435        } 
     436 
     437        const string bvh_filename = string(model_path + "city.bvh"); 
     438        BvhLoader bvhLoader; 
     439        bvh = bvhLoader.Load(bvh_filename, sceneEntities); 
     440 
     441        if (!bvh) 
     442        { 
     443                cerr << "loading bvh " << bvh_filename << " failed" << endl; 
     444                CleanUp(); 
     445                exit(0); 
     446        } 
     447 
     448         
    417449        Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 
    418         AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 
     450        /*AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 
    419451 
    420452        Material *mat = new Material(RgbaColor(1, 0.4, 0.4, 0)); 
    421453        Transform3 *tf = new Transform3(); 
    422454        cube = SceneEntityConverter().ConvertBox(box, mat, tf); 
    423  
    424         //aeroplane = ObjConverter().Load(model_path + "toyplane.obj"); 
    425         //if (!aeroplane)       cerr << "loadig plane failed" << endl; 
    426  
    427         skyDome = ObjConverter().Load(model_path + "sky.obj"); 
    428         if (!skyDome) cerr << "loadig plane failed" << endl; 
    429  
    430         const float turbitiy = 3.0f; 
    431         preetham = new SkyPreetham(turbitiy, skyDome); 
    432  
    433         glEnable(GL_MULTISAMPLE_ARB); 
    434         glHint(GL_MULTISAMPLE_FILTER_HINT_NV, GL_NICEST); 
    435  
    436         LeftMotion(0, 0); 
    437         MiddleMotion(0, 0); 
    438  
    439         perfGraph = new PerformanceGraph(1000); 
    440  
    441         loader = new ResourceManager(); 
    442  
    443         //const string filename("data/city/model/city.dem"); 
    444         const string filename = string(model_path + "city.dem"); 
    445  
    446         if (loader->Load(filename, sceneEntities)) 
    447                 cout << "scene " << filename << " loaded" << endl; 
     455*/ 
     456 
     457        Matrix4x4 transl = TranslationMatrix(cubeCenter); 
     458         
     459        const string aeroplaneStr = model_path + "toyplane.dem"; 
     460 
     461        SceneEntityContainer dummy; 
     462 
     463        if (loader->Load(aeroplaneStr, dummy)) 
     464                cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 
    448465        else 
    449466        { 
    450                 cerr << "loading scene " << filename << " failed" << endl; 
     467                cerr << "loading file " << aeroplaneStr << " failed" << endl; 
     468 
    451469                CleanUp(); 
    452470                exit(0); 
    453471        } 
    454472 
    455         SceneEntityContainer dummy; 
    456  
    457         const string envname = string(model_path + "env.dem"); 
    458  
    459         if (loader->Load(envname, skyGeometry)) 
    460                 cout << "sky box " << filename << " loaded" << endl; 
    461         else 
    462         { 
    463                 cerr << "loading sky box " << filename << " failed" << endl; 
    464                 CleanUp(); 
    465                 exit(0); 
    466         } 
    467  
    468         const string bvh_filename = string(model_path + "city.bvh"); 
    469         BvhLoader bvhLoader; 
    470         bvh = bvhLoader.Load(bvh_filename, sceneEntities); 
    471  
    472         if (!bvh) 
    473         { 
    474                 cerr << "loading bvh " << bvh_filename << " failed" << endl; 
    475                 CleanUp(); 
    476                 exit(0); 
    477         } 
     473        aeroplane = dummy[0]; 
     474        aeroplane->GetTransform()->MultMatrix(transl); 
     475        dummy.clear(); 
     476 
    478477 
    479478        // set far plane based on scene extent 
     
    488487        SkyPreetham::Init(sCgContext); 
    489488 
     489         
     490        string skyDomeStr(model_path + "sky.dem"); 
     491 
     492        if (loader->Load(skyDomeStr, dummy)) 
     493                cout << "successfully loaded " << dummy.size() << " scene entities" << endl; 
     494        else 
     495        { 
     496                cerr << "loading file " << skyDomeStr << " failed" << endl; 
     497 
     498                CleanUp(); 
     499                exit(0); 
     500        } 
     501 
     502        skyDome = dummy[0]; 
     503         
     504        const float turbitiy = 3.0f; 
     505        preetham = new SkyPreetham(turbitiy, skyDome); 
    490506 
    491507        // initialize the render traverser 
     
    628644void InitGLstate()  
    629645{ 
    630         glClearColor(0.4f, 0.4f, 0.4f, 1.0f); 
     646        glClearColor(1.4f, 0.4f, 0.4f, 1.0f); 
    631647         
    632648        glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 
     
    10871103         
    10881104 
    1089  
    10901105        /////////////// 
    10911106        //-- render sky 
     
    10951110 
    10961111        RenderSky(); 
    1097          
     1112 
     1113        //state.Reset(); glEnable(GL_TEXTURE_2D); 
     1114        aeroplane->Render(&state); 
     1115 
    10981116 
    10991117        if ((renderMethod == RENDER_DEFERRED) || 
    11001118                (renderMethod == RENDER_DEPTH_PASS_DEFERRED)) 
    11011119        { 
    1102                 //glPopAttrib(); 
    11031120                FrameBufferObject::Release(); 
    11041121 
     
    19541971void RenderSky() 
    19551972{ 
    1956         //glEnable(GL_LIGHTING); 
    19571973        cgGLEnableProfile(RenderState::sCgVertexProfile); 
    19581974 
     
    19601976                state.SetRenderPassType(RenderState::DEFERRED); 
    19611977 
    1962         SceneEntityContainer::const_iterator sit, sit_end = skyGeometry.end(); 
    1963  
    1964         //      for (sit = skyGeometry.begin(); sit != sit_end; ++ sit) 
    1965         //              (*sit)->Render(&state); 
    1966  
    1967         //cube->Render(&state); 
    1968         //aeroplane->Render(&state); 
    1969         //glEnable(GL_LIGHTING); 
    1970  
    19711978        preetham->RenderSkyDome(-light->GetDirection(), camera, &state); 
    1972          
     1979 
    19731980        cgGLDisableProfile(RenderState::sCgVertexProfile); 
    19741981        cgGLDisableProfile(RenderState::sCgFragmentProfile); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/common.h

    r2913 r2961  
    163163// Clears a container (i.e., a vector of pointers) and deletes the pointers 
    164164#ifndef CLEAR_CONTAINER 
    165 #define CLEAR_CONTAINER(co) do { for (size_t _i = 0; _i < (int)(co).size(); ++ _i) { \ 
     165#define CLEAR_CONTAINER(co) do { for (size_t _i = 0; _i < (co).size(); ++ _i) { \ 
    166166        DEL_PTR((co)[_i]);} \ 
    167167        (co).clear(); } \ 
Note: See TracChangeset for help on using the changeset viewer.