Changeset 2760 for GTP/trunk/App
- Timestamp:
- 06/14/08 19:04:01 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/CHC_revisited
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/BinaryLoader.cpp
r2757 r2760 13 13 namespace CHCDemo 14 14 { 15 16 /*static STL_MAP<String,Texture *> stlm_textures;17 18 19 // clear the texture table (called on new file load)20 static void clear_textures()21 {22 STL_MAP<String,Texture *>::iterator it, it_end = stlm_textures.end();23 24 for (it = stlm_textures.begin(); it != it_end; ++ it)25 {26 it->second->unref();27 delete [] it->first;28 29 it ++;30 }31 32 stlm_textures.clear();33 }34 35 36 static Texture *get_texture(const char *filename, TextureAttributes *&myTextureAttributes)37 {38 Texture * myTexture = NULL;39 40 myTextureAttributes = new TextureAttributes;41 myTextureAttributes->setTextureMode(TextureAttributes::DECAL);42 43 // Michi: avoid multiple loading of same texture!44 if (stlm_textures.find(filename) != stlm_textures.end())45 {46 myTexture = stlm_textures[filename];47 }48 else49 {50 ImageComponent *image = new ImageComponent(filename);51 //Texture *myTexture = new Texture(Texture::BASE_LEVEL, Texture::RGB, image->getWidth(), image->getHeight());52 myTexture = new Texture(Texture::MULTI_LEVEL_MIPMAP, ImageComponent::FORMAT_RGBP, image->getWidth(), image->getHeight());53 myTexture->setImage(0, image);54 55 myTexture->setMagFilter(Texture::BASE_LEVEL_LINEAR);56 myTexture->setMinFilter(Texture::MULTI_LEVEL_LINEAR_POINT);57 58 myTexture->setBoundaryModeS(Texture::WRAP);59 myTexture->setBoundaryModeT(Texture::WRAP);60 61 stlm_textures[filename] = myTexture;62 /// HACK!!! (texture not deleted on reload!)63 myTexture->ref();64 }65 66 return myTexture;67 }*/68 15 69 16 … … 98 45 str.read(texname, sizeof(char) * texnameSize); 99 46 100 cout << "loading texture " << texname << " with len " << texnameSize << " id: " << id << endl; 101 47 //cout << "loading texture " << texname << " with len " << texnameSize << " id: " << id << endl; 102 48 Texture *tex = new Texture(texname); 103 49 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.cpp
r2756 r2760 131 131 mIndices(NULL), 132 132 mTestIndices(NULL), 133 mCurrentIndicesPtr(0) 133 mCurrentIndicesPtr(0), 134 mNumNodes(0), 135 mMaxDepthForTestingChildren(4), 136 mAreaRatioThreshold(1.4f) 134 137 {} 135 138 136 /* 137 Bvh::Bvh(const GeometryVector &geometry, 138 DistanceSortedRenderAction *const renderer): 139 140 Bvh::Bvh(const SceneEntityContainer &entities): 139 141 mCamera(NULL), 140 142 mFrameId(-1), … … 144 146 mTestIndices(NULL), 145 147 mCurrentIndicesPtr(0), 146 { 147 mGeometry = new NodeGeometry*[geometry.size()]; 148 mGeometrySize = geometry.size(); 149 150 BoundingBox sceneBox; 151 152 // compute scene extent 153 for (size_t i = 0; i < mGeometrySize; ++ i) 154 { 155 mGeometry[i] = geometry[i]; 156 sceneBox.combine(&mGeometry[i]->mBox); 157 158 mBvhStats.mTriangles += mGeometry[i]->mNumTriangles; 159 } 160 161 162 //////// 163 //-- create root 164 165 BvhLeaf *leaf = new BvhLeaf(NULL); 166 leaf->mDepth = 0; 167 leaf->mFirst = 0; 168 leaf->mLast = (int)geometry.size() - 1; 169 leaf->mBox = sceneBox; 170 171 OUT1("geometry in root: " << leaf->mLast); 172 173 mRoot = leaf; 174 mNumNodes = 1; 175 176 // parameters 177 mMaxGeometry = Settings::Global()->get_nvocc_bvh_max_objects(); 178 mMaxTriangles = Settings::Global()->get_nvocc_bvh_max_triangles(); 179 mMaxDepth = Settings::Global()->get_nvocc_bvh_max_depth(); 180 mSplitType = Settings::Global()->get_nvocc_bvh_split_type(); 181 182 float sceneArea = sceneBox.getSurface(); 183 float minAreaRatio = Settings::Global()->get_nvocc_bvh_min_area(); 184 185 mMinArea = minAreaRatio * sceneArea; 186 187 mMaxDepthForTestingChildren = Settings::Global()->get_nvocc_bvh_max_depth_for_testing_children(); 188 189 mAreaRatioThreshold = Settings::Global()->get_nvocc_area_ratio_threshold(); 190 mVolRatioThreshold = Settings::Global()->get_nvocc_vol_ratio_threshold(); 191 } 192 */ 148 mNumNodes(0), 149 mMaxDepthForTestingChildren(4), 150 mAreaRatioThreshold(1.4f) 151 { 152 mGeometrySize = entities.size(); 153 mGeometry = new SceneEntity*[mGeometrySize]; 154 155 mBox.Initialize(); 156 157 SceneEntityContainer::const_iterator it, it_end = entities.end(); 158 159 int i = 0; 160 for (it = entities.begin(); it != it_end; ++ it, ++ i) 161 { 162 mGeometry[i] = (*it); 163 mBox.Include((*it)->GetBoundingBox()); 164 } 165 166 cout << "scene box: " << mBox << endl; 167 } 168 193 169 194 170 Bvh::~Bvh() … … 801 777 cout << "leafNodesVolume = " << mBvhStats.mLeafVol / mRoot->mBox.GetVolume() << endl; 802 778 803 cout << "boundsInteriorNodesSA = " << mBvhStats.mBoundsInteriorSA / mBvhStats.mLeafSA << endl;804 cout << "boundsLeafNodesSA = " << mBvhStats.mBoundsLeafSA / mBvhStats.mLeafSA << endl;805 cout << "boundsInteriorNodesVolume = " << mBvhStats.mBoundsInteriorVol / mBvhStats.mLeafVol << endl;806 cout << "boundsLeafNodesVolume = " << mBvhStats.mBoundsLeafVol / mBvhStats.mLeafVol << "\n" << endl;807 808 cout << "boundsLeaves: " << (float)mBvhStats.mBoundsLeavesCount / (float)GetNumLeaves() << "\n" << endl;809 779 cout << "geometry per leaf: " << mBvhStats.mGeometryRatio << endl; 810 780 cout << "triangles per leaf: " << mBvhStats.mTriangleRatio << endl; … … 828 798 } 829 799 830 } 800 801 void Bvh::UpdateNumLeaves(BvhNode *node) const 802 { 803 if (node->IsLeaf()) 804 { 805 node->mNumLeaves = 1; 806 } 807 else 808 { 809 BvhNode *f = static_cast<BvhInterior *>(node)->GetFront(); 810 BvhNode *b = static_cast<BvhInterior *>(node)->GetBack(); 811 812 UpdateNumLeaves(f); 813 UpdateNumLeaves(b); 814 815 node->mNumLeaves = f->mNumLeaves + b->mNumLeaves; 816 } 817 } 818 819 820 int Bvh::Render(BvhNode *node, RenderState *state) 821 { 822 //cout << "r " << node->mFirst << " " << node->mLast << endl; 823 824 int rendered = 0; 825 826 for (int i = node->mFirst; i <= node->mLast; ++ i) 827 { 828 if (mGeometry[i]->GetLastRendered() != mFrameId) 829 { 830 mGeometry[i]->Render(state); 831 mGeometry[i]->SetLastRendered(mFrameId); 832 ++ rendered; 833 } 834 } 835 836 return rendered; 837 } 838 839 840 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/Bvh.h
r2756 r2760 14 14 15 15 //////// 16 // Forward declarations16 //-- Forward declarations 17 17 18 18 class SceneEntity; 19 19 class Camera; 20 class RenderState; 20 21 21 22 … … 210 211 /// the bounding box 211 212 AxisAlignedBox3 mBox; 212 213 213 }; 214 214 … … 347 347 /** Returns split axis of this interior node. 348 348 */ 349 inline int GetAxis() { return (int)mAxis; }349 //inline int GetAxis() { return (int)mAxis; } 350 350 /** Returns position of the split axis. 351 351 */ 352 inline float GetPosition() {return (float)mPosition;}352 //inline float GetPosition() {return (float)mPosition;} 353 353 354 354 … … 356 356 357 357 /// the position of the split plane 358 float mPosition;358 //float mPosition; 359 359 360 360 BvhNode *mBack; … … 407 407 mInteriorVol(0), 408 408 mLeafVol(0), 409 mBoundsInteriorSA(0),410 mBoundsLeafSA(0),411 mBoundsInteriorVol(0),412 mBoundsLeafVol(0),413 mBoundsLeavesCount(0),414 409 mTriangles(0), 415 410 mTriangleRatio(0), … … 423 418 float mInteriorVol; 424 419 float mLeafVol; 425 float mBoundsInteriorSA; 426 float mBoundsLeafSA; 427 float mBoundsInteriorVol; 428 float mBoundsLeafVol; 429 int mBoundsLeavesCount; 420 430 421 int mTriangles; 431 422 … … 479 470 int RenderBoundingBoxes(const BvhNodeContainer &nodes); 480 471 472 /** Returns the bounding box of this bvh. 473 */ 474 inline const AxisAlignedBox3 &GetBox() { return mBox; } 481 475 482 476 … … 535 529 const BvhStats &GetBvhStats() const {return mBvhStats;} 536 530 531 int Render(BvhNode *node, RenderState *state); 532 537 533 538 534 protected: … … 543 539 */ 544 540 Bvh(); 541 542 /** Protected constructor taking scene geometry into account 543 */ 544 const Bvh(const SceneEntityContainer &entities); 545 545 546 546 … … 574 574 */ 575 575 void RecomputeBounds(); 576 /** Does some postprocessing on the leaves. 577 @returns #leaves that were chosen for tighter bounds. 578 */ 579 int PostProcessLeaves(BvhLeafContainer &leaves); 580 581 576 /** Does some postprocessing on the nodes. 577 */ 578 //void PostProcess(); 579 /** Helper method that updates the number of leaves in the subtree under 580 this node. 581 */ 582 void UpdateNumLeaves(BvhNode *node) const; 583 582 584 //////////////////////// 583 585 … … 619 621 int mNumNodes; 620 622 623 /// the bounding box 624 AxisAlignedBox3 mBox; 621 625 622 626 ////////////// -
GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.cpp
r2755 r2760 19 19 20 20 21 BvhLeaf *BvhLoader::ImportBinLeaf(ifstream &stream, BvhInterior *parent)22 {23 BvhLeaf *leaf = new BvhLeaf(parent);24 25 int first, last;26 27 stream.read(reinterpret_cast<char *>(&first), sizeof(int));28 stream.read(reinterpret_cast<char *>(&last), sizeof(int));29 30 leaf->mFirst = first;31 leaf->mLast = last;32 33 return leaf;34 }35 36 37 BvhInterior *BvhLoader::ImportBinInterior(ifstream &stream, BvhInterior *parent)38 {39 BvhInterior *interior = new BvhInterior(parent);40 41 stream.read(reinterpret_cast<char *>(&interior->mAxis), sizeof(char));42 stream.read(reinterpret_cast<char *>(&interior->mPosition), sizeof(float));43 44 return interior;45 }46 47 48 21 BvhNode *BvhLoader::LoadNextNode(ifstream &stream, BvhInterior *parent) 49 22 { … … 51 24 stream.read(reinterpret_cast<char *>(&nodeType), sizeof(int)); 52 25 26 BvhNode *node; 27 53 28 if (nodeType == TYPE_LEAF) 54 29 { 55 //OUT1("l"); 56 return ImportBinLeaf(stream, static_cast<BvhInterior *>(parent)); 30 // cout << "l"; 31 node = new BvhLeaf(parent); 32 } 33 else if (nodeType == TYPE_INTERIOR) 34 { 35 //cout << "i"; 36 node = new BvhInterior(parent); 37 } 38 else 39 { 40 cerr << "wrong node type: " << nodeType << endl; 41 //exit(0); 57 42 } 58 43 59 if (nodeType == TYPE_INTERIOR) 60 { 61 //OUT1("i"); 62 return ImportBinInterior(stream, static_cast<BvhInterior *>(parent)); 63 } 44 Vector3 bMin, bMax; 64 45 65 return NULL; 46 stream.read(reinterpret_cast<char *>(&(node->mFirst)), sizeof(int)); 47 stream.read(reinterpret_cast<char *>(&(node->mLast)), sizeof(int)); 48 stream.read(reinterpret_cast<char *>(&bMin), sizeof(Vector3)); 49 stream.read(reinterpret_cast<char *>(&bMax), sizeof(Vector3)); 50 51 node->mBox = AxisAlignedBox3(bMin, bMax); 52 53 node->mArea = node->mBox.SurfaceArea(); 54 55 //cout << "box: " << node->mBox << " area: " << node->mArea << endl; 56 57 return node; 66 58 } 67 59 68 60 69 Bvh *BvhLoader::Load FromFile(const string &filename,70 61 Bvh *BvhLoader::Load(const string &filename, 62 const SceneEntityContainer &entities) 71 63 { 72 64 // export binary version of mesh … … 77 69 78 70 cout << "loading bvh" << endl; 79 Bvh *bvh = new Bvh();80 71 81 bvh->mGeometrySize = entities.size(); 82 bvh->mGeometry = new SceneEntity*[bvh->mGeometrySize]; 83 84 for (size_t i = 0; i < bvh->mGeometrySize; ++ i) 85 bvh->mGeometry[i] = entities[i]; 86 72 Bvh *bvh = new Bvh(entities); 87 73 bvh->mRoot = LoadNextNode(stream, NULL); 88 74 … … 117 103 cout << "... finished loading " << bvh->mNumNodes << " nodes, updating boxes" << endl; 118 104 119 //adjust bounding boxes 120 //bvh->UpdateBoxes(bvh->mRoot); 121 //bvh->UpdateNumLeaves(bvh->mRoot); 105 /////////// 106 //-- post process 122 107 108 bvh->UpdateNumLeaves(bvh->mRoot); 123 109 // compute unique ids 124 //bvh->ComputeIds(); 125 // update the indices of the geometry so we can render interiors as well 126 //bvh->UpdateInteriors(bvh->mRoot); 127 // do this once so at least the current node bounding box is tested 128 //bvh->RecomputeBounds(); 110 bvh->ComputeIds(); 111 // specify bounds for occlusion tests 112 bvh->RecomputeBounds(); 113 // compute and print stats 114 bvh->ComputeBvhStats(); 115 bvh->PrintBvhStats(); 129 116 130 117 return bvh; -
GTP/trunk/App/Demos/Vis/CHC_revisited/BvhLoader.h
r2755 r2760 16 16 public: 17 17 18 Bvh *Load FromFile(const std::string &filename, const SceneEntityContainer &entities);18 Bvh *Load(const std::string &filename, const SceneEntityContainer &entities); 19 19 20 20 protected: 21 21 22 BvhLeaf *ImportBinLeaf(std::ifstream &stream, BvhInterior *parent);23 24 BvhInterior *ImportBinInterior(std::ifstream &stream, BvhInterior *parent);25 26 22 BvhNode *LoadNextNode(std::ifstream &stream, BvhInterior *parent); 27 28 29 23 }; 30 24 -
GTP/trunk/App/Demos/Vis/CHC_revisited/Camera.cpp
r2756 r2760 12 12 mWidth = 100; 13 13 mHeight = 100; 14 mFovy = 90.0f * M_PI /180.0f;14 mFovy = 90.0f * M_PI / 180.0f; 15 15 } 16 16 … … 21 21 mHeight = height; 22 22 23 mFovy = fieldOfView * M_PI /180.0f;23 mFovy = fieldOfView * M_PI / 180.0f; 24 24 } 25 25 … … 74 74 void Camera::GetProjectionMatrix(Matrix4x4 &mat) 75 75 { 76 //float m[16];77 78 76 glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat.x); 79 //mat = Matrix4x4((const float *)m);80 77 } 81 78 … … 83 80 void Camera::GetModelViewMatrix(Matrix4x4 &mat) 84 81 { 85 //float m[16];86 87 82 glGetFloatv(GL_MODELVIEW_MATRIX, (float *)mat.x); 88 //mat = Matrix4f((const float *)m);89 83 } 90 84 … … 100 94 matProjectionView *= matViewing; 101 95 102 103 96 float fInvLength; 104 105 97 float planes[6][4]; 106 98 -
GTP/trunk/App/Demos/Vis/CHC_revisited/FrustumCullingTraverser.cpp
r2757 r2760 1 1 #include "FrustumCullingTraverser.h" 2 #include "SceneEntity.h" 3 2 4 3 5 namespace CHCDemo … … 11 13 void FrustumCullingTraverser::Render() 12 14 { 15 mRenderState->mTexturesEnabled = false; 16 mDistanceQueue.push(mBvh->GetRoot()); 17 13 18 while (!mDistanceQueue.empty()) 14 19 { -
GTP/trunk/App/Demos/Vis/CHC_revisited/Material.cpp
r2759 r2760 20 20 mAmbientColor = RgbColor(0.2, 0.2, 0.2); 21 21 mDiffuseColor = RgbColor(1, 1, 1); 22 //mSpecularColor = RgbColor(0.5, 0.5, 0.5);23 mSpecularColor = RgbColor(1, 1, 1);22 mSpecularColor = RgbColor(0.0, 0.0, 0.0); 23 //mSpecularColor = RgbColor(1, 1, 1); 24 24 } 25 25 -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
r2755 r2760 68 68 if (node->IsLeaf()) 69 69 { 70 //mNumRenderedGeometry += node->Render(); 70 //mNumRenderedGeometry += 71 mBvh->Render(node, mRenderState); 71 72 } 72 73 else … … 81 82 } 82 83 84 85 void RenderTraverser::SetHierarchy(Bvh *bvh) 86 { 87 mBvh = bvh; 88 //DelQueries(); 89 } 90 91 92 void RenderTraverser::SetRenderState(RenderState *state) 93 { 94 mRenderState = state; 95 //DelQueries(); 96 } 97 98 83 99 #if 0 100 101 Bvh *RenderTraverser::GetHierarchy() 102 { 103 return mBvh; 104 } 105 84 106 85 107 void RenderTraverser::RenderVisualization() … … 135 157 } 136 158 137 void RenderTraverser::SetHierarchy(HierarchyNode *sceneRoot)138 {139 mHierarchyRoot = sceneRoot;140 141 DelQueries();142 }143 144 HierarchyNode *RenderTraverser::GetHierarchy()145 {146 return mHierarchyRoot;147 }148 159 149 160 unsigned int RenderTraverser::GetOcclusionQueryResult(HierarchyNode *node) const -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.h
r2755 r2760 12 12 class Camera; 13 13 class Matrix4x4; 14 14 15 15 16 … … 83 84 */ 84 85 void SetUseOptimization(bool useOptimization); 86 /** Sets the current render state 87 */ 88 void SetRenderState(RenderState *state); 89 85 90 86 91 protected: … … 113 118 void EnqueueNode(BvhNode *node); 114 119 120 115 121 //////////// 116 122 //-- members … … 138 144 //bool mIntersects; 139 145 bool mUseOptimization; 146 147 RenderState *mRenderState; 140 148 }; 141 149 -
GTP/trunk/App/Demos/Vis/CHC_revisited/chcdemo.cpp
r2759 r2760 13 13 #include "Camera.h" 14 14 #include "Geometry.h" 15 #include "BvhLoader.h" 16 #include "FrustumCullingTraverser.h" 17 15 18 16 19 … … 30 33 /// the scene bounding box 31 34 AxisAlignedBox3 sceneBox; 35 /// the current render state 36 RenderState state; 32 37 33 38 // eye near plane distance 34 39 float nearDist = 0.1f; 35 int winWidth, winHeight; 40 int winWidth = 1024; 41 int winHeight = 768; 36 42 float winAspectRatio = 1.0f; 37 43 … … 44 50 bool showCreateParams = false; 45 51 46 47 Vector3 eyePos = Vector3(0.0f, 0.0f, 3.0f); // eye position 48 Vector3 viewDir = Vector3(0.0f, 0.0f, -1.0f); // eye view dir 49 Vector3 lightDir = Vector3(0.0f, 0.0f, 1.0f); // light dir 50 51 Matrix4x4 visView; // visualisation view matrix 52 int currentFrame = -1; 53 54 // visualisation view matrix 55 Matrix4x4 visView; 52 56 53 57 //mouse navigation state 54 58 int xEyeBegin, yEyeBegin, yMotionBegin, verticalMotionBegin, horizontalMotionBegin = 0; 55 59 //int renderMode = RenderTraverser::RENDER_COHERENT; 56 57 60 58 61 const int renderTimeSize = 100; … … 100 103 int main(int argc, char* argv[]) 101 104 { 102 camera = new Camera( 800, 600);103 104 glutInitWindowSize( 800, 600);105 camera = new Camera(winWidth, winHeight); 106 107 glutInitWindowSize(winWidth, winHeight); 105 108 glutInit(&argc, argv); 106 109 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); … … 124 127 125 128 //const string filename("house_test.dem"); 126 const string filename("city_demo.dem"); 129 //const string filename("city_demo.dem"); 130 const string filename("city.dem"); 127 131 128 132 if (loader.Load(filename, sceneEntities)) … … 131 135 cerr << "loading scene " << filename << " failed" << endl; 132 136 133 sceneBox.Initialize(); 134 135 SceneEntityContainer::const_iterator it, it_end = sceneEntities.end(); 136 137 for (it = sceneEntities.begin(); it != it_end; ++ it) 138 sceneBox.Include((*it)->GetBoundingBox()); 139 140 cout << "scene box: " << sceneBox << endl; 141 137 BvhLoader bvhLoader; 138 bvh = bvhLoader.Load("city.bvh", sceneEntities); 139 140 sceneBox = bvh->GetBox(); 141 142 traverser = new FrustumCullingTraverser(); 143 traverser->SetHierarchy(bvh); 144 traverser->SetRenderState(&state); 142 145 143 146 //SetupProjection(800, 600, 60, sceneBox); … … 162 165 void InitGLstate(void) 163 166 { 164 glClearColor(0. 0f, 0.0f, 0.0f, 0.0);167 glClearColor(0.5f, 0.5f, 0.8f, 0.0); 165 168 166 169 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); … … 171 174 SetupLighting(); 172 175 173 glColor3f(1.0f, 0.0f, 0.0f);176 glColor3f(1.0f, 1.0f, 1.0f); 174 177 glShadeModel(GL_SMOOTH); 175 176 178 177 179 glMaterialf(GL_FRONT, GL_SHININESS, 64); … … 190 192 glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuseColor); 191 193 glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor); 192 193 glColor3f(1.0f, 0.0f, 0.0f);194 194 //setupVisView(); 195 195 } … … 277 277 GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; 278 278 GLfloat diffuse[] = {1.0, 1.0, 1.0, 1.0}; 279 //GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 279 280 GLfloat specular[] = {1.0, 1.0, 1.0, 1.0}; 280 281 … … 286 287 glLightfv(GL_LIGHT0, GL_SPECULAR, specular); 287 288 288 GLfloat position[] = { 0.0, 3.0, 3.0, 0.0};289 GLfloat position[] = {1.0, 1.0, 1.0, 0.0}; 289 290 glLightfv(GL_LIGHT0, GL_POSITION, position); 290 291 … … 293 294 //-- second light 294 295 295 GLfloat ambient1[] = {0.2, 0.2, 0.2, 1.0}; 296 GLfloat ambient1[] = {0.5, 0.5, 0.5, 1.0}; 297 //GLfloat diffuse1[] = {1.0, 1.0, 1.0, 1.0}; 296 298 GLfloat diffuse1[] = {0.5, 0.5, 0.5, 1.0}; 297 GLfloat specular1[] = {0. 0, 0.0, 0.0, 1.0};299 GLfloat specular1[] = {0.5, 0.5, 0.5, 1.0}; 298 300 299 301 glLightfv(GL_LIGHT1, GL_AMBIENT, ambient1); … … 314 316 void SetupEyeView(void) 315 317 { 316 317 318 glMatrixMode(GL_PROJECTION); 318 319 glLoadIdentity(); … … 323 324 glLoadIdentity(); 324 325 325 GLfloat position[] = {0.0f, 3.0f, 3.0f, 0.0f}; 326 camera->SetupCameraView(); 327 328 GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f}; 326 329 glLightfv(GL_LIGHT0, GL_POSITION, position); 327 330 328 GLfloat position1[] = {sceneBox.Center().x, sceneBox.Center().y, sceneBox.Center().z, 1.0f}; 331 GLfloat position1[] = {sceneBox.Center().x, sceneBox.Max().y, sceneBox.Center().z, 1.0f}; 332 //GLfloat position1[] = {-2.0f, 1.0f, 0.0f, 0.0f}; 329 333 glLightfv(GL_LIGHT1, GL_POSITION, position1); 330 331 camera->SetupCameraView();332 333 334 334 } 335 335 … … 374 374 */ 375 375 376 ++ currentFrame; 376 377 377 378 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); … … 380 381 SetupEyeView(); 381 382 383 bvh->InitFrame(camera, currentFrame); 384 385 382 386 InitTiming(); 383 387 … … 389 393 glEnableClientState(GL_NORMAL_ARRAY); 390 394 395 traverser->Render(); 396 /* 391 397 bool usesTextures = false; 392 398 … … 412 418 entity->Render(); 413 419 } 414 420 */ 415 421 glDisableClientState(GL_VERTEX_ARRAY); 416 422 glDisableClientState(GL_NORMAL_ARRAY); … … 568 574 { 569 575 // used to avoid vertical motion with the keys 570 Vector3 hvec = Vector3(viewDir[0], 0, viewDir[2]);576 //Vector3 hvec = Vector3(viewDir[0], 0, viewDir[2]); 571 577 572 578 switch(c)
Note: See TracChangeset
for help on using the changeset viewer.