- Timestamp:
- 09/19/08 11:41:18 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 3 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r2954 r2957 196 196 > 197 197 <File 198 RelativePath=".\src\AxisAlignedBox3.cpp"199 >200 </File>201 <File202 198 RelativePath=".\src\BvhLoader.cpp" 203 199 > … … 224 220 </File> 225 221 <File 226 RelativePath=".\src\FrameBufferObject.cpp"227 >228 </File>229 <File230 RelativePath=".\src\FrameBufferObject.h"231 >232 </File>233 <File234 222 RelativePath=".\src\glfont2.cpp" 235 223 > … … 252 240 </File> 253 241 <File 254 RelativePath=".\src\Halton.cpp"255 >256 </File>257 <File258 RelativePath=".\src\Halton.h"259 >260 </File>261 <File262 RelativePath=".\src\Matrix4x4.cpp"263 >264 </File>265 <File266 RelativePath=".\src\Matrix4x4.h"267 >268 </File>269 <File270 242 RelativePath=".\src\MotionPath.cpp" 271 243 > … … 276 248 </File> 277 249 <File 250 RelativePath=".\src\ObjConverter.cpp" 251 > 252 </File> 253 <File 254 RelativePath=".\src\ObjConverter.h" 255 > 256 </File> 257 <File 278 258 RelativePath=".\src\PerformanceGraph.cpp" 279 259 > … … 284 264 </File> 285 265 <File 286 RelativePath=".\src\Plane3.cpp"287 >288 </File>289 <File290 RelativePath=".\src\Plane3.h"291 >292 </File>293 <File294 RelativePath=".\src\Polygon3.cpp"295 >296 </File>297 <File298 RelativePath=".\src\Polygon3.h"299 >300 </File>301 <File302 RelativePath=".\src\Polyhedron.cpp"303 >304 </File>305 <File306 RelativePath=".\src\Polyhedron.h"307 >308 </File>309 <File310 266 RelativePath=".\src\SampleGenerator.cpp" 311 267 > … … 324 280 </File> 325 281 <File 326 RelativePath=".\src\SceneQuery.cpp"327 >328 </File>329 <File330 RelativePath=".\src\SceneQuery.h"331 >332 </File>333 <File334 282 RelativePath=".\src\shaderenv.h" 335 283 > 336 284 </File> 337 285 <File 338 RelativePath=".\src\ShadowMapping.cpp"339 >340 </File>341 <File342 RelativePath=".\src\ShadowMapping.h"343 >344 </File>345 <File346 286 RelativePath=".\src\SkyPreetham.cpp" 347 287 > … … 357 297 <File 358 298 RelativePath=".\src\SunColor.h" 359 >360 </File>361 <File362 RelativePath=".\src\Triangle3.cpp"363 >364 </File>365 <File366 RelativePath=".\src\Triangle3.h"367 >368 </File>369 <File370 RelativePath=".\src\Vector3.cpp"371 >372 </File>373 <File374 RelativePath=".\src\Vector3.h"375 299 > 376 300 </File> … … 579 503 </File> 580 504 <File 505 RelativePath=".\src\FrameBufferObject.h" 506 > 507 </File> 508 <File 581 509 RelativePath=".\src\Geometry.h" 582 510 > … … 612 540 <File 613 541 RelativePath=".\src\SceneEntity.h" 542 > 543 </File> 544 <File 545 RelativePath=".\src\SceneQuery.h" 546 > 547 </File> 548 <File 549 RelativePath=".\src\ShadowMapping.h" 614 550 > 615 551 </File> … … 689 625 </File> 690 626 <File 627 RelativePath=".\src\FrameBufferObject.cpp" 628 > 629 </File> 630 <File 691 631 RelativePath=".\src\Geometry.cpp" 692 632 > … … 772 712 <File 773 713 RelativePath=".\src\SceneEntity.cpp" 714 > 715 </File> 716 <File 717 RelativePath=".\src\SceneQuery.cpp" 718 > 719 </File> 720 <File 721 RelativePath=".\src\ShadowMapping.cpp" 774 722 > 775 723 </File> … … 848 796 </File> 849 797 <File 798 RelativePath=".\src\shaders\sky_preetham.cg" 799 > 800 </File> 801 <File 850 802 RelativePath=".\src\shaders\ssao.cg" 851 803 > … … 853 805 <File 854 806 RelativePath=".\src\shaders\ssao3d.cg" 807 > 808 </File> 809 </Filter> 810 <Filter 811 Name="math" 812 > 813 <File 814 RelativePath=".\src\AxisAlignedBox3.cpp" 815 > 816 </File> 817 <File 818 RelativePath=".\src\Halton.cpp" 819 > 820 </File> 821 <File 822 RelativePath=".\src\Halton.h" 823 > 824 </File> 825 <File 826 RelativePath=".\src\Matrix4x4.cpp" 827 > 828 </File> 829 <File 830 RelativePath=".\src\Matrix4x4.h" 831 > 832 </File> 833 <File 834 RelativePath=".\src\Plane3.cpp" 835 > 836 </File> 837 <File 838 RelativePath=".\src\Plane3.h" 839 > 840 </File> 841 <File 842 RelativePath=".\src\Polygon3.cpp" 843 > 844 </File> 845 <File 846 RelativePath=".\src\Polygon3.h" 847 > 848 </File> 849 <File 850 RelativePath=".\src\Polyhedron.cpp" 851 > 852 </File> 853 <File 854 RelativePath=".\src\Polyhedron.h" 855 > 856 </File> 857 <File 858 RelativePath=".\src\Triangle3.cpp" 859 > 860 </File> 861 <File 862 RelativePath=".\src\Triangle3.h" 863 > 864 </File> 865 <File 866 RelativePath=".\src\Vector3.cpp" 867 > 868 </File> 869 <File 870 RelativePath=".\src\Vector3.h" 855 871 > 856 872 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r2954 r2957 11 11 camPosition=483.398f 242.364f 186.078f 12 12 camDirection=1 0 0 13 lightDirection=-0.8f 1.0f -0.7f13 #lightDirection=-0.8f 1.0f -0.7f 14 14 #lightDirection=0.2f -1.0f -.5f 15 lightDirection=0.0f 0.0f -1.0f 15 16 useFullScreen=0 16 17 useLODs=1 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r2952 r2957 90 90 int mHeight; 91 91 92 /// this is just a scale factor for the scene depthin order to get better float precision in the shader92 /// a scale factor of scene positions in order to get better float precision in the shader 93 93 float mScaleFactor; 94 94 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h
r2899 r2957 8 8 namespace CHCDemoEngine 9 9 { 10 11 12 10 13 11 /** This class implements a wrapper for a color buffer object -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
r2844 r2957 43 43 public: 44 44 45 /** Sets default material (ambient intensity 0.2f, diffuse intensity 1.0f) 46 */ 45 47 Material(); 46 48 49 /** Sets ambient and diffuse color to color 50 */ 47 51 Material(const RgbaColor &color); 48 52 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp
r2953 r2957 36 36 bool hasTrafo; 37 37 str.read(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 38 39 Matrix4x4 *m;40 38 41 39 SceneEntity *sceneGeom; 40 Transform3 *trafo; 42 41 43 42 if (!hasTrafo) 44 43 { 45 m = NULL;44 trafo = new Transform3(); 46 45 } 47 46 else 48 47 { 49 m = new Matrix4x4(); 50 str.read(reinterpret_cast<char *>(m->x), sizeof(Matrix4x4)); 51 } 52 53 Transform3 *trafo = new Transform3(m); 48 Matrix4x4 m; 49 str.read(reinterpret_cast<char *>(m.x), sizeof(Matrix4x4)); 50 51 trafo = new Transform3(m); 52 } 53 54 54 mTrafos.push_back(trafo); 55 55 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r2865 r2957 152 152 AxisAlignedBox3 SceneEntity::GetTransformedBoundingBox() const 153 153 { 154 Matrix4x4 *mat = mTransform->GetMatrix(); 155 156 if (!mat) 154 if (mTransform->IsIdentity()) 157 155 return mBox; 158 156 159 return Transform(mBox, *mat); 157 Matrix4x4 mat = mTransform->GetMatrix(); 158 159 return Transform(mBox, mat); 160 160 } 161 161 … … 169 169 Vector3 SceneEntity::GetCenter() const 170 170 { 171 Matrix4x4 *mat = mTransform->GetMatrix(); 171 if (mTransform->IsIdentity()) 172 return mCenter; 172 173 173 if (!mat) return mCenter;174 Matrix4x4 mat = mTransform->GetMatrix(); 174 175 175 return (*mat)* mCenter;176 return mat * mCenter; 176 177 } 177 178 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp
r2953 r2957 156 156 157 157 glDisable(GL_CULL_FACE); 158 159 glShadeModel(GL_FLAT);160 158 glEnable(GL_DEPTH_TEST); 161 159 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r2867 r2957 56 56 AxisAlignedBox3 Shape::GetTransformedBoundingBox() const 57 57 { 58 Matrix4x4 *mat = mParent->GetTransform()->GetMatrix(); 59 60 if (!mat) 58 if (mParent->GetTransform()->IsIdentity()) 61 59 return mGeometry->GetBoundingBox(); 62 60 63 return Transform(mGeometry->GetBoundingBox(), *mat); 61 Matrix4x4 mat = mParent->GetTransform()->GetMatrix(); 62 63 return Transform(mGeometry->GetBoundingBox(), mat); 64 64 } 65 65 … … 67 67 Vector3 Shape::GetCenter() const 68 68 { 69 Matrix4x4 *mat = mParent->GetTransform()->GetMatrix(); 69 if (mParent->GetTransform()->IsIdentity()) 70 return mCenter; 70 71 71 if (!mat) return mCenter;72 Matrix4x4 mat = mParent->GetTransform()->GetMatrix(); 72 73 73 return (*mat)* mCenter;74 return mat * mCenter; 74 75 } 75 76 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r2956 r2957 2 2 #include "common.h" 3 3 #include "Vector3.h" 4 5 6 //#include <rendering/effect/FEffect.h> 7 //#include <rendering/FVertexbuffer.h> 4 #include "SceneEntity.h" 5 #include "Transform3.h" 6 #include "Camera.h" 7 #include "RenderState.h" 8 9 using namespace CHCDemoEngine; 10 using namespace std; 11 12 13 14 static CGprogram sCgSkyProgram = NULL; 15 static CGparameter sLightDirParam; 16 static CGparameter sThetaSunParam; 17 static CGparameter sZenithColorParam; 18 static CGparameter sAColorParam; 19 static CGparameter sBColorParam; 20 static CGparameter sCColorParam; 21 static CGparameter sDColorParam; 22 static CGparameter sEColorParam; 8 23 9 24 … … 20 35 21 36 22 using namespace CHCDemoEngine; 23 24 25 SkyPreetham::SkyPreetham(float turbitity): 26 // mEffect(NULL), 27 mTurbidity(turbitity) 28 // mSunEffect(NULL), 29 // mSunTexture(NULL), 37 void SkyPreetham::Init(CGcontext context) 38 { 39 sCgSkyProgram = 40 cgCreateProgramFromFile(context, 41 CG_SOURCE, 42 "src/shaders/sky_preetham.cg", 43 RenderState::sCgVertexProfile, 44 "default_vs", 45 NULL); 46 47 if (sCgSkyProgram != NULL) 48 { 49 cgGLLoadProgram(sCgSkyProgram); 50 51 sLightDirParam = cgGetNamedParameter(sCgSkyProgram, "lightDir"); 52 sThetaSunParam = cgGetNamedParameter(sCgSkyProgram, "thetaSun"); 53 sZenithColorParam = cgGetNamedParameter(sCgSkyProgram, "zenithColor"); 54 sAColorParam = cgGetNamedParameter(sCgSkyProgram, "aColor"); 55 sBColorParam = cgGetNamedParameter(sCgSkyProgram, "bColor"); 56 sCColorParam = cgGetNamedParameter(sCgSkyProgram, "cColor"); 57 sDColorParam = cgGetNamedParameter(sCgSkyProgram, "dColor"); 58 sEColorParam = cgGetNamedParameter(sCgSkyProgram, "eColor"); 59 } 60 else 61 cerr << "sky program failed to load" << endl; 62 } 63 64 65 SkyPreetham::SkyPreetham(float turbitity, SceneEntity *skyDome): 66 mSkyDome(skyDome), 67 mTurbidity(turbitity) 30 68 // mSunQuad(NULL) 31 69 { 32 /* mEffect = D().getScene().getEffect("../effects/sky_preetham.fx");33 34 mVertexBuffer = D().getScene().getVertexBuffer("../models/sky.vbo");35 36 mSunEffect = D().getScene().getEffect("../effects/sky_sun.fx");37 mSunTexture = D().getScene().getTexture2D("../textures/sky_sun.png");38 */39 70 CreateSunQuad(); 40 71 } … … 47 78 48 79 49 50 void SkyPreetham::Compute(const Vector3 &sunDir) 80 void SkyPreetham::Compute(const Vector3 &sunDir, Camera *camera, RenderState *state) 51 81 { 52 82 float sun_theta[2]; 53 83 54 sun_theta[0] = acos(sunDir.y); 55 56 const float cos_theta = cos(sun_theta[0]); 84 //sun_theta[0] = acos(sunDir.y); 85 sun_theta[0] = acos(sunDir.z); 86 87 const float cos_theta = cos(sun_theta[0]); 57 88 sun_theta[1] = cos_theta * cos_theta; 58 89 … … 93 124 ABCDE_Y[4] = -0.06696 * mTurbidity + 0.37027; 94 125 95 /* 96 F().getRenderDevice().setDefaultDepthStencilMode(FRenderDevice::DEPTHSTENCIL_TEST_NO_OVERWRITE); 126 //F().getRenderDevice().setDefaultDepthStencilMode(FRenderDevice::DEPTHSTENCIL_TEST_NO_OVERWRITE); 97 127 98 128 // Move skybox with camera. 99 mPosition = D().getScene().getCamera().getPosition(); 100 101 mPosition.y -= 2.0; 102 103 setTransform(); 104 105 mEffect->setVariableVector3("LightDirection", D().getScene().getLight().getDirection()); 129 Vector3 position = camera->GetPosition(); 130 131 132 const float scaleFactor = 100.0f; 133 134 position.z -= 10 * scaleFactor; 135 Matrix4x4 m = TranslationMatrix(position); 136 137 Matrix4x4 s = ScaleMatrix(scaleFactor, scaleFactor, scaleFactor); 138 mSkyDome->GetTransform()->SetMatrix(s * m); 139 140 141 cgGLSetParameter3f(sLightDirParam, sunDir.x, sunDir.y, sunDir.z); 142 cgGLSetParameter2f(sThetaSunParam, sun_theta[0], sun_theta[1]); 143 cgGLSetParameter3f(sZenithColorParam, zenithColor.x, zenithColor.y, zenithColor.z); 144 145 cgGLSetParameter3f(sAColorParam, ABCDE_x[0], ABCDE_y[0], ABCDE_Y[0]); 146 cgGLSetParameter3f(sBColorParam, ABCDE_x[1], ABCDE_y[1], ABCDE_Y[1]); 147 cgGLSetParameter3f(sCColorParam, ABCDE_x[2], ABCDE_y[2], ABCDE_Y[2]); 148 cgGLSetParameter3f(sDColorParam, ABCDE_x[3], ABCDE_y[3], ABCDE_Y[3]); 149 cgGLSetParameter3f(sEColorParam, ABCDE_x[4], ABCDE_y[4], ABCDE_Y[4]); 150 151 /*mEffect->setVariableVector3("LightDirection", D().getScene().getLight().getDirection()); 106 152 mEffect->setVariableVector2("ThetaSun", sun_theta); 107 153 mEffect->setVariableVector3("ZenithColor", zenithColor); … … 111 157 mEffect->setVariableVector3("DColor",FVector3((FFloat)ABCDE_x[3], (FFloat)ABCDE_y[3], (FFloat)ABCDE_Y[3])); 112 158 mEffect->setVariableVector3("EColor",FVector3((FFloat)ABCDE_x[4], (FFloat)ABCDE_y[4], (FFloat)ABCDE_Y[4])); 113 114 115 mEffect->activate(); 116 117 F().getRenderDevice().setDefaultPolygonMode(true, FRenderDevice::CULL_NONE); 159 */ 160 161 cgGLEnableProfile(RenderState::sCgVertexProfile); 162 cgGLBindProgram(sCgSkyProgram); 118 163 119 164 // Render sky dome. 120 m VertexBuffer->render();165 mSkyDome->Render(state); 121 166 122 167 // Render additively blended sun disc. 123 renderSunDisk(); 124 125 F().getRenderDevice().setDefaultPolygonMode(true, FRenderDevice::CULL_BACKFACES); 126 127 128 F().getRenderDevice().setDefaultDepthStencilMode(FRenderDevice::DEPTHSTENCIL_TEST_AND_OVERWRITE); 129 */ 168 RenderSunDisk(); 130 169 } 131 170 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.h
r2955 r2957 1 1 #ifndef _SKYPREETHAM_H__ 2 2 #define _SKYPREETHAM_H__ 3 4 #include "glInterface.h" 5 6 #include <Cg/cg.h> 7 #include <Cg/cgGL.h> 3 8 4 9 5 10 namespace CHCDemoEngine{ 6 11 class Vector3; 12 class SceneEntity; 13 class RenderState; 14 class Camera; 7 15 } 8 16 … … 10 18 { 11 19 public: 12 // Constructor and destructor.13 SkyPreetham(float turbitity );20 /// Constructor taking sky turbitity as parameter and the sky dome geometry 21 SkyPreetham(float turbitity, CHCDemoEngine::SceneEntity *skyDome); 14 22 virtual ~SkyPreetham(); 15 23 16 void Compute(const CHCDemoEngine::Vector3 &sunDir); 24 void Compute(const CHCDemoEngine::Vector3 &sunDir, CHCDemoEngine::Camera *camera, CHCDemoEngine::RenderState *state); 25 26 static void Init(CGcontext context); 17 27 18 28 protected: … … 29 39 FVertexBuffer* mSunQuad; 30 40 */ 41 CHCDemoEngine::SceneEntity *mSkyDome; 42 31 43 float mTurbidity; 32 44 }; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SunColor.cpp
r2955 r2957 5 5 6 6 using namespace CHCDemoEngine; 7 using namespace std; 7 8 8 9 … … 24 25 25 26 // sunDir is sun direction 26 // ambient color :shadow color27 // diffuse color :sun color27 // ambient color: shadow color 28 // diffuse color: sun color 28 29 29 30 float sun_theta[2]; 30 31 31 sun_theta[0] = acos(sunDir. y);32 sun_theta[0] = acos(sunDir.z); 32 33 33 const float cos_theta = 34 const float cos_theta = cos(sun_theta[0]); 34 35 sun_theta[1] = cos_theta * cos_theta; 35 36 … … 66 67 67 68 // simulate the sun intensity by modulating the ambient term. 68 ambient *= (1.0f - 0.9 0f * DotProd(sunDir, Vector3(0, 1, 0)));69 ambient *= (1.0f - 0.9f * DotProd(sunDir, Vector3::UNIT_Z())); 69 70 ambient += Vector3(0.2f); 70 71 … … 91 92 Vector3 num; 92 93 93 num.x = (1.0f + ABCDE_x[0] * exp( ABCDE_x[1] / sunDir. y)) * (1.0f + ABCDE_x[2])+ ABCDE_x[4];94 num.y = (1.0f + ABCDE_y[0] * exp( ABCDE_y[1] / sunDir. y)) * (1.0f + ABCDE_y[2])+ ABCDE_y[4];95 num.z = (1.0f + ABCDE_Y[0] * exp( ABCDE_Y[1] / sunDir. y)) * (1.0f + ABCDE_Y[2])+ ABCDE_Y[4];94 num.x = (1.0f + ABCDE_x[0] * exp( ABCDE_x[1] / sunDir.z )) * (1.0f + ABCDE_x[2])+ ABCDE_x[4]; 95 num.y = (1.0f + ABCDE_y[0] * exp( ABCDE_y[1] / sunDir.z )) * (1.0f + ABCDE_y[2])+ ABCDE_y[4]; 96 num.z = (1.0f + ABCDE_Y[0] * exp( ABCDE_Y[1] / sunDir.z )) * (1.0f + ABCDE_Y[2])+ ABCDE_Y[4]; 96 97 97 98 … … 103 104 104 105 105 Vector3 xyY = num / den* zenithColor;106 Vector3 xyY = (num / den) * zenithColor; 106 107 107 108 Vector3 XYZ; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.cpp
r2955 r2957 1 1 #include "Transform3.h" 2 #include "Matrix4x4.h"3 2 #include "RenderState.h" 4 3 … … 10 9 11 10 12 Transform3::Transform3( Matrix4x4 *trafo): mMatrix(trafo)11 Transform3::Transform3(const Matrix4x4 &trafo): mMatrix(trafo) 13 12 { 13 mIsIdentity = false; 14 14 } 15 15 16 16 17 Transform3:: ~Transform3()17 Transform3::Transform3() 18 18 { 19 DEL_PTR(mMatrix);19 Reset(); 20 20 } 21 21 … … 23 23 void Transform3::Load(RenderState *state) 24 24 { 25 if ( !mMatrix) return;25 if (mIsIdentity) return; 26 26 27 27 if (state->GetRenderPassType() == RenderState::DEFERRED) 28 28 { 29 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix ->x);29 cgGLSetMatrixParameterfc(sModelMatrixParam, (const float *)mMatrix.x); 30 30 } 31 31 32 32 glPushMatrix(); 33 glMultMatrixf((float *)mMatrix ->x);33 glMultMatrixf((float *)mMatrix.x); 34 34 } 35 35 … … 37 37 void Transform3::Unload(RenderState *state) 38 38 { 39 if ( !mMatrix) return;39 if (mIsIdentity) return; 40 40 41 41 if (state->GetRenderPassType() == RenderState::DEFERRED) … … 48 48 } 49 49 50 51 void Transform3::MultMatrix(const Matrix4x4 &trafo) 52 { 53 mIsIdentity = false; 54 mMatrix = mMatrix * trafo; 50 55 } 56 57 58 void Transform3::Reset() 59 { 60 mIsIdentity = true; 61 mMatrix = IdentityMatrix(); 62 } 63 64 65 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Transform3.h
r2952 r2957 2 2 #define __TRANSFORM3_H 3 3 4 #include "Matrix4x4.h" 4 5 #include "glInterface.h" 5 6 #include "common.h" … … 12 13 13 14 class RenderState; 14 class Matrix4x4;15 15 16 16 17 /** Class representing a transformation17 /** Class representing a wrapper class for a 3D transformation 18 18 */ 19 19 class Transform3 … … 21 21 public: 22 22 23 /** Creates a scene entity.23 /** Creates a transformation. 24 24 */ 25 Transform3(Matrix4x4 *trafo); 26 27 ~Transform3(); 25 Transform3(const Matrix4x4 &trafo); 26 /** The identity transformation. 27 */ 28 Transform3(); 28 29 /** Loads this transformation. 29 30 */ … … 32 33 */ 33 34 void Unload(RenderState *state); 34 /** Returns the trafo of this scene entity.35 /** Returns the trafo matrix. 35 36 */ 36 inline Matrix4x4 *GetMatrix() const { return mMatrix; } 37 inline Matrix4x4 GetMatrix() const { return mMatrix; } 38 /** See Get 39 */ 40 inline void SetMatrix(const Matrix4x4 &trafo) { mMatrix = trafo; } 41 /** Right multiplies with the given matrix. 42 */ 43 inline void MultMatrix(const Matrix4x4 &trafo); 44 /** Resets trafo to identiy. 45 */ 46 void Reset(); 47 /** Returns true if this transformation is the identity. 48 */ 49 inline bool IsIdentity() const { return mIsIdentity; } 37 50 38 51 static CGparameter sModelMatrixParam; … … 41 54 42 55 /// transform matrix 43 Matrix4x4 *mMatrix; 56 Matrix4x4 mMatrix; 57 /// if this matrix is still the identity matrix 58 bool mIsIdentity; 44 59 }; 45 60 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Triangle3.cpp
r2782 r2957 59 59 Vector3 v1 = mVertices[0] - mVertices[1], v2=mVertices[2] - mVertices[1]; 60 60 return 0.5f * Magnitude(CrossProd(v2, v1)); 61 }62 63 64 bool Triangle3::CheckValidity() const65 {66 return !(67 EpsilonEqualV3(mVertices[0], mVertices[1]) ||68 EpsilonEqualV3(mVertices[0], mVertices[2]) ||69 EpsilonEqualV3(mVertices[1], mVertices[2])70 );71 61 } 72 62 … … 135 125 136 126 127 bool Triangle3::Valid() const 128 { 129 const Vector3 a = mVertices[0] - mVertices[1]; 130 const Vector3 b = mVertices[0] - mVertices[2]; 131 const Vector3 cross_a_b = CrossProd(a, b); 132 133 const float eps = 1e-6f; 134 135 if (SqrMagnitude(cross_a_b) <= eps * eps) 136 { 137 // v0, v1 & v2 lies on a line (area == 0) 138 return false; 139 } 140 141 return true; 137 142 } 143 144 145 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Triangle3.h
r2782 r2957 29 29 */ 30 30 AxisAlignedBox3 GetBoundingBox() const; 31 /** Checks if this triangle is ill-defined.32 */33 bool CheckValidity() const;34 31 /** Intersects triangle with plane, returns intersection points 35 32 if intersection is happening. … … 41 38 Vector3 &intersectB) const; 42 39 40 /** Returns false if this triangle is ill-defined, true otherwise 41 */ 42 bool Valid() const; 43 43 44 44 friend std::ostream& operator<< (std::ostream &s, const Triangle3 &A); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2955 r2957 38 38 #include "SceneEntityConverter.h" 39 39 #include "SunColor.h" 40 #include "ObjConverter.h" 41 #include "SkyPreetham.h" 40 42 41 43 … … 91 93 RenderTraverser *shadowTraverser = NULL; 92 94 95 SkyPreetham *preetham = NULL; 96 93 97 94 98 /// these values get scaled with the frame rate … … 166 170 PerfTimer frameTimer, algTimer; 167 171 172 173 168 174 /// the used render type for this render pass 169 175 enum RenderMethod … … 204 210 205 211 SceneEntity *cube = NULL; 212 SceneEntity *aeroplane = NULL; 213 SceneEntity *skyDome = NULL; 206 214 207 215 bool altKeyPressed = false; … … 463 471 464 472 DeferredRenderer::Init(sCgContext); 473 SkyPreetham::Init(sCgContext); 465 474 466 475 … … 649 658 650 659 Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 651 652 660 AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 653 661 654 662 Material *mat = new Material(RgbaColor(1, 0.4, 0.4, 0)); 655 Transform3 *tf = new Transform3( NULL);663 Transform3 *tf = new Transform3(); 656 664 cube = SceneEntityConverter().ConvertBox(box, mat, tf); 665 666 //aeroplane = ObjConverter().Load(model_path + "toyplane.obj"); 667 //if (!aeroplane) cerr << "loadig plane failed" << endl; 668 669 skyDome = ObjConverter().Load(model_path + "sky.obj"); 670 if (!skyDome) cerr << "loadig plane failed" << endl; 671 672 preetham = new SkyPreetham(3.0f, skyDome); 673 657 674 658 675 ////////////////////////////// … … 799 816 800 817 801 SunColor().Compute( h, sunAmbient, sunDiffuse);818 SunColor().Compute(lightDir, sunAmbient, sunDiffuse); 802 819 803 820 const float maxComponent = sunDiffuse.MaxComponent(); … … 896 913 cgGLEnableProfile(RenderState::sCgFragmentProfile); 897 914 cgGLBindProgram(RenderState::sCgMrtFragmentProgram); 898 899 915 } 900 916 … … 1057 1073 else 1058 1074 { 1059 //glEnable(GL_CULL_FACE);1060 //cube->Render(&state);1061 1062 1075 // actually render the scene geometry using the specified algorithm 1063 1076 traverser->RenderScene(); … … 1947 1960 SceneEntityContainer::const_iterator sit, sit_end = skyGeometry.end(); 1948 1961 1949 for (sit = skyGeometry.begin(); sit != sit_end; ++ sit) 1950 (*sit)->Render(&state); 1962 // for (sit = skyGeometry.begin(); sit != sit_end; ++ sit) 1963 // (*sit)->Render(&state); 1964 1965 //cube->Render(&state); 1966 //aeroplane->Render(&state); 1967 glDisable(GL_CULL_FACE); 1968 preetham->Compute(-light->GetDirection(), camera, &state); 1969 glEnable(GL_CULL_FACE); 1970 cgGLDisableProfile(RenderState::sCgVertexProfile); 1951 1971 } 1952 1972 … … 1974 1994 else 1975 1995 { 1976 glShadeModel(GL_SMOOTH);1977 1996 glEnable(GL_LIGHTING); 1978 1979 1997 state.SetRenderPassType(RenderState::FIXED); 1980 1998 } 1981 1999 1982 2000 glShadeModel(GL_SMOOTH); 1983 2001 glEnableClientState(GL_NORMAL_ARRAY); 1984 2002 … … 2011 2029 { 2012 2030 Vector3 playerPos = camera->GetPosition(); 2013 2014 2031 bool validIntersect = sceneQuery->CalcIntersection(playerPos); 2015 2032 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r2952 r2957 52 52 vtxout OUT; 53 53 54 // transform the vertex position into eye space55 54 OUT.color = IN.color; 56 57 55 OUT.texCoord = IN.texCoord; 58 56
Note: See TracChangeset
for help on using the changeset viewer.