- Timestamp:
- 10/29/08 10:19:11 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp
r3062 r3078 1 1 #include "Matrix4x4.h" 2 2 #include "Vector3.h" 3 4 // standard headers5 3 #include "AxisAlignedBox3.h" 6 #include <iomanip> 4 7 5 8 6 using namespace std; 7 9 8 10 9 namespace CHCDemoEngine … … 625 624 for (int j = 0; j < 4; j++) { // x 626 625 // x y 627 s << setprecision(4) << setw(10) <<M.x[j][i];626 s << M.x[j][i]; 628 627 } 629 628 s << '\n'; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/MotionPath.cpp
r2953 r3078 1 1 #include "MotionPath.h" 2 #include "Matrix4x4.h" 2 3 3 4 … … 7 8 8 9 MotionPath::MotionPath(const VertexArray &vertices): 9 mVertices(vertices), mCurrentVertexIdx(0) 10 mVertices(vertices), mCurrentVertexIdx(0), mT(.0f) 10 11 { 11 12 } … … 14 15 void MotionPath::Move(float velocity) 15 16 { 17 mT += velocity; 18 19 if (mT >= 1.0f) 20 { 21 mCurrentVertexIdx = (mCurrentVertexIdx + 1) % (int)mVertices.size(); 22 mT -= 1.0f; 23 } 16 24 } 17 25 … … 19 27 Vector3 MotionPath::GetCurrentPosition() const 20 28 { 21 return mT * mVertices[mCurrentVertexIdx] + (1.0f - mT)* mVertices[(mCurrentVertexIdx + 1) % mVertices.size()];29 return (1.0f - mT) * mVertices[mCurrentVertexIdx] + mT * mVertices[(mCurrentVertexIdx + 1) % mVertices.size()]; 22 30 } 23 31 … … 32 40 { 33 41 mCurrentVertexIdx = 0; 42 mT = 0; 43 } 44 45 46 Matrix4x4 MotionPath::GetOrientation() 47 { 48 Vector3 dir = mVertices[(mCurrentVertexIdx + 1) % mVertices.size()] - mVertices[mCurrentVertexIdx]; 49 Vector3 ndir = -Normalize(dir); 50 51 float pitch = -atan2(ndir.x, ndir.y); 52 float yaw = atan2(ndir.z, sqrt((ndir.x * ndir.x) + (ndir.y * ndir.y))); 53 54 55 Matrix4x4 roty = RotationYMatrix(pitch); 56 Matrix4x4 rotx = RotationXMatrix(yaw); 57 58 return roty * rotx; 34 59 } 35 60 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/MotionPath.h
r2951 r3078 34 34 void Reset(); 35 35 36 Matrix4x4 GetOrientation(); 37 36 38 37 39 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3077 r3078 54 54 #include "Texture.h" 55 55 #include "ShaderManager.h" 56 #include "MotionPath.h" 56 57 57 58 … … 103 104 SkyPreetham *preetham = NULL; 104 105 106 MotionPath *motionPath = NULL; 105 107 106 108 … … 142 144 143 145 int shadowSize = 2048; 144 145 146 /// the hud font 146 147 glfont::GLFont myfont; … … 276 277 /// Creates the traversal method (vfc, stopandwait, chc, chc++) 277 278 RenderTraverser *CreateTraverser(PerspectiveCamera *cam); 278 279 279 /// place the viewer on the floor plane 280 280 void PlaceViewer(const Vector3 &oldPos); … … 293 293 inline float KeyShift() { return keyForwardMotion * elapsedTime * 1e-3f; } 294 294 295 void CreateAnimation(); 296 297 295 298 // the new and the old viewProjection matrix of the current camera 296 299 static Matrix4x4 viewProjMat = IdentityMatrix(); … … 455 458 //-- load some dynamic stuff 456 459 457 /*LoadModel("hbuddha.dem", dynamicObjects);460 LoadModel("hbuddha.dem", dynamicObjects); 458 461 buddha = dynamicObjects.back(); 459 462 … … 479 482 } 480 483 481 */ 484 482 485 /////////// 483 486 //-- load the associated static bvh … … 512 515 const float turbitiy = 5.0f; 513 516 preetham = new SkyPreetham(turbitiy, skyDome); 517 518 CreateAnimation(); 514 519 515 520 … … 870 875 void MainLoop() 871 876 { 872 /*Vector3 offs = Vector3::ZERO(); 873 offs.x = RandomValue(-.1f, .1f); 874 offs.y = RandomValue(-.1f, .1f); 875 //offs.x = RandomValue(.0f, .01f); 876 //offs.y = RandomValue(.0f, .01f); 877 878 Matrix4x4 mat = TranslationMatrix(offs); 879 buddha->GetTransform()->MultMatrix(mat); 880 */ 877 motionPath->Move(0.3f); 878 879 Vector3 planepos = motionPath->GetCurrentPosition(); 880 881 Matrix4x4 mat = TranslationMatrix(planepos); 882 buddha->GetTransform()->SetMatrix(mat); 883 881 884 Vector3 oldPos = camera->GetPosition(); 882 885 … … 1673 1676 DEL_PTR(shadowMap); 1674 1677 DEL_PTR(shadowTraverser); 1678 DEL_PTR(motionPath); 1675 1679 1676 1680 ResourceManager::DelSingleton(); … … 2044 2048 } 2045 2049 } 2050 2051 2052 void CreateAnimation() 2053 { 2054 const float radius = 5.0f; 2055 const Vector3 center(483.398f, 242.364f, 186.078f); 2056 2057 VertexArray vertices; 2058 2059 for (int i = 0; i < 360; ++ i) 2060 { 2061 float angle = (float)i * M_PI / 180.0f; 2062 2063 Vector3 offs = Vector3(cos(angle) * radius, sin(angle) * radius, 0); 2064 vertices.push_back(center + offs); 2065 } 2066 2067 motionPath = new MotionPath(vertices); 2068 }
Note: See TracChangeset
for help on using the changeset viewer.