- Timestamp:
- 06/10/08 10:54:13 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis
- Files:
-
- 8 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/CHC_revisited/DataTypes.c
r2642 r2746 18 18 } 19 19 20 void addVector3(Vector3 result, const Vector3 a, const Vector3 b) { 20 void addVector3(Vector3 result, const Vector3 a, const Vector3 b) 21 { 21 22 int i; 22 for(i = 0; i < 3; i++) { 23 result[i] = a[i]+b[i]; 24 } 25 } 26 27 void diffVector3(Vector3 result, const Vector3 a, const Vector3 b) { 23 24 for (i = 0; i < 3; ++ i) 25 { 26 result[i] = a[i] + b[i]; 27 } 28 } 29 30 31 void diffVector3(Vector3 result, const Vector3 a, const Vector3 b) 32 { 28 33 int i; 29 for(i = 0; i < 3; i++) { 30 result[i] = a[i]-b[i]; 31 } 32 } 33 34 void copyVector3Values(Vector3 result, const double x, const double y, const double z) { 34 for (i = 0; i < 3; ++ i) 35 { 36 result[i] = a[i] - b[i]; 37 } 38 } 39 40 41 void copyVector3Values(Vector3 result, const double x, const double y, const double z) 42 { 35 43 result[0] = x; 36 44 result[1] = y; … … 38 46 } 39 47 40 void copyMatrix(Matrix4x4 result, const Matrix4x4 input) { 41 if(input != result) { 48 49 void copyMatrix(Matrix4x4 result, const Matrix4x4 input) 50 { 51 if (input != result) 52 { 42 53 memcpy(result,input,4*4*sizeof(double)); 43 54 } 44 55 } 45 56 46 void planesSetSize(struct VecPlane* p, const int size) { 47 if(0 != p) { 48 if(size == p->size) { 57 58 void planesSetSize(struct VecPlane* p, const int size) 59 { 60 if (0 != p) 61 { 62 if(size == p->size) 63 { 49 64 return; 50 65 } 66 51 67 p->plane = (struct Plane*)realloc(p->plane,size*sizeof(struct Plane)); 52 68 p->size = size; … … 54 70 } 55 71 56 void emptyVecPlane(struct VecPlane* p) { 72 73 void emptyVecPlane(struct VecPlane* p) 74 { 57 75 planesSetSize(p,0); 58 76 } 59 77 60 void vecPointSetSize(struct VecPoint* poly, const int size) { 61 if(0 != poly) { 62 if(size == poly->size) { 78 79 void vecPointSetSize(struct VecPoint* poly, const int size) 80 { 81 if (0 != poly) 82 { 83 if (size == poly->size) 84 { 63 85 return; 64 86 } 87 65 88 poly->points = (Vector3*)realloc(poly->points,size*sizeof(Vector3)); 66 89 poly->size = size; … … 68 91 } 69 92 70 void emptyVecPoint(struct VecPoint* poly) { 93 94 void emptyVecPoint(struct VecPoint* poly) 95 { 71 96 vecPointSetSize(poly,0); 72 97 } 73 98 74 void append2VecPoint(struct VecPoint* poly, const Vector3 p) { 75 if(0 != poly) { 99 100 void append2VecPoint(struct VecPoint* poly, const Vector3 p) 101 { 102 if (0 != poly) 103 { 76 104 int size = poly->size; 77 105 vecPointSetSize(poly,size+1); 78 copyVector3(poly->points[size],p); 79 } 80 } 81 82 void copyVecPoint(struct VecPoint* poly, const struct VecPoint poly2) { 83 if(0 != poly) { 106 copyVector3(poly->points[size], p); 107 } 108 } 109 110 111 void copyVecPoint(struct VecPoint* poly, const struct VecPoint poly2) 112 { 113 if (0 != poly) 114 { 84 115 int i; 85 116 vecPointSetSize(poly,poly2.size); 86 for(i= 0; i < poly2.size; i++) { 87 copyVector3(poly->points[i],poly2.points[i]); 88 } 89 } 90 } 91 92 void swapVecPoint(struct VecPoint* poly1, struct VecPoint* poly2) { 93 if(0 != poly1 && 0 != poly2 && poly1 != poly2) { 94 { 95 Vector3* points = poly1->points; 96 poly1->points = poly2->points; 97 poly2->points = points; 98 } 99 { 100 int size = poly1->size; 101 poly1->size = poly2->size; 102 poly2->size = size; 103 } 104 } 105 } 106 107 void objectSetSize(struct Object* obj, const int size) { 108 if(0 != obj) { 117 for (i = 0; i < poly2.size; ++ i) 118 { 119 copyVector3(poly->points[i], poly2.points[i]); 120 } 121 } 122 } 123 124 125 void swapVecPoint(struct VecPoint* poly1, struct VecPoint* poly2) 126 { 127 if(0 != poly1 && 0 != poly2 && poly1 != poly2) 128 { 129 Vector3* points = poly1->points; 130 poly1->points = poly2->points; 131 poly2->points = points; 132 133 int size = poly1->size; 134 poly1->size = poly2->size; 135 poly2->size = size; 136 } 137 } 138 139 140 void objectSetSize(struct Object* obj, const int size) 141 { 142 if (0 != obj) 143 { 109 144 int i; 110 if(size == obj->size) { 145 if(size == obj->size) 146 { 111 147 return; 112 148 } 149 113 150 //dispose if shrinking 114 for(i = size; i < obj->size; i++) { 115 emptyVecPoint( &(obj->poly[i]) ); 116 } 151 for(i = size; i < obj->size; i++) 152 { 153 emptyVecPoint(&(obj->poly[i])); 154 } 155 117 156 //allocate new place 118 157 obj->poly = (struct VecPoint*)realloc(obj->poly,size*sizeof(struct VecPoint)); 158 119 159 //initialize new place 120 for(i = obj->size; i < size; i++) { 160 for(i = obj->size; i < size; i++) 161 { 121 162 obj->poly[i] = VECPOINT_NULL; 122 163 } 164 123 165 obj->size = size; 124 166 } 125 167 } 126 168 127 void emptyObject(struct Object* obj) { 128 objectSetSize(obj,0); 129 } 130 131 void copyObject(struct Object* obj, const struct Object objIn) { 132 if(0 != obj) { 169 170 void emptyObject(struct Object* obj) 171 { 172 objectSetSize(obj, 0); 173 } 174 175 176 void copyObject(struct Object* obj, const struct Object objIn) 177 { 178 if(0 != obj) 179 { 133 180 int i; 134 181 objectSetSize(obj,objIn.size); 135 for(i = 0; i < objIn.size; i++) { 182 183 for(i = 0; i < objIn.size; i++) 184 { 136 185 copyVecPoint( &(obj->poly[i]), objIn.poly[i]); 137 186 } … … 139 188 } 140 189 141 void append2Object(struct Object* obj, const struct VecPoint poly) { 142 if(0 != obj) { 190 191 void append2Object(struct Object* obj, const struct VecPoint poly) 192 { 193 if (0 != obj) 194 { 143 195 int size = obj->size; 144 objectSetSize(obj,size+1); 145 copyVecPoint( &(obj->poly[size]) ,poly); 146 } 147 } 148 149 150 void convObject2VecPoint(struct VecPoint* points,const struct Object obj) { 196 objectSetSize(obj, size + 1); 197 copyVecPoint(&(obj->poly[size]), poly); 198 } 199 } 200 201 202 void convObject2VecPoint(struct VecPoint* points,const struct Object obj) 203 { 151 204 if(0 != points) { 152 205 int i, j; … … 160 213 } 161 214 } 215 162 216 163 217 void calcAABoxPoints(Vector3x8 points, const struct AABox b) { … … 173 227 } 174 228 229 175 230 void calcAABoxPlanes(struct VecPlane* planes, const struct AABox b) { 176 231 if(0 != planes) { -
GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.cpp
r2642 r2746 89 89 return true; 90 90 } 91 91 92 92 93 void Geometry::GenerateList() … … 112 113 break; 113 114 } 115 114 116 glEndList(); 115 117 } 116 118 } 119 117 120 118 121 void Geometry::Render() … … 238 241 { 239 242 glBegin(GL_TRIANGLE_STRIP); 240 while(teapot_indices[i] != STRIP_END) 241 { 242 int index = teapot_indices[i] * 3; 243 244 glNormal3fv(teapot_normals + index); 245 glVertex3fv(teapot_vertices + index); 246 247 i++; 248 } 243 244 while (teapot_indices[i] != STRIP_END) 245 { 246 int index = teapot_indices[i] * 3; 247 248 glNormal3fv(teapot_normals + index); 249 glVertex3fv(teapot_vertices + index); 250 251 ++ i; 252 } 253 249 254 glEnd(); 250 251 i++; // skip strip end flag 252 } 253 } 255 256 ++ i; // skip strip end flag 257 } 258 } 259 254 260 255 261 void Geometry::CalcBoundingVolume() … … 276 282 Vector3 *rotatedPoints = new Vector3[num_vertices]; 277 283 278 for (int i = 0; i < num_vertices; i++)284 for (int i = 0; i < num_vertices; ++ i) 279 285 { 280 286 copyVector3Values(rotatedPoints[i], vertices[i * 3], … … 288 294 calcCubicHull(mBoundingBox.min, mBoundingBox.max, rotatedPoints, num_vertices); 289 295 290 for (int i=0; i< 3; i++)296 for (int i = 0; i < 3; ++ i) 291 297 { 292 298 mBoundingBox.min[i] *= mScale; … … 325 331 } 326 332 327 /* 328 creates a torus with specified radii, with number of rings and ring 333 /* Creates a torus with specified radii, with number of rings and ring 329 334 subdivision = precision. 330 335 */ … … 338 343 torus_indices = new int[num_torus_indices]; 339 344 340 for (int i = 0; i < precision + 1; ++ i)345 for (int i = 0; i < precision + 1; ++ i) 341 346 { 342 347 int index = i * 3; … … 364 369 } 365 370 366 for (int i_rng = 1; i_rng < precision + 1; ++ i_rng)367 { 368 for(int i =0; i<precision+1; ++i)371 for (int i_rng = 1; i_rng < precision + 1; ++ i_rng) 372 { 373 for(int i = 0; i<precision + 1; ++ i) 369 374 { 370 375 int index = 3 * (i_rng * (precision + 1) + i); … … 388 393 } 389 394 390 for (int i_rng = 0; i_rng < precision; ++ i_rng)391 { 392 for (int i = 0; i < precision; ++ i)395 for (int i_rng = 0; i_rng < precision; ++ i_rng) 396 { 397 for (int i = 0; i < precision; ++ i) 393 398 { 394 399 int index = ((i_rng * precision + i) * 2) * 3; … … 407 412 } 408 413 409 /** 410 counts the triangles of the teapot.414 415 /** Counts the triangles of the teapot. 411 416 traverses through all the triangle strips. 412 417 */ … … 414 419 { 415 420 int result = 0; 416 int i=0; 421 int i = 0; 422 417 423 // n - 2 triangles are drawn for a strip 418 while (i < num_teapot_indices)419 { 420 while (teapot_indices[i] != STRIP_END)424 while (i < num_teapot_indices) 425 { 426 while (teapot_indices[i] != STRIP_END) 421 427 { 422 428 result ++;; 423 i++;429 ++ i; 424 430 } 425 431 result -= 2; 426 i++; // skip STRIP_END 427 } 432 ++ i; // skip STRIP_END 433 } 434 428 435 return result; 429 436 } 430 437 431 /** 432 counts the triangles of the torus438 439 /** Counts the triangles of the torus 433 440 */ 434 441 int Geometry::CountTorusTriangles() … … 452 459 int result = 0; 453 460 454 switch (objectType)461 switch (objectType) 455 462 { 456 463 case TEAPOT: … … 466 473 break; 467 474 } 475 468 476 return result; 469 477 } … … 497 505 } 498 506 499 /** 500 renders a sphere with sphere_precision subdivisions. 501 note: works only for even sphere_precision507 508 /** Renders a sphere with sphere_precision subdivisions. 509 Note: works only for even sphere_precision 502 510 */ 503 511 void Geometry::RenderSphere() … … 508 516 glFrontFace(GL_CW); 509 517 510 for (int j = 0; j < sphere_precision /2; ++j)518 for (int j = 0; j < sphere_precision / 2; ++ j) 511 519 { 512 520 double alpha = j * PI * 2.0 / (double)sphere_precision - PI_2; … … 515 523 glBegin(GL_TRIANGLE_STRIP); 516 524 517 for (int i = 0; i <= sphere_precision; ++ i)525 for (int i = 0; i <= sphere_precision; ++ i) 518 526 { 519 527 double gamma = i * PI * 2.0 / (double)sphere_precision; … … 536 544 glEnd(); 537 545 } 546 538 547 glFrontFace(GL_CCW); 539 548 } -
GTP/trunk/App/Demos/Vis/CHC_revisited/Geometry.h
r2642 r2746 16 16 Geometry(); 17 17 Geometry(Vector3 translation, float xRot, float yRot, float zRot, float scale, int objectType); 18 //! renders this geometry18 //! Renders this geometry 19 19 void Render(); 20 21 20 //! sets rotations in degree : executed in the order x, y, and z rotation 22 21 void SetRotations(float xRot, float yRot, float zRot); … … 33 32 void GetRotations(float &xRot, float &yRot, float &zRot); 34 33 35 // --- material settings 36 void SetAmbientColor(float ambientR, float ambientG, float ambientB); 37 void SetDiffuseColor(float diffuseR, float diffuseG, float diffuseB); 38 void SetSpecularColor(float specularR, float specularG, float specularB); 39 34 //! Set pointer to the material 35 void SetMaterial(Material *mat); 36 //! Returns the bounding box 40 37 const AABox& GetBoundingVolume(); 41 42 38 //! last visited flag, important for rendering each geometry only once 43 39 void SetLastVisited(int lastVisited); 44 40 //! returns lastvisited flag 45 41 int GetLastVisited(); 46 47 42 // --- sets the object type to one of teapot, torus, sphere 48 43 void SetObjectType(int type); 49 44 50 enum{TEAPOT, TORUS, SPHERE, NUM_OBJECTS};45 51 46 52 47 static int sDisplayList[NUM_OBJECTS]; … … 60 55 61 56 protected: 57 62 58 //! generates the display list this a object 63 59 void GenerateList(); -
GTP/trunk/App/Demos/Vis/CHC_revisited/HierarchyNode.cpp
r2642 r2746 1 #if TOIMPLEMENT 2 1 3 #include "HierarchyNode.h" 2 4 #include "glInterface.h" … … 486 488 mDistance = distance; 487 489 } 490 491 #endif -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.cpp
r2642 r2746 3 3 #include "Timers.h" 4 4 5 /*extern "C" 6 { 7 #include "MathStuff.h" 8 }*/ 9 5 6 #if TOIMPLEMENT 10 7 11 8 RenderTraverser::RenderTraverser(): … … 546 543 printf("using opt %d\n", mUseOptimization); 547 544 } 545 546 547 #endif -
GTP/trunk/App/Demos/Vis/CHC_revisited/RenderTraverser.h
r2642 r2746 1 #ifndef NO_PRAGMA_ONCE2 #pragma once3 #endif4 5 1 #ifndef RENDERTRAVERSER_H 6 2 #define RENDERTRAVERSER_H 3 4 #if TOIMPLEMENT 7 5 8 6 #include "glInterface.h" … … 12 10 #include <stack> 13 11 14 using namespace std; 12 15 13 16 14 typedef stack<HierarchyNode *> TraversalStack; … … 133 131 bool mUseOptimization; 134 132 }; 135 133 #endif 136 134 #endif // RENDERTRAVERSER_H -
GTP/trunk/App/Demos/Vis/CHC_revisited/Timers.h
r2642 r2746 1 // ================================================================ 2 // $Id: Timers.h,v, 1.1.1.1 2004/10/12 12:49:13 matt Exp $ 3 // **************************************************************** 4 // 5 /** \file time.h 6 7 Various time measuring routines 8 9 @author Jiri Bittner 1 /** Various time measuring routines 2 @author Jiri Bittner 10 3 */ 11 4 -
GTP/trunk/App/Demos/Vis/CHC_revisited/chc_revisited.vcproj
r2642 r2746 182 182 > 183 183 <File 184 RelativePath=".\ DataTypes.c"185 > 186 </File> 187 <File 188 RelativePath=".\ Geometry.cpp"184 RelativePath=".\AxisAlignedBox3.cpp" 185 > 186 </File> 187 <File 188 RelativePath=".\common.cpp" 189 189 > 190 190 </File> … … 194 194 </File> 195 195 <File 196 RelativePath=".\MathStuff.c" 196 RelativePath=".\Material.cpp" 197 > 198 </File> 199 <File 200 RelativePath=".\Matrix4x4.cpp" 197 201 > 198 202 </File> … … 216 220 > 217 221 <File 218 RelativePath=".\DataTypes.h" 219 > 220 </File> 221 <File 222 RelativePath=".\Geometry.h" 222 RelativePath=".\AxisAlignedBox3.h" 223 > 224 </File> 225 <File 226 RelativePath=".\Bvh.cpp" 227 > 228 </File> 229 <File 230 RelativePath=".\Bvh.h" 231 > 232 </File> 233 <File 234 RelativePath=".\common.h" 223 235 > 224 236 </File> … … 228 240 </File> 229 241 <File 230 RelativePath=".\ HierarchyNode.h"231 > 232 </File> 233 <File 234 RelativePath=".\Mat hStuff.h"242 RelativePath=".\Material.h" 243 > 244 </File> 245 <File 246 RelativePath=".\Matrix4x4.h" 235 247 > 236 248 </File> … … 240 252 </File> 241 253 <File 242 RelativePath=".\teapot.h"243 >244 </File>245 <File246 254 RelativePath=".\Timers.h" 255 > 256 </File> 257 <File 258 RelativePath=".\Vector3.cpp" 259 > 260 </File> 261 <File 262 RelativePath=".\Vector3.h" 247 263 > 248 264 </File> -
GTP/trunk/App/Demos/Vis/CHC_revisited/occquery.cpp
r2642 r2746 1 1 // occquery.cpp : Defines the entry point for the console application. 2 2 // 3 4 //#include "stdafx.h" 3 #if TOIMPLEMENT 4 5 #include <math.h> 6 #include <time.h> 5 7 #include "glInterface.h" 6 8 #include "RenderTraverser.h" 7 9 8 extern "C"9 {10 #include "MathStuff.h"11 #include "DataTypes.h"12 }13 14 #include <math.h>15 #include <time.h>16 10 17 11 … … 109 103 void deleteGeometry(); 110 104 105 #endif 111 106 112 107 int main(int argc, char* argv[]) 113 108 { 109 #if 0 114 110 glutInitWindowSize(800,600); 115 111 glutInit(&argc,argv); … … 141 137 // clean up 142 138 cleanUp(); 143 139 #endif 144 140 return 0; 145 141 } 146 142 147 143 #if 0 148 144 void initGLstate(void) 149 145 { … … 850 846 } 851 847 } 848 849 #endif -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj
r2501 r2746 83 83 OptimizeForWindowsApplication="TRUE" 84 84 AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";..\..\Ogre\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include" 85 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE "85 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1" 86 86 RuntimeLibrary="2" 87 87 RuntimeTypeInfo="FALSE" … … 142 142 OptimizeForWindowsApplication="TRUE" 143 143 AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";..\..\Ogre\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;"$(LIBXML_HOME)\include";d:\work\Collada\include;..\..\..\..\..\Lib\Vis\Preprocessing\src\Timer" 144 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODUL E"144 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODUL" 145 145 StringPooling="TRUE" 146 146 RuntimeLibrary="2" -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
r2555 r2746 234 234 mVizCamera = mSceneMgr->createCamera("VizCam"); 235 235 mVizCamera->setPosition(mCamNode->getPosition()); 236 237 /////////////// 236 238 237 239 mVizCamera->setNearClipDistance(1); -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/scripts/TestKdTree.vcproj
r2361 r2746 86 86 OptimizeForWindowsApplication="TRUE" 87 87 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include" 88 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE "88 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GTP_VISIBILITY_MODIFIED_OGRE;GAMETOOLS_ILLUMINATION_MODULE1" 89 89 StringPooling="TRUE" 90 90 MinimalRebuild="TRUE" … … 263 263 Name="VCAuxiliaryManagedWrapperGeneratorTool"/> 264 264 </Configuration> 265 <Configuration265 <Configuration 266 266 Name="Release_noqt|Win32" 267 267 OutputDirectory="Release"
Note: See TracChangeset
for help on using the changeset viewer.