Changeset 3127 for GTP/trunk/App/Demos
- Timestamp:
- 11/14/08 17:22:49 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.cpp
r3120 r3127 19 19 delete [] mGeometry[i]->mVertices; 20 20 delete [] mGeometry[i]->mNormals; 21 delete [] mGeometry[i]->mTangents; 21 22 delete [] mGeometry[i]->mTexcoords; 22 23 … … 83 84 geom->mVertices = new SimpleVec[numElements]; 84 85 geom->mNormals = new SimpleVec[numElements]; 86 geom->mTangents = new SimpleVec[numElements]; 85 87 geom->mTexcoords = new Texcoord[numElements]; 86 88 … … 105 107 geom->mNormals[line] = normal; 106 108 geom->mTexcoords[line] = tex; 109 geom->mTangents[line] = tangent; 107 110 108 111 ++ line; … … 125 128 str.write(reinterpret_cast<char *>(geom->mVertices), sizeof(SimpleVec) * vertexCount); 126 129 str.write(reinterpret_cast<char *>(geom->mNormals), sizeof(SimpleVec) * vertexCount); 130 str.write(reinterpret_cast<char *>(geom->mTangents), sizeof(SimpleVec) * vertexCount); 127 131 128 132 int texCoordCount = geom->mTexcoordCount; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.h
r3119 r3127 32 32 SimpleVec *mVertices; 33 33 SimpleVec *mNormals; 34 SimpleVec *mTangents; 34 35 Texcoord *mTexcoords; 35 36 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3125 r3127 1508 1508 mRoot->mLast = (int)mGeometrySize - 1; 1509 1509 1510 cout<<"f: " << mRoot->mFirst<< " l: " <<mRoot->mLast << endl;1510 //cout<<"f: " << mRoot->mFirst<< " l: " <<mRoot->mLast << endl; 1511 1511 // add static root on left subtree 1512 1512 mRoot->mFront = mStaticRoot; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
r3126 r3127 15 15 #endif 16 16 17 using namespace std; 17 18 18 19 namespace CHCDemoEngine … … 66 67 67 68 if (mTexCoords) dataSize += mNumVertices * 2; 68 69 69 if (mTangents) dataSize += mNumVertices * 3; 70 70 … … 82 82 { 83 83 for (int i = 0; i < mNumVertices; ++ i) 84 ((Vector3 *)data)[mNumVertices * 3 + i] = mTangents[i]; 84 ((Vector3 *)data)[mNumVertices * 2 + i] = mTangents[i]; 85 86 for (int i = 0; i < 3; ++ i) 87 cout << ((Vector3 *)data)[mNumVertices * 2 + i] << " "; 85 88 86 89 currentPData += mNumVertices * 3; … … 129 132 void Geometry::Render(RenderState *state) 130 133 { 134 if (mHasTangents) 135 glEnableClientState(GL_COLOR_ARRAY); 136 131 137 if (state->GetCurrentVboId() != mVboId) 132 138 { 133 139 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 134 140 135 if (mHasTexture) 136 glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + 2 * mNumVertices * sizeof(Vector3)); 141 int currentPointer; 137 142 138 143 glNormalPointer(GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3)); 144 145 if (mHasTangents) 146 { 147 glColorPointer(3, GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3)); 148 currentPointer = mNumVertices * 3 * sizeof(Vector3); 149 } 150 else 151 currentPointer = mNumVertices * 2 * sizeof(Vector3); 152 153 if (mHasTexture) 154 glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + currentPointer); 139 155 140 156 glVertexPointer(3, GL_FLOAT, 0, (char *)NULL); 141 157 142 158 state->SetCurrentVboId(mVboId); 159 143 160 } 144 161 145 162 // don't render first degenerate index 146 163 glDrawArrays(GL_TRIANGLES, 0, mNumVertices); 164 165 if (mHasTangents) 166 glDisableClientState(GL_COLOR_ARRAY); 147 167 } 148 168 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3126 r3127 130 130 static Technique queryTech = GetQueryTechnique(); 131 131 SetState(&queryTech); 132 133 glDisableClientState(GL_NORMAL_ARRAY); 134 } 135 else 136 { 137 glEnableClientState(GL_NORMAL_ARRAY); 132 138 } 133 139 … … 219 225 { 220 226 mTexturesEnabled = false; 221 222 //if (!tech->GetFragmentProgram()) 223 glDisable(GL_TEXTURE_2D); 227 glDisable(GL_TEXTURE_2D); 224 228 225 229 glDisableClientState(GL_TEXTURE_COORD_ARRAY); … … 229 233 mTexturesEnabled = true; 230 234 231 //if (!tech->GetFragmentProgram()) 232 glEnable(GL_TEXTURE_2D); 233 235 glEnable(GL_TEXTURE_2D); 234 236 glEnableClientState(GL_TEXTURE_COORD_ARRAY); 235 237 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3126 r3127 39 39 ResourceManager::ResourceManager() 40 40 { 41 mUseNormalMapping = false; 41 42 } 42 43 … … 289 290 static ShaderProgram *sDefaultVertexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultVertexMrt"); 290 291 292 static ShaderProgram *sNormalMappingVertexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("normalMappingVertexMrt"); 293 static ShaderProgram *sNormalMappingFragmentProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("normalMappingFragmentMrt"); 294 291 295 Technique *deferred = new Technique(*tech); 292 296 … … 343 347 str.read(reinterpret_cast<char *>(normals), sizeof(Vector3) * vertexCount); 344 348 349 Vector3 *tangents; 350 351 if (mUseNormalMapping) 352 { 353 tangents = new Vector3[vertexCount]; 354 str.read(reinterpret_cast<char *>(tangents), sizeof(Vector3) * vertexCount); 355 } 356 else 357 { 358 tangents = NULL; 359 } 360 345 361 int texCoordCount; 346 362 str.read(reinterpret_cast<char *>(&texCoordCount), sizeof(int)); … … 356 372 } 357 373 358 return new Geometry(vertices, normals, texcoords, vertexCount, true, NULL);359 //return new Geometry(vertices, normals, texcoords, vertexCount, false);374 const bool delGeometry = false; 375 return new Geometry(vertices, normals, texcoords, vertexCount, delGeometry, tangents); 360 376 } 361 377 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h
r3070 r3127 58 58 59 59 60 bool mUseNormalMapping; 61 60 62 protected: 61 63 … … 76 78 Geometry *LoadGeometry(igzstream &str); 77 79 80 78 81 std::map<int, Texture *> mTextureTable; 79 82 std::map<int, Material *> mMaterialTable; … … 90 93 TransformContainer mTrafos; 91 94 ShapeContainer mShapes; 92 //LODContainer mLODs;95 93 96 /// the scene entities 94 97 SceneEntityContainer mSceneEntities; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3125 r3127 471 471 //-- load some dynamic stuff 472 472 473 //LoadModel("fisch.dem", dynamicObjects); 474 LoadModel("hbuddha.dem", dynamicObjects); 473 resourceManager->mUseNormalMapping = true; 474 //resourceManager->mUseNormalMapping = false; 475 476 LoadModel("fisch.dem", dynamicObjects); 477 478 resourceManager->mUseNormalMapping = false; 479 //LoadModel("hbuddha.dem", dynamicObjects); 475 480 buddha = dynamicObjects.back(); 476 481 … … 1996 2001 } 1997 2002 2003 1998 2004 ///////////////// 1999 2005 //-- reset gl renderState before the final visible objects pass … … 2115 2121 const string filename = string(model_path + model); 2116 2122 2123 cout << "\nloading model " << filename << endl; 2117 2124 if (resourceManager->Load(filename, entities)) 2118 cout << "model " << filename << " loaded" << endl;2125 cout << "model " << filename << " successfully loaded" << endl; 2119 2126 else 2120 2127 {
Note: See TracChangeset
for help on using the changeset viewer.