Changeset 3293 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 01/28/09 21:58:44 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj
r3292 r3293 156 156 IgnoreAllDefaultLibraries="false" 157 157 IgnoreDefaultLibraryNames="LIBCMT" 158 GenerateDebugInformation=" false"158 GenerateDebugInformation="true" 159 159 SubSystem="1" 160 160 LargeAddressAware="2" -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3291 r3293 658 658 { 659 659 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 660 //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 661 660 662 // set the vertex pointer to the vertex buffer 661 663 glVertexPointer(3, GL_FLOAT, 0, (char *)NULL); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
r3284 r3293 31 31 mTangents(tangents), 32 32 mNumVertices(numVertices), 33 mVboId(-1) 33 mVboId(-1), 34 mVboId2(-1), 35 mIndices(NULL) 34 36 { 35 37 mHasTexture = (mTexCoords != NULL); … … 37 39 38 40 Prepare(); 41 42 mIndices = new unsigned int[mNumVertices]; 43 44 for (int i = 0; i < mNumVertices; ++ i) 45 { 46 mIndices[i] = i; 47 } 39 48 40 49 if (delData) … … 54 63 DEL_ARRAY_PTR(mTexCoords); 55 64 DEL_ARRAY_PTR(mTangents); 65 DEL_ARRAY_PTR(mIndices); 56 66 57 67 // delete vbo … … 87 97 88 98 float dotProd = DotProd(tangent, normal); 89 //tangent -= normal * dotProd;tangent = Normalize(tangent); 90 99 //tangent -= normal * dotProd; tangent = Normalize(tangent); 91 100 //mTangents[i] = tangent; 92 101 mTangents[i] = tangent * 0.5f + Vector3(0.5f); … … 94 103 95 104 for (int i = 0; i < mNumVertices; ++ i) 105 { 96 106 ((Vector3 *)data)[mNumVertices * 2 + i] = mTangents[i]; 107 } 97 108 98 109 currentPData += mNumVertices * 3; … … 102 113 { 103 114 for (int i = 0; i < mNumVertices; ++ i) 115 { 104 116 ((Texcoord2 *)currentPData)[i] = mTexCoords[i]; 117 } 105 118 } 106 119 … … 120 133 if (mTangents) 121 134 { 122 //cout << "dotprods: " << endl; 123 124 /*for (int i = 0; i < 100; ++ i) 125 { 126 //cout << mTangents[i] << " " << mNormals[i] << " " << DotProd(Normalize(mTangents[i]), Normalize(mNormals[i])) << endl; 127 float d = fabs(DotProd(Normalize(mTangents[i]), Normalize(mNormals[i]))); 128 if (d > 0.01) cout << d << " "; 129 //cout << d << " "; 130 } 131 cout << endl; 132 */ 133 134 for (int i = 0; i < 50; ++ i) 135 { 136 cout << mTexCoords[i].first << "," << mTexCoords[i].second << " "; 137 } 138 135 // hack: use color pointer to store tangents 139 136 glColorPointer(3, GL_FLOAT, 0, (char *)NULL + currentPVbo); 140 137 currentPVbo += mNumVertices * sizeof(Vector3); … … 151 148 glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 152 149 150 glGenBuffersARB(1, &mVboId2); 151 152 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 153 glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mNumVertices * sizeof(unsigned int), 154 mIndices, GL_STATIC_DRAW_ARB); 155 156 int bufferSize; 157 glGetBufferParameterivARB(GL_ELEMENT_ARRAY_BUFFER_ARB, GL_BUFFER_SIZE_ARB, &bufferSize); 158 // cout << "Index Array in VBO: " << bufferSize << " bytes\n"; 159 160 glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 161 153 162 // data handled by graphics driver from now on 154 163 delete [] data; … … 166 175 { 167 176 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 168 177 //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mVboId2); 178 169 179 int currentPointer; 170 171 180 glNormalPointer(GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3)); 172 181 … … 182 191 } 183 192 else 193 { 184 194 currentPointer = mNumVertices * 2 * sizeof(Vector3); 195 } 185 196 186 197 if (mHasTexture) 198 { 187 199 glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + currentPointer); 200 } 188 201 189 202 glVertexPointer(3, GL_FLOAT, 0, (char *)NULL); 190 203 /// update state 191 204 state->SetCurrentVboId(mVboId); 192 193 } 194 195 // don't render first degenerate index 205 } 206 196 207 glDrawArrays(GL_TRIANGLES, 0, mNumVertices); 197 198 if (mHasTangents) 199 glDisableClientState(GL_COLOR_ARRAY); 208 //glDrawElements(GL_TRIANGLES, mNumVertices, GL_UNSIGNED_INT, mIndices); 209 //glDrawElements(GL_TRIANGLES, mNumVertices, GL_UNSIGNED_INT, 0); 210 211 //glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); 212 //glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); 213 214 if (mHasTangents) glDisableClientState(GL_COLOR_ARRAY); 200 215 } 201 216 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h
r3260 r3293 81 81 Texcoord2 *mTexCoords; 82 82 83 unsigned int *mIndices; 84 83 85 unsigned int mVboId; 86 unsigned int mVboId2; 84 87 85 88 int mNumVertices;
Note: See TracChangeset
for help on using the changeset viewer.