Changeset 2669 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 04/30/08 10:09:52 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r2667 r2669 96 96 97 97 // for sg snapshot 98 //mViewPoint = Vector3(18.5133, 10.9818, -1032.24);99 //mViewDirection = Vector3(-0.5373, 0, 0.843391);100 101 102 // mViewPoint = Vector3(1213.85, 176.988, -437.364);103 // mViewDirection = Vector3(0.433884, 0, -0.900969);104 105 //mViewPoint = Vector3(1213.85, 176.988, -437.364);106 //mViewDirection = Vector3(0.433884, 0, -0.900969);107 108 98 mViewPoint = Vector3(32.8596, 9.86079, -1023.79); 109 99 mViewDirection = Vector3(-0.92196, 0, 0.387286); 110 111 //mViewPoint = Vector3(1099.9,183.0,-387);112 //mViewDirection = Vector3(-0.6,0,-0.8);113 100 114 101 // inside … … 1650 1637 // drop the first frame (for some reason, the first frame yields wrong pixel error) 1651 1638 1652 if ((mFrame > 0) && (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0)) 1639 if (//(mFrame > 0) && 1640 (err >= 0.0f) && (err < (1.0f - 1e-6f)) && (pvsSize > 0)) 1653 1641 { 1654 1642 if (err > mPvsStat.maxError) -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2667 r2669 20 20 21 21 #define GVS_DEBUG 0 22 22 #define NOT_ACCOUNTED_OBJECT 0 23 #define ACCOUNTED_OBJECT 2 24 #define SHOW_QT_VISUALIZATION 0 25 26 static const float MIN_DIST = 0.001f; 27 28 static ObjectContainer myobjects; 29 30 31 /** Visualization structure for the GVS algorithm. 32 */ 23 33 struct VizStruct 24 34 { … … 28 38 }; 29 39 30 31 static const float MIN_DIST = 0.001f;32 33 static ObjectContainer myobjects;34 40 static vector<VizStruct> vizContainer; 41 42 35 43 36 44 … … 153 161 //newRay->mFlags |= VssRay::ReverseSample; 154 162 155 // if ray is not further processed => delete ray 156 if (!HandleRay(newRay)) 157 { 158 //delete newRay; 159 } 163 // check if ray is not further processed (ray not deleted because using ray pool) 164 HandleRay(newRay); 160 165 161 166 return 1; … … 164 169 return 0; 165 170 } 171 172 173 void GvsPreprocessor::CountObject(Intersectable *triObj) 174 { 175 if ((triObj->mCounter != (NOT_ACCOUNTED_OBJECT + 1)) && (triObj->mCounter != (ACCOUNTED_OBJECT + 1))) 176 { 177 ++ triObj->mCounter; 178 ++ mGenericStats2; 179 } 180 } 181 182 183 void GvsPreprocessor::UpdateStatsForVisualization(KdIntersectable *kdInt) 184 { 185 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 186 187 // count new objects in pvs due to kd node conversion 188 myobjects.clear(); 189 mKdTree->CollectObjects(kdInt->GetItem(), myobjects); 190 191 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 192 193 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 194 CountObject(*oit); 195 } 166 196 167 197 … … 189 219 Intersectable *obj = ray.mTerminationObject; 190 220 191 if (obj->mCounter < 2) 221 // counter < 2 => not accounted for yet 222 if (obj->mCounter < ACCOUNTED_OBJECT) 192 223 { 193 obj->mCounter += 2;224 obj->mCounter += ACCOUNTED_OBJECT; 194 225 mTrianglePvs.push_back(obj); 195 226 196 227 mGenericStats = mTrianglePvs.size(); 197 228 198 // if using kd pvs, exchange the triangle with the node in thepvs229 // exchange the triangle with the node in the pvs for kd pvs 199 230 if (mUseKdPvs) 200 231 { … … 203 234 if (!node->Mailed()) 204 235 { 236 // add to pvs 205 237 node->Mail(); 206 238 KdIntersectable *kdInt = mKdTree->GetOrCreateKdIntersectable(node); 207 239 mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 208 //mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 209 210 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 211 myobjects.clear(); 212 mKdTree->CollectObjects(node, myobjects); 213 214 // account for kd object pvs 215 ObjectContainer::const_iterator oit, oit_end = myobjects.end(); 216 217 for (oit = myobjects.begin(); oit != oit_end; ++ oit) 218 { 219 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 220 221 if ((triObj->mCounter != 1) && (triObj->mCounter != 3)) 222 { 223 ++ triObj->mCounter; 224 ++ mGenericStats2; 225 } 226 } 227 } 240 241 if (SHOW_QT_VISUALIZATION) UpdateStatsForVisualization(kdInt); 242 } 228 243 } 229 244 … … 902 917 ObjectContainer kdobjects; 903 918 mKdTree->CollectKdObjects(box, kdobjects); 904 //vector<KdLeaf *>::const_iterator lit, lit_end = leaves.end(); 905 //for (lit = leaves.begin(); lit != lit_end; ++ lit) 919 906 920 ObjectContainer::const_iterator oit, oit_end = kdobjects.end(); 921 907 922 for (oit = kdobjects.begin(); oit != oit_end; ++ oit) 908 923 { … … 912 927 //mCurrentViewCell->GetPvs().AddSampleDirty(kdInt, 1.0f); 913 928 mCurrentViewCell->GetPvs().AddSampleDirtyCheck(kdInt, 1.0f); 929 914 930 mViewCellsManager->UpdateStatsForViewCell(mCurrentViewCell, kdInt); 915 931 … … 924 940 TriangleIntersectable *triObj = static_cast<TriangleIntersectable *>(*oit); 925 941 926 // account for the overall pvs 927 if ((triObj->mCounter != 1) && (triObj->mCounter != 3)) 928 { 929 ++ triObj->mCounter; 930 ++ mGenericStats2; 931 } 942 CountObject(triObj); 932 943 933 944 // the triangle itself intersects 934 945 if (box.Intersects(triObj->GetItem())) 935 946 { 936 if ((triObj->mCounter < 2))947 if ((triObj->mCounter < ACCOUNTED_OBJECT)) 937 948 { 938 triObj->mCounter += 2;949 triObj->mCounter += ACCOUNTED_OBJECT; 939 950 940 951 mTrianglePvs.push_back(triObj); … … 957 968 958 969 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 959 (*oit)->mCounter = 0;970 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 960 971 961 972 ComputeViewCell(vc); … … 986 997 987 998 for (oit = mObjects.begin(); oit != oit_end; ++ oit) 988 (*oit)->mCounter = 0;999 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 989 1000 990 1001 ComputeViewCell(vc); … … 1049 1060 1050 1061 // hack: reset counter 1051 (*oit)->mCounter = 0;1062 (*oit)->mCounter = NOT_ACCOUNTED_OBJECT; 1052 1063 1053 1064 if (!bv || bv->Mailed()) … … 1252 1263 ProcessViewCell(); 1253 1264 1254 //mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize();1255 1265 mGvsStats.mTrianglePvs = (int)mTrianglePvs.size(); 1256 1266 mGvsStats.mTotalTrianglePvs += mGvsStats.mTrianglePvs; -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2648 r2669 11 11 class Exporter; 12 12 class VssRay; 13 class TriangleIntersectable; 14 class KdIntersectable; 13 15 14 16 /** View space partition statistics. … … 234 236 */ 235 237 void ProcessViewCell(); 236 238 /** Use this for qt visualization. 239 */ 240 void UpdateStatsForVisualization(KdIntersectable *kdInt); 241 /** Keep count of new objects for stats. 242 */ 243 void CountObject(Intersectable *triObj); 237 244 238 245 -
GTP/trunk/Lib/Vis/Preprocessing/src/OcclusionQuery.cpp
r2663 r2669 79 79 #ifdef _WIN32 80 80 // VH 81 cout << "issuing arb query" << endl;81 //cout << "issuing arb query" << endl; 82 82 glBeginQueryARB(GL_SAMPLES_PASSED_ARB, mId); 83 83 #endif … … 100 100 #ifdef _WIN32 101 101 // VH 102 cout << "ending query" << endl;102 //cout << "ending query" << endl; 103 103 glEndQueryARB(GL_SAMPLES_PASSED_ARB); 104 104 #endif … … 134 134 { 135 135 #ifdef _WIN32 136 137 136 // VH 137 glGetOcclusionQueryuivNV(mId, GL_PIXEL_COUNT_AVAILABLE_NV, &available); 138 138 #endif 139 139 } … … 180 180 // VH 181 181 glGenQueriesARB(n, (unsigned int *)newQueries); 182 cout << "creating " << n << " arb queries" << endl;182 //cout << "creating " << n << " arb queries" << endl; 183 183 #endif 184 184 } … … 188 188 // VH 189 189 glGenOcclusionQueriesNV(n, (unsigned int *)newQueries); 190 cout << "creating " << n << " nv queries" << endl;190 //cout << "creating " << n << " nv queries" << endl; 191 191 #endif 192 192 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2667 r2669 31 31 #include <QVBoxLayout> 32 32 33 namespace GtpVisibilityPreprocessor {34 33 namespace GtpVisibilityPreprocessor 34 { 35 35 36 36 … … 41 41 static CGprofile sCgFragmentProfile; 42 42 43 44 //static vector<OcclusionQuery *> sQueries;45 43 46 44 QtGlRendererWidget *rendererWidget = NULL; … … 88 86 ViewCellsManager *viewcells, 89 87 KdTree *tree): 90 QGLPixelBuffer(QSize(w, h), QGLFormat(QGL::StencilBuffer | QGL::DirectRendering | QGL::DepthBuffer | QGL::Rgba)), 88 QGLPixelBuffer(QSize(w, h), 89 QGLFormat(QGL::StencilBuffer | 90 QGL::DepthBuffer | 91 QGL::DoubleBuffer | 92 QGL::Rgba 93 )), 91 94 GlRendererBuffer(sceneGraph, viewcells, tree) 92 95 { … … 125 128 MakeCurrent(); 126 129 127 /* 128 SetupCamera(); 129 RenderScene(); 130 */ 130 cout << "stencil: " << format().stencil() << endl; 131 cout << "depth: " << format().depth() << endl; 132 cout << "rgba: " << format().rgba() << endl; 133 cout << "double: " << format().doubleBuffer() << endl; 134 131 135 float pErrorPixels = -1.0f; 132 136 … … 134 138 unsigned int pixelCount = 0; 135 139 136 140 137 141 ViewCell *viewcell = mViewCellsManager->GetViewCell(mViewPoint); 138 142 139 143 if (viewcell == NULL) 140 144 return -1.0f; 145 146 KdNode::NewMail2(); 147 Intersectable::NewMail(); 141 148 142 149 ObjectPvs pvs; … … 150 157 mViewCellsManager->ApplyFilter2(viewcell, false, mViewCellsManager->GetFilterWidth(), pvs); 151 158 152 153 mUseForcedColors = true;154 155 SetupCamera();156 157 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);158 glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE);159 glColor3f(0,1,0);160 glDepthFunc(GL_LESS );161 glEnable(GL_DEPTH_TEST);162 163 glDisable(GL_STENCIL_TEST);164 165 159 pvsSize = pvs.GetSize(); 166 167 Intersectable::NewMail();168 160 169 161 if (pvsSize == 0) 170 162 return 0.0f; 171 163 172 RenderPvs(pvs); 173 174 //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 164 mUseForcedColors = true; 165 166 SetupCamera(); 167 168 // use shading 169 if (mSnapErrorFrames) 170 { 171 172 GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0}; 173 GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0}; 174 GLfloat light_specular[] = {1.0, 1.0, 1.0, 1.0}; 175 176 GLfloat light_position[] = //{278.0f, 548.8f,279.0f, 1.0f}; 177 {0.f,0.f,0.f, 1.0f}; 178 179 glEnable(GL_LIGHT0); 180 181 // a light 182 glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); 183 glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); 184 glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); 185 186 glEnable(GL_LIGHTING); 187 glLightfv (GL_LIGHT0, GL_POSITION, light_position); 188 189 glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); 190 glEnable(GL_COLOR_MATERIAL); 191 192 glShadeModel(GL_SMOOTH); 193 } 194 195 glDisable(GL_ALPHA_TEST); 196 175 197 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 198 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 199 200 //glColorMask(GL_FALSE, GL_TRUE, GL_FALSE, GL_TRUE); 201 glColor3f(0, 1, 0); 202 203 glDepthFunc(GL_LESS); 204 glDepthMask(GL_TRUE); 205 glEnable(GL_DEPTH_TEST); 176 206 177 207 glStencilFunc(GL_EQUAL, 0x0, 0x1); 178 208 glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); 209 210 211 // render pvs once 212 RenderPvs(pvs); 213 214 //glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); 215 //glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE); 216 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 217 179 218 glEnable(GL_STENCIL_TEST); 180 181 219 glColor3f(1,0,0); 182 220 183 221 184 OcclusionQuery *query = mOcclusionQueries[1]; 185 222 // render scene, record differences 223 OcclusionQuery *query = mOcclusionQueries[0]; 224 225 KdNode::NewMail2(); 186 226 Intersectable::NewMail(); 187 227 … … 236 276 } 237 277 } 238 278 279 280 #if 0 239 281 mUseFalseColors = false; 282 240 283 glPushAttrib(GL_CURRENT_BIT); 241 glColor3f(0,1,0); 284 glColor3f(0, 1, 0); 285 242 286 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 243 287 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 244 288 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); 245 289 290 KdNode::NewMail2(); 291 Intersectable::NewMail(); 292 246 293 RenderPvs(pvs); 247 294 295 glFinish(); 296 248 297 mUseForcedColors = false; 298 249 299 im = toImage(); 250 300 sprintf(filename, "error-frame-%04d-%0.5f-pvs.png", mFrame, pErrorPixels); … … 252 302 qstr = str.c_str(); 253 303 im.save(qstr, "PNG"); 304 254 305 glPopAttrib(); 306 #endif 255 307 } 256 308 … … 449 501 int indexBufferSize = 0; 450 502 503 // super hack: mal not working with multiple threads 451 504 KdNode::NewMail2(); 452 505 //Intersectable::NewMail(); … … 503 556 504 557 EnableDrawArrays(); 505 //Intersectable::NewMail(); 506 558 507 559 if (mDetectEmptyViewSpace) 508 560 glEnable(GL_CULL_FACE);
Note: See TracChangeset
for help on using the changeset viewer.