- Timestamp:
- 11/10/08 10:10:50 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r3068 r3114 61 61 62 62 63 void Technique::Render(RenderState *state )63 void Technique::Render(RenderState *state, SceneEntity *ent) 64 64 { 65 65 glMaterialfv(GL_FRONT, GL_AMBIENT, (float *)&mAmbientColor.r); … … 68 68 glMaterialfv(GL_FRONT, GL_SPECULAR, (float *)&mSpecularColor.r); 69 69 70 state->SetState(this );70 state->SetState(this, ent); 71 71 } 72 72 … … 94 94 95 95 96 void Material::Render(RenderState *state )96 void Material::Render(RenderState *state, SceneEntity *parent) 97 97 { 98 98 // set technique if available 99 99 int idx = min((int)mTechniques.size() - 1 , state->GetRenderTechnique()); 100 mTechniques[idx]->Render(state );100 mTechniques[idx]->Render(state, parent); 101 101 } 102 102 … … 117 117 { 118 118 Technique *tech = new Technique(); 119 120 119 mTechniques.push_back(tech); 121 120 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
r3065 r3114 48 48 class Technique 49 49 { 50 50 51 friend class ResourceManager; 51 52 friend class RenderQueue; 53 friend class Material; 52 54 53 55 public: … … 61 63 /** Renders this technique. 62 64 */ 63 void Render(RenderState *state );65 void Render(RenderState *state, SceneEntity *parent = NULL); 64 66 /** Initialize this technique material with default values 65 67 */ … … 126 128 ShaderProgram *mFragmentProgram; 127 129 ShaderProgram *mVertexProgram; 130 128 131 /// if this material can write colors 129 132 bool mColorWriteEnabled; … … 149 152 /** Renders this material. 150 153 */ 151 void Render(RenderState *state );154 void Render(RenderState *state, SceneEntity *parent); 152 155 153 156 void AddTechnique(Technique *t); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r3110 r3114 196 196 197 197 if (ent) ent->Prepare(mState); 198 shape->Render(mState );198 shape->Render(mState, ent); 199 199 if (ent) ent->GetTransform()->Unload(mState); 200 200 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r3074 r3114 136 136 137 137 138 void RenderState::SetState(Technique *tech) 139 { 140 if (mCurrentTechnique == tech) 141 return; 138 void RenderState::SetState(Technique *tech, SceneEntity *ent) 139 { 140 //if (mCurrentTechnique == tech) return; 142 141 143 142 mCurrentTechnique = tech; … … 152 151 const bool depthWrite = tech->IsDepthWriteEnabled(); 153 152 153 154 154 if (mDepthWriteEnabled && !depthWrite) 155 155 { … … 256 256 } 257 257 258 tech->GetFragmentProgramParameters()->UpdateParameters( );258 tech->GetFragmentProgramParameters()->UpdateParameters(ent); 259 259 } 260 260 else … … 267 267 } 268 268 269 ShaderProgram *v ert= tech->GetVertexProgram();270 271 if (v ert)269 ShaderProgram *vtx = tech->GetVertexProgram(); 270 271 if (vtx) 272 272 { 273 273 if (!mVertexProgramEnabled) … … 277 277 } 278 278 279 if (v ert!= mCurrentVertexProgram)280 { 281 mCurrentVertexProgram = v ert;279 if (vtx != mCurrentVertexProgram) 280 { 281 mCurrentVertexProgram = vtx; 282 282 mCurrentVertexProgram->Bind(); 283 283 } 284 284 285 tech->GetVertexProgramParameters()->UpdateParameters( );285 tech->GetVertexProgramParameters()->UpdateParameters(ent); 286 286 } 287 287 else -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.h
r3068 r3114 33 33 */ 34 34 bool SetMode(Mode mode); 35 /** Sets the current render state .35 /** Sets the current render state with the current technique + scene entity 36 36 */ 37 void SetState(Technique *tech );37 void SetState(Technique *tech, SceneEntity *ent = NULL); 38 38 /** Returns the current render state. 39 39 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r3113 r3114 304 304 deferred->SetVertexProgram(sDefaultVertexProgramMrt); 305 305 306 static Matrix4x4 identity = IdentityMatrix(); 307 308 // default values: these are only updated for dynamic objects 309 deferred->GetVertexProgramParameters()->SetMatrix(1, identity); 310 deferred->GetVertexProgramParameters()->SetMatrix(2, identity); 306 deferred->GetVertexProgramParameters()->SetModelMatrixParam(1); 307 deferred->GetVertexProgramParameters()->SetOldModelMatrixParam(2); 311 308 312 309 mat->AddTechnique(deferred); … … 317 314 318 315 Technique *depthPass = new Technique(*tech); 316 319 317 depthPass->SetColorWriteEnabled(false); 320 318 depthPass->SetLightingEnabled(false); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r3113 r3114 100 100 101 101 for (; sit != sit_end; ++ sit) 102 (*sit)->Render(state );102 (*sit)->Render(state, this); 103 103 104 104 mTransform->Unload(state); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderManager.cpp
r3113 r3114 91 91 fragmentProgMrtTex->AddParameter("viewMatrix", 0); 92 92 93 94 // vertex program 93 95 vertexProgMrt->AddParameter("viewMatrix", 0); 94 95 // these parameters are used for ssao 96 // needed for for ssao 96 97 vertexProgMrt->AddParameter("modelMatrix", 1); 97 98 vertexProgMrt->AddParameter("oldModelMatrix", 2); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.cpp
r3113 r3114 5 5 #include "Camera.h" 6 6 #include "Light.h" 7 7 #include "SceneEntity.h" 8 #include "Transform3.h" 8 9 9 10 using namespace std; … … 32 33 mViewDirParam(-1), 33 34 mViewMatrixParam(-1), 34 mLightDirParam(-1) 35 mLightDirParam(-1), 36 mModelMatrixParam(-1), 37 mOldModelMatrixParam(-1) 35 38 { 36 39 } … … 42 45 mViewDirParam(-1), 43 46 mViewMatrixParam(-1), 44 mLightDirParam(-1) 47 mLightDirParam(-1), 48 mModelMatrixParam(-1), 49 mOldModelMatrixParam(-1) 45 50 { 46 51 } … … 59 64 mLightDirParam = -1; 60 65 mViewMatrixParam = -1; 66 67 mModelMatrixParam = -1; 68 mOldModelMatrixParam = -1; 61 69 } 62 70 … … 171 179 172 180 181 void GPUProgramParameters::SetModelMatrixParam(int idx) 182 { 183 mModelMatrixParam = idx; 184 } 185 186 187 void GPUProgramParameters::SetOldModelMatrixParam(int idx) 188 { 189 mOldModelMatrixParam = idx; 190 } 191 192 173 193 void GPUProgramParameters::SetValue1f(const string &name, float val) 174 194 { … … 225 245 226 246 227 void GPUProgramParameters::UpdateParameters( )247 void GPUProgramParameters::UpdateParameters(SceneEntity *ent) 228 248 { 229 249 if (!mProgram) return; … … 305 325 if (mViewMatrixParam >= 0) 306 326 mProgram->SetMatrix(mViewMatrixParam, sCurrentViewMatrix); 327 328 if (ent) 329 { 330 if (mModelMatrixParam >= 0) 331 mProgram->SetMatrix(mModelMatrixParam, ent->GetTransform()->GetMatrix()); 332 if (mOldModelMatrixParam >= 0) 333 mProgram->SetMatrix(mOldModelMatrixParam, ent->GetTransform()->GetOldMatrix()); 334 } 307 335 } 308 336 … … 347 375 348 376 for (int i = 0; i < maxParams; ++ i) 349 {350 377 mParameters[i] = NULL; 351 }352 378 } 353 379 … … 391 417 { 392 418 for (int i = 0; i < numElements; ++ i) 393 {394 419 AddParameter(params[i], startIdx + i); 395 }396 420 } 397 421 … … 403 427 404 428 if (it == mParamHash.end()) 405 {406 429 p = cgGetNamedParameter(mProgram, name.c_str()); 407 }408 430 else 409 {410 431 p = mParameters[(*it).second]; 411 }412 432 413 433 //cout << "name: " << name << " " << p << " " << mProgram << endl; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShaderProgram.h
r3113 r3114 34 34 */ 35 35 GPUProgramParameters(); 36 37 /** Constructor which initialized this parameter set for a given program. 36 /** Constructor which initializes this parameter set for a given program. 38 37 */ 39 38 GPUProgramParameters(ShaderProgram *p); 40 39 /** Sets the assoziated program (a 1:n relationship) 40 */ 41 41 void SetProgram(ShaderProgram *p) { mProgram = p; } 42 42 /** Resets this parameter set. … … 84 84 */ 85 85 void SetLightDirParam(int idx); 86 87 86 /** This parameter is connected to the current light direction 87 that is updated once per frame. 88 */ 89 void SetModelMatrixParam(int idx); 90 /** This parameter is connected to the current light direction 91 that is updated once per frame. 92 */ 93 void SetOldModelMatrixParam(int idx); 94 95 88 96 89 97 /////////// … … 110 118 /** Feeds the shader program with the parameter values. 111 119 */ 112 void UpdateParameters( );120 void UpdateParameters(SceneEntity *ent = NULL); 113 121 /** Function should be called once per frame to update frame related parameters. 114 122 */ … … 190 198 int mLightDirParam; 191 199 int mViewMatrixParam; 200 int mModelMatrixParam; 201 int mOldModelMatrixParam; 192 202 193 203 std::vector<FloatParam> mFloats; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r3074 r3114 24 24 25 25 26 void Shape::Render(RenderState *state )26 void Shape::Render(RenderState *state, SceneEntity *ent) 27 27 { 28 if (mMaterial) mMaterial->Render(state );28 if (mMaterial) mMaterial->Render(state, ent); 29 29 30 30 mGeometry->Render(state); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
r3072 r3114 34 34 /** Renders this node. 35 35 */ 36 void Render(RenderState *state );36 void Render(RenderState *state, SceneEntity *ent = NULL); 37 37 /** Set pointer to the geometry 38 38 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
r3089 r3114 14 14 15 15 16 Transform3::Transform3(const Matrix4x4 &trafo): mMatrix(trafo) 16 Transform3::Transform3(const Matrix4x4 &trafo): 17 mMatrix(trafo), mOldMatrix(trafo) 17 18 { 18 19 mIsIdentity = false; … … 32 33 void Transform3::Unload(RenderState *state) 33 34 { 34 if (!mIsIdentity) 35 { 36 glPopMatrix(); 37 } 35 if (!mIsIdentity) glPopMatrix(); 38 36 } 39 37 … … 42 40 { 43 41 mIsIdentity = false; 42 mOldMatrix = mMatrix; 44 43 mMatrix = mMatrix * trafo; 45 44 } … … 50 49 mIsIdentity = true; 51 50 mMatrix = IdentityMatrix(); 51 mOldMatrix = mMatrix; 52 52 } 53 53 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.h
r3113 r3114 30 30 */ 31 31 void Unload(RenderState *state); 32 /** Returns the trafo matrix.33 */34 inline Matrix4x4 GetMatrix() const { return mMatrix; }35 /** Returns pointer to trafo matrix36 */37 inline const Matrix4x4 *GetPMatrix() const { return &mMatrix; }38 /** See Get39 */40 inline void SetMatrix(const Matrix4x4 &trafo) { mIsIdentity = false; mMatrix = trafo; }41 32 /** Right multiplies with the given matrix. 42 33 */ … … 45 36 */ 46 37 void Reset(); 38 /** Returns the trafo matrix. 39 */ 40 inline Matrix4x4 GetMatrix() const { return mMatrix; } 41 /** See Get 42 */ 43 inline void SetMatrix(const Matrix4x4 &trafo) ; 44 /** Returns the old trafo matrix. 45 */ 46 inline Matrix4x4 GetOldMatrix() const { return mOldMatrix; } 47 47 /** Returns true if this transformation is the identity. 48 48 */ … … 54 54 /// transform matrix 55 55 Matrix4x4 mMatrix; 56 /// the previous transformation matrix 57 Matrix4x4 mOldMatrix; 56 58 /// if this matrix is still the identity matrix 57 59 bool mIsIdentity; … … 59 61 60 62 63 void Transform3::SetMatrix(const Matrix4x4 &trafo) 64 { 65 mIsIdentity = false; 66 mOldMatrix = mMatrix; 67 mMatrix = trafo; 68 } 69 70 61 71 } 62 72 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3113 r3114 908 908 909 909 oldTrafo = buddha->GetTransform()->GetMatrix(); 910 vtxParams->SetMatrix(2, oldTrafo);910 //vtxParams->SetMatrix(2, oldTrafo); 911 911 912 912 Vector3 buddhaPos = motionPath->GetCurrentPosition(); … … 915 915 buddha->GetTransform()->SetMatrix(trafo); 916 916 917 vtxParams->SetMatrix(1, buddha->GetTransform()->GetMatrix());917 //vtxParams->SetMatrix(1, buddha->GetTransform()->GetMatrix()); 918 918 919 919 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3113 r3114 110 110 const float projectedEyeSpaceDepth = length(translatedPos) * invlen; 111 111 112 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 5.0f) ? 0 : abs(oldEyeSpaceDepth - projectedEyeSpaceDepth); 112 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 5.0f) ? 113 0 : abs(oldEyeSpaceDepth - projectedEyeSpaceDepth); 113 114 114 115 return depthDif;
Note: See TracChangeset
for help on using the changeset viewer.