Changeset 3126 for GTP/trunk/App/Demos
- Timestamp:
- 11/13/08 18:48:41 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3110 r3126 764 764 </File> 765 765 <File 766 RelativePath=".\src\shaders\normalMapping.cg" 767 > 768 </File> 769 <File 766 770 RelativePath=".\src\shaderenv.h" 767 771 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
r3021 r3126 23 23 Texcoord2 *texcoords, 24 24 int numVertices, 25 bool delData): 25 bool delData, 26 Vector3 *tangents): 26 27 mVertices(vertices), 27 28 mNormals(normals), 28 29 mTexCoords(texcoords), 30 mTangents(tangents), 29 31 mNumVertices(numVertices), 30 32 mVboId(-1) 31 33 { 32 34 mHasTexture = (mTexCoords != NULL); 35 mHasTangents = (mTangents != NULL); 33 36 34 37 Prepare(); … … 39 42 DEL_ARRAY_PTR(mNormals); 40 43 DEL_ARRAY_PTR(mTexCoords); 44 DEL_ARRAY_PTR(mTangents); 41 45 } 42 46 } … … 48 52 DEL_ARRAY_PTR(mNormals); 49 53 DEL_ARRAY_PTR(mTexCoords); 54 DEL_ARRAY_PTR(mTangents); 50 55 51 56 // delete vbo … … 60 65 int dataSize = mNumVertices * 6; 61 66 62 if (mTexCoords) 63 dataSize += mNumVertices * 2; 67 if (mTexCoords) dataSize += mNumVertices * 2; 64 68 69 if (mTangents) dataSize += mNumVertices * 3; 70 65 71 float *data = new float[dataSize]; 66 72 … … 71 77 } 72 78 79 float *currentPData = data + mNumVertices * 6; 80 81 if (mTangents) 82 { 83 for (int i = 0; i < mNumVertices; ++ i) 84 ((Vector3 *)data)[mNumVertices * 3 + i] = mTangents[i]; 85 86 currentPData += mNumVertices * 3; 87 } 88 73 89 if (mTexCoords) 74 90 { 75 91 for (int i = 0; i < mNumVertices; ++ i) 76 ((Texcoord2 *) data)[mNumVertices * 3 +i] = mTexCoords[i];92 ((Texcoord2 *)currentPData)[i] = mTexCoords[i]; 77 93 } 94 78 95 79 96 glGenBuffersARB(1, &mVboId); 80 97 glBindBufferARB(GL_ARRAY_BUFFER_ARB, mVboId); 81 98 99 int currentPVbo = 0; 100 82 101 glVertexPointer(3, GL_FLOAT, 0, (char *)NULL); 83 glNormalPointer(GL_FLOAT, 0, (char *)NULL + mNumVertices * sizeof(Vector3)); 102 103 currentPVbo += mNumVertices * sizeof(Vector3); 104 glNormalPointer(GL_FLOAT, 0, (char *)NULL + currentPVbo); 105 106 currentPVbo += mNumVertices * 2 * sizeof(Vector3); 107 108 if (mTangents) 109 { 110 glColorPointer(3, GL_FLOAT, 0, (char *)NULL + currentPVbo); 111 currentPVbo += mNumVertices * sizeof(Vector3); 112 } 84 113 85 114 if (mTexCoords) 86 115 { 87 glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + 2 * mNumVertices * sizeof(Vector3));116 glTexCoordPointer(2, GL_FLOAT, 0, (char *)NULL + currentPVbo); 88 117 } 89 118 90 glBufferDataARB(GL_ARRAY_BUFFER_ARB, 91 dataSize * sizeof(float), 92 (float *)data, 93 GL_STATIC_DRAW_ARB); 119 glBufferDataARB(GL_ARRAY_BUFFER_ARB, dataSize * sizeof(float), 120 (float *)data, GL_STATIC_DRAW_ARB); 94 121 95 122 glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.h
r2980 r3126 21 21 22 22 public: 23 /** Constructs a geometry from the given data. 24 The vertices are interpreted as triangles. 25 26 If delData is true, the vertex / normal / texture is deleted when 27 after it was transferred into a vbo 23 /** Constructs a geometry from the given data. The vertices are 24 interpreted as triangles. If delData is true, the 25 vertex / normal / texture is deleted when after it was 26 transferred into a vbo 28 27 */ 29 28 Geometry(Vector3 *vertices, … … 31 30 Texcoord2 *texcoords, 32 31 int numVertices, 33 bool delData); 34 32 bool delData, 33 Vector3 *tangents); 34 /** Detructor destroying the opengl resources. 35 */ 35 36 ~Geometry(); 36 37 /** Render the geometry 37 38 */ 38 39 void Render(RenderState *state); 39 40 int GetNumTriangles() const { return mNumVertices / 3; } 41 40 /** Return bounding box. 41 */ 42 const AxisAlignedBox3& GetBoundingBox() const; 43 /** Returns the number of triangles in this geometry. 44 */ 45 inline int GetNumTriangles() const { return mNumVertices / 3; } 46 /** Returns true if this geometry has a texture 47 */ 42 48 inline bool HasTexture() const { return mHasTexture; } 43 49 44 const AxisAlignedBox3& GetBoundingBox() const;45 50 46 51 protected: 47 52 /** Calculates the bounding box from the vertices. 53 */ 48 54 void CalcBoundingBox(); 49 55 /** Prepare vbos for rendering … … 58 64 Vector3 *mNormals; 59 65 66 Vector3 *mTangents; 67 60 68 Texcoord2 *mTexCoords; 61 69 … … 67 75 68 76 bool mHasTexture; 77 78 bool mHasTangents; 69 79 }; 70 80 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3117 r3126 236 236 237 237 238 // set texture for fixed function rendering 239 if (tex) 240 { 241 if (mCurrentTexId != tex->GetId()) 242 { 243 tex->Bind(); 244 mCurrentTexId = tex->GetId(); 245 } 246 } 247 else 248 { 249 mCurrentTexId = -1; 250 glBindTexture(GL_TEXTURE_2D, 0); 251 } 252 253 238 254 ////////////////// 239 255 //-- fragment and vertex programs … … 292 308 } 293 309 } 294 295 if (!mFragmentProgramEnabled)296 {297 // set texture for fixed function rendering298 if (tex)299 {300 if (mCurrentTexId != tex->GetId())301 {302 tex->Bind();303 mCurrentTexId = tex->GetId();304 }305 }306 else307 {308 mCurrentTexId = -1;309 glBindTexture(GL_TEXTURE_2D, 0);310 }311 }312 310 } 313 311 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3115 r3126 292 292 293 293 if (deferred->GetTexture()) 294 {295 294 deferred->SetFragmentProgram(sDefaultFragmentTexProgramMrt); 296 deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0);297 deferred->GetFragmentProgramParameters()->SetTexture(1, tech->GetTexture()->GetId());298 }299 295 else 300 {301 296 deferred->SetFragmentProgram(sDefaultFragmentProgramMrt); 302 deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0); 303 }297 298 deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0); 304 299 305 300 deferred->SetVertexProgram(sDefaultVertexProgramMrt); … … 361 356 } 362 357 363 return new Geometry(vertices, normals, texcoords, vertexCount, true );358 return new Geometry(vertices, normals, texcoords, vertexCount, true, NULL); 364 359 //return new Geometry(vertices, normals, texcoords, vertexCount, false); 365 360 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.cpp
r3071 r3126 41 41 cout << "number of triangles in box: " << (int)triangles.size() << endl; 42 42 43 Geometry *geom = new Geometry(vertices, normals, NULL, 36, false );43 Geometry *geom = new Geometry(vertices, normals, NULL, 36, false, NULL); 44 44 45 45 Shape *shape = new Shape(geom, mat); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp
r3116 r3126 100 100 101 101 // add a texture parameter 102 fragmentProgMrtTex->AddParameter("tex", 1);102 //fragmentProgMrtTex->AddParameter("tex", 1); 103 103 104 104 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3123 r3126 124 124 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 125 125 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y)); 126 ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y));127 //ao.x = BilateralFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f);126 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y)); 127 ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f); 128 128 } 129 129 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3118 r3126 75 75 76 76 pixel fragtex(fragin IN, 77 uniform sampler2D tex ,77 uniform sampler2D tex: TEXUNIT0, 78 78 uniform float4x4 viewMatrix 79 79 )
Note: See TracChangeset
for help on using the changeset viewer.