- Timestamp:
- 10/17/05 21:51:45 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/AxisAlignedBox3.cpp
r329 r333 1719 1719 1720 1720 // compute angle to reference point 1721 for (i nt i= 1; i < (int)planePoly->mVertices.size(); ++ i)1721 for (i = 1; i < (int)planePoly->mVertices.size(); ++ i) 1722 1722 { 1723 1723 float angle = … … 1730 1730 1731 1731 // update vertices 1732 for (i nt i= 1; i < (int)planePoly->mVertices.size(); ++ i)1732 for (i = 1; i < (int)planePoly->mVertices.size(); ++ i) 1733 1733 planePoly->mVertices[i] = vertexData[i - 1].mVertex; 1734 1734 } -
trunk/VUT/GtpVisibilityPreprocessor/src/KdTree.cpp
r311 r333 163 163 bool mOnlyDrivingAxis = false; 164 164 if (mOnlyDrivingAxis) { 165 axis = box.Size().DrivingAxis();166 costRatio = BestCostRatio(leaf,167 168 169 170 171 165 axis = box.Size().DrivingAxis(); 166 costRatio = BestCostRatio(leaf, 167 box, 168 axis, 169 position, 170 objectsBack, 171 objectsFront); 172 172 } else { 173 costRatio = MAX_FLOAT;174 for (int i=0; i < 3; i++) {175 176 177 178 179 180 181 182 183 184 185 186 187 }173 costRatio = MAX_FLOAT; 174 for (int i=0; i < 3; i++) { 175 float p; 176 float r = BestCostRatio(leaf, 177 box, 178 i, 179 p, 180 objectsBack, 181 objectsFront); 182 if (r < costRatio) { 183 costRatio = r; 184 axis = i; 185 position = p; 186 } 187 } 188 188 } 189 189 190 190 if (costRatio > mMaxCostRatio) { 191 // cout<<"Too big cost ratio "<<costRatio<<endl;192 axis = -1;191 // cout<<"Too big cost ratio "<<costRatio<<endl; 192 axis = -1; 193 193 } 194 194 break; … … 415 415 float 416 416 KdTree::BestCostRatio( 417 418 419 420 421 422 423 417 KdLeaf *node, 418 const AxisAlignedBox3 &box, 419 const int axis, 420 float &position, 421 int &objectsBack, 422 int &objectsFront 423 ) 424 424 { 425 425 … … 439 439 totalIntersections += (*ci).intersectable->IntersectionComplexity(); 440 440 } 441 441 442 442 float intersectionsLeft = 0; 443 443 float intersectionsRight = totalIntersections; 444 444 445 445 int objectsLeft = 0, objectsRight = node->mObjects.size(); 446 446 -
trunk/VUT/GtpVisibilityPreprocessor/src/Makefile
r258 r333 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Sep 06 13: 22:5820053 # Generated by qmake (1.07a) (Qt 3.3.2) on: Tue Sep 06 13:46:00 2005 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 13 13 LEX = flex 14 14 YACC = byacc 15 CFLAGS = -nologo -Zm200 -W0 -MD d -Zi -GX -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT16 CXXFLAGS = -nologo -Zm200 -W0 -MD d -Zi -GX -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT15 CFLAGS = -nologo -Zm200 -W0 -MD -O2 -GX -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG 16 CXXFLAGS = -nologo -Zm200 -W0 -MD -O2 -GX -DUNICODE -DQT_DLL -DQT_THREAD_SUPPORT -DQT_NO_DEBUG 17 17 LEXFLAGS = 18 18 YACCFLAGS =-d 19 19 INCPATH = -I"..\src" -I"..\support\xerces\include" -I"..\support\zlib\include" -I"..\support\boost" -I"..\support\devil\include" -I"$(QTDIR)\include" -I"d:\gametools\svn\trunk\VUT\GtpVisibilityPreprocessor\src" -I"C:\Qt\3.3.2\mkspecs\win32-msvc" 20 20 LINK = link 21 LFLAGS = /NOLOGO /DEBUG/SUBSYSTEM:console /LIBPATH:"../support/xerces/lib" /LIBPATH:"../support/devil/lib" /LIBPATH:"$(QTDIR)\lib"21 LFLAGS = /NOLOGO delayimp.lib /DELAYLOAD:comdlg32.dll /DELAYLOAD:oleaut32.dll /DELAYLOAD:winmm.dll /DELAYLOAD:wsock32.dll /DELAYLOAD:winspool.dll /SUBSYSTEM:console /LIBPATH:"../support/xerces/lib" /LIBPATH:"../support/devil/lib" /LIBPATH:"$(QTDIR)\lib" 22 22 LIBS = "qt-mt332.lib" "qtmain.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "imm32.lib" "winmm.lib" "wsock32.lib" "winspool.lib" "xerces-c_2.lib" "devil.lib" "ilu.lib" "ilut.lib" "opengl32.lib" "glu32.lib" "delayimp.lib" 23 23 MOC = $(QTDIR)\bin\moc.exe … … 188 188 -$(DEL_FILE) ViewCell.obj 189 189 -$(DEL_FILE) ViewCellBsp.obj 190 -$(DEL_FILE) preprocessor.pdb191 -$(DEL_FILE) preprocessor.ilk192 -$(DEL_FILE) vc*.pdb193 -$(DEL_FILE) vc*.idb194 195 190 196 191 -
trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.cpp
r308 r333 50 50 int 51 51 Mesh::CastRayToFace( 52 53 54 55 56 57 52 const int faceIndex, 53 Ray &ray, 54 float &nearestT, 55 int &nearestFace, 56 Intersectable *instance 57 ) 58 58 { 59 59 float t; … … 72 72 case Ray::LINE_SEGMENT: 73 73 if (t <= 1.0f) { 74 ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex));75 hit++;74 ray.intersections.push_back(Ray::Intersection(t, instance, faceIndex)); 75 hit++; 76 76 } 77 77 break; … … 83 83 int 84 84 Mesh::CastRay( 85 86 87 85 Ray &ray, 86 MeshInstance *instance 87 ) 88 88 { 89 89 if (mKdTree) { … … 100 100 101 101 for ( ; 102 faceIndex < mFaces.size();103 faceIndex++) {102 faceIndex < mFaces.size(); 103 faceIndex++) { 104 104 hits += CastRayToFace(faceIndex, ray, nearestT, nearestFace, instance); 105 105 if (mIsConvex && nearestFace != -1) … … 119 119 int 120 120 Mesh::CastRayToSelectedFaces( 121 122 123 124 121 Ray &ray, 122 const vector<int> &faces, 123 Intersectable *instance 124 ) 125 125 { 126 126 vector<int>::const_iterator fi; … … 134 134 135 135 for ( fi = faces.begin(); 136 fi != faces.end();137 fi++) {136 fi != faces.end(); 137 fi++) { 138 138 hits += CastRayToFace(*fi, ray, nearestT, nearestFace, instance); 139 139 if (mIsConvex && nearestFace != -1) … … 157 157 inline int 158 158 int_lineseg(float px, 159 160 161 162 163 159 float py, 160 float u1, 161 float v1, 162 float u2, 163 float v2) 164 164 { 165 165 float t; … … 180 180 if (fabs(ydiff) < Limits::Small) { // denominator near 0 181 181 if (((fabs(v1) > Limits::Small) || 182 (u1 > 0) || (u2 > 0)))182 (u1 > 0) || (u2 > 0))) 183 183 return 0; 184 184 return 1; … … 195 195 int 196 196 Mesh::RayFaceIntersection(const int faceIndex, 197 198 199 200 197 const Ray &ray, 198 float &t, 199 const float nearestT 200 ) 201 201 { 202 202 Face *face = mFaces[faceIndex]; … … 242 242 // line u1, v1, u2, v2 243 243 if ((v2 - v1)*(u1 - u) > (u2 - u1)*(v1 - v)) 244 return Ray::NO_INTERSECTION;244 return Ray::NO_INTERSECTION; 245 245 u1 = u2; 246 246 v1 = v2; … … 288 288 int 289 289 MeshInstance::CastRay( 290 291 290 Ray &ray 291 ) 292 292 { 293 293 int res = mMesh->CastRay(ray, this); … … 297 297 int 298 298 MeshInstance::CastRay( 299 300 301 299 Ray &ray, 300 const vector<int> &faces 301 ) 302 302 { 303 303 return mMesh->CastRayToSelectedFaces(ray, faces, this); … … 325 325 Face *face = mFaces[faceIndex]; 326 326 return Plane3(mVertices[face->mVertexIndices[0]], 327 mVertices[face->mVertexIndices[1]],328 mVertices[face->mVertexIndices[2]]);327 mVertices[face->mVertexIndices[1]], 328 mVertices[face->mVertexIndices[2]]); 329 329 } 330 330 331 331 int 332 332 TransformedMeshInstance::CastRay( 333 Ray &ray334 )333 Ray &ray 334 ) 335 335 { 336 336 ray.ApplyTransform(Invert(mWorldTransform)); -
trunk/VUT/GtpVisibilityPreprocessor/src/Mesh.h
r327 r333 107 107 int 108 108 CastRay( 109 110 111 112 109 Ray &ray, 110 MeshInstance *instance 111 ); 112 113 113 int 114 114 CastRayToSelectedFaces( 115 Ray &ray,116 const vector<int> &faces,117 Intersectable *instance118 );119 115 Ray &ray, 116 const vector<int> &faces, 117 Intersectable *instance 118 ); 119 120 120 int 121 121 CastRayToFace( 122 const int faceIndex,123 Ray &ray,124 float &nearestT,125 int &nearestFace,126 Intersectable *instance127 );128 122 const int faceIndex, 123 Ray &ray, 124 float &nearestT, 125 int &nearestFace, 126 Intersectable *instance 127 ); 128 129 129 130 130 int 131 131 RayFaceIntersection(const int faceIndex, 132 133 134 135 132 const Ray &ray, 133 float &t, 134 const float nearestT 135 ); 136 136 137 137 Plane3 GetFacePlane(const int faceIndex); -
trunk/VUT/GtpVisibilityPreprocessor/src/Polygon3.h
r329 r333 24 24 public: 25 25 Polygon3(); 26 26 27 Polygon3(const VertexContainer &vertices); 27 28 Polygon3(MeshInstance *parent); 29 30 ~Polygon3(); 31 28 32 // creates an "infinite" polygon from this plane 29 33 //Polygon3(Plane3 plane); … … 75 79 /** Returns the surface normal. 76 80 */ 77 inlineVector3 GetNormal() const;81 Vector3 GetNormal() const; 78 82 79 83 /** Includes polygons to axis aligned box. -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r332 r333 234 234 235 235 236 void 236 int 237 237 SamplingPreprocessor::CastEdgeSamples( 238 238 Intersectable *object, 239 239 const Vector3 &point, 240 Mesh &mesh,240 MeshInstance *mi, 241 241 const int samples 242 242 ) 243 243 { 244 244 Ray ray; 245 int maxTries = samples*10; 245 246 int i; 246 for (i=0; i < samples; i++) { 247 int rays = 0; 248 int edgeSamplesContributions = 0; 249 for (i=0; i < maxTries && rays < samples; i++) { 247 250 // pickup a random face of each mesh 248 int face = RandomValue(0, mesh.mFaces.size()-1); 249 250 Polygon3 poly(mesh.mFaces[face], &mesh); 251 Mesh *mesh = mi->GetMesh(); 252 int face = RandomValue(0, mesh->mFaces.size()-1); 253 254 Polygon3 poly(mesh->mFaces[face], mesh); 251 255 poly.Scale(1.001); 252 256 // now extend a random edge of the face … … 256 260 poly.mVertices.size()]; 257 261 SetupRay(ray, point, target - point); 258 CastRay(object, ray); 262 if (!mesh->CastRay(ray, mi)) { 263 // the rays which intersect the mesh have been discarded since they are not tangent 264 // to the mesh 265 rays++; 266 edgeSamplesContributions += CastRay(object, ray); 267 } 259 268 } 269 return edgeSamplesContributions; 260 270 } 261 271 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.h
r331 r333 26 26 int mBspConstructionSamples; 27 27 28 28 29 SamplingPreprocessor(); 29 30 … … 47 48 CastRay(Intersectable *object, Ray &ray); 48 49 49 void50 int 50 51 CastEdgeSamples( 51 52 Intersectable *object, 52 53 const Vector3 &point, 53 Mesh &mesh,54 MeshInstance *mi, 54 55 const int samples 55 56 ); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r323 r333 72 72 73 73 // add top vertices 74 for (i nt i= 0; i < 3; ++ i)74 for (i = 0; i < 3; ++ i) 75 75 mesh->mVertices.push_back(baseTri.mVertices[i] + height * triNorm); 76 76 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dExporter.cpp
r329 r333 249 249 VertexContainer::const_iterator vi; 250 250 251 for (in t index = 0; index < (int)poly->mVertices.size(); ++ index)251 for (index = 0; index < (int)poly->mVertices.size(); ++ index) 252 252 stream << index << " "; 253 253 -
trunk/VUT/GtpVisibilityPreprocessor/src/X3dParser.cpp
r318 r333 506 506 } 507 507 508 509 for (int i = 0; i < mCurrentVertexIndices.size(); i += 3) 510 { 508 for (i = 0; i < mCurrentVertexIndices.size(); i += 3) 509 { 511 510 Triangle3 baseTri(vertices[mCurrentVertexIndices[i + 0]], 512 511 vertices[mCurrentVertexIndices[i + 1]], -
trunk/VUT/GtpVisibilityPreprocessor/src/default.env
r326 r333 30 30 sahUseFaces true 31 31 Termination { 32 minCost 232 minCost 1 33 33 maxDepth 18 34 maxCostRatio 0.9 34 maxCostRatio 0.95 35 35 ct_div_ci 0.5 36 36 } … … 43 43 MeshKdTree { 44 44 Termination { 45 minCost 446 maxDepth 1 847 maxCostRatio 0.9 45 minCost 1 46 maxDepth 12 47 maxCostRatio 0.95 48 48 ct_div_ci 0.5 49 49 } -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r332 r333 96 96 97 97 98 if ( 1) {98 if (0) { 99 99 p->ComputeVisibility(); 100 100 p->ExportPreprocessedData("scene.vis"); … … 104 104 Camera camera; 105 105 //camera.LookAtBox(p->mKdTree->GetBox()); 106 camera.LookInBox(p->mKdTree->GetBox());107 camera.SetPosition(camera.mPosition + Vector3(0,300,0));106 camera.LookInBox(p->mKdTree->GetBox()); 107 camera.SetPosition(camera.mPosition + Vector3(0,300,0)); 108 108 camera.SnapImage("camera.jpg", p->mKdTree); 109 109 110 110 111 111 camera.LookInBox(p->mKdTree->GetBox()); 112 112 camera.SetPosition(camera.mPosition - Vector3(0,100,0)); 113 camera.SnapImage("camera2. png", p->mKdTree);113 camera.SnapImage("camera2.jpg", p->mKdTree); 114 114 } 115 115 -
trunk/VUT/GtpVisibilityPreprocessor/src/preprocessor.pro
r258 r333 13 13 14 14 # debuc config 15 CONFIG += console warn_off thread debug15 CONFIG += console warn_off thread release 16 16 17 17 # RELEASE CONFIG
Note: See TracChangeset
for help on using the changeset viewer.