Changeset 271
- Timestamp:
- 10/10/06 18:01:16 (2 years ago)
- Files:
-
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGOcclusionCullingTreeBuilder.cpp (modified) (9 diffs)
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderPartition.cpp (modified) (1 diff)
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderTreeNode.cpp (modified) (1 diff)
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderTreeNode.h (modified) (2 diffs)
- branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderTreeNode.inl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGOcclusionCullingTreeBuilder.cpp
r268 r271 54 54 #include "OSGRenderPartition.h" 55 55 #include "OSGRenderTraversalAction.h" 56 #include "OSGVolumeDraw.h" 56 57 57 58 //#define OSG_DUMP_SORTING … … 132 133 UInt32 current_node = 1; 133 134 GLuint queries[uNumNodes]; 134 std::cout << "Submitting " << uNumNodes << " queries" << std::endl;135 //std::cout << "Submitting " << uNumNodes << " queries" << std::endl; 135 136 136 137 GenQueryT genquer = (GenQueryT)win->getFunction(_funcGenQueriesARB); … … 138 139 139 140 //glGenQueriesARB(uNumNodes, queries); 141 std::cout << "Calculated Pixels" << std::endl; 140 142 drawNode(_pRoot, denv, part, screen_covered_percentage, current_node, queries); 141 std::cout << "Calc Pixels" << std::endl;143 //std::cout << "Calc Pixels" << std::endl; 142 144 143 145 GetQueryObjectuivT getquiv = … … 148 150 sc->getElem(statNOccInvisible)->set(0); // Just create it 149 151 152 std::cout << std::endl; 153 std::cout << "Real pixels " << std::endl; 150 154 for(UInt32 i = 1; i<uNumNodes; i++) 151 155 { 152 156 GLuint available = 0; 153 157 getquiv(queries[i], GL_QUERY_RESULT_AVAILABLE_ARB, &available); 158 /* 159 if (!available) 160 { 161 std::cout << std::endl << "Waiting on " << i << "th query"; 162 } 163 */ 154 164 while (!available) 155 165 { 156 std::cout << "Waiting on " << i << "th query" << std::endl; 157 getquiv(queries[i], GL_QUERY_RESULT_AVAILABLE_ARB, &available); 158 //glGetQueryObjectivARB(queries[i], GL_QUERY_RESULT_AVAILABLE_ARB, &available); 159 } 166 //std::cout << "."; 167 getquiv(queries[i], GL_QUERY_RESULT_AVAILABLE_ARB, &available); 168 //glGetQueryObjectivARB(queries[i], GL_QUERY_RESULT_AVAILABLE_ARB, &available); 169 /* 170 if(available) 171 { 172 std::cout << std::endl; 173 } 174 */ 175 } 176 160 177 GLuint sampleCount = 0; 161 178 getquiv(queries[i], GL_QUERY_RESULT_ARB, &sampleCount); … … 177 194 while (pNode != NULL) 178 195 { 179 Int32 pix_width = denv.getViewport()->getPixelWidth(); 180 Int32 pix_height = denv.getViewport()->getPixelHeight(); 196 Viewport* vp = denv.getViewport(); 197 Int32 pix_width = vp->getPixelWidth(); 198 Int32 pix_height = vp->getPixelHeight(); 199 200 Matrix worldToCam; 201 vp->getCamera()->getWorldToScreen(worldToCam, *vp); 202 181 203 182 204 UInt32 uiNextMatrix = pNode->getMatrixStore().first; … … 218 240 } 219 241 } 220 242 DynamicVolume volume = pNode->getVol(); 243 Pnt3r min,max; 244 //volume.transform(_accMatrix); 245 volume.getBounds(min, max); 246 Pnt3r p[8]; 247 p[0].setValues(min[0],min[1],min[2]); 248 p[1].setValues(max[0],min[1],min[2]); 249 p[2].setValues(min[0],max[1],min[2]); 250 p[3].setValues(min[0],min[1],max[2]); 251 p[4].setValues(max[0],max[1],min[2]); 252 p[5].setValues(max[0],min[1],max[2]); 253 p[6].setValues(min[0],max[1],max[2]); 254 p[7].setValues(max[0],max[1],max[2]); 255 256 //std::cout << "OtoW:" << std::endl; 257 //std::cout << denv.getObjectToWorld() << std::endl; 258 //std::cout << "WtoC:" << std::endl; 259 //std::cout << worldToCam << std::endl; 260 for(UInt32 i = 0; i<8;i++) 261 { 262 // std::cout << p[i] << "=>"; 263 denv.getObjectToWorld().mult(p[i]); 264 worldToCam.multFullMatrixPnt(p[i]); 265 //std::cout << p[i] << " "; 266 } 267 min=p[0]; 268 max=p[0]; 269 for(UInt32 i = 0; i<8; i++) 270 { 271 for(UInt32 j=0; j<2; j++) 272 { 273 if(p[i][j] < min[j]) 274 { 275 min[j] = p[i][j]; 276 } 277 if(p[i][j] > max[j]) 278 { 279 max[j] = p[i][j]; 280 } 281 } 282 } 283 max[0] = osgClamp(-1.f, max[0], 1.f); 284 max[1] = osgClamp(-1.f, max[1], 1.f); 285 min[0] = osgClamp(-1.f, min[0], 1.f); 286 min[1] = osgClamp(-1.f, min[1], 1.f); 287 //std::cout << min << std::endl; 288 //std::cout << max << std::endl; 289 //v.transform(worldToCam); 290 Real32 pix; 291 pix = (max[0] - min[0]) * (max[1] - min[1]) * ((pix_width/2.0f)*(pix_height/2.0f)); 292 293 std::cout << cur_node << ":" << pix << " "; 294 // std::cout << max - min << std::endl; 295 296 221 297 State *pNewState = pNode->getState(); 222 298 StateOverride *pNewStateOverride = pNode->getStateOverride(); … … 226 302 Window* win = denv.getWindow(); 227 303 228 BeginQueryT beginq = (BeginQueryT) win->getFunction(_funcBeginQueryARB);229 beginq(GL_SAMPLES_PASSED_ARB, queries[cur_node]);230 304 //glBeginQueryARB(GL_SAMPLES_PASSED_ARB, queries[cur_node]); 231 232 305 if(pNode->hasFunctor() == true) 233 pNode->getFunctor()(&denv); 234 235 EndQueryT endq = (EndQueryT) win->getFunction(_funcEndQueryARB); 236 endq(GL_SAMPLES_PASSED_ARB); 237 //glEndQueryARB(GL_SAMPLES_PASSED_ARB); 238 239 cur_node++; 306 { 307 std::cout << " D "; 308 BeginQueryT beginq = (BeginQueryT) win->getFunction(_funcBeginQueryARB); 309 beginq(GL_SAMPLES_PASSED_ARB, queries[cur_node]); 310 if(1) 311 { 312 //glPushMatrix(); 313 //glLoadIdentity(); 314 //glMatrixMode(GL_PROJECTION); 315 //GLfloat m[16]; 316 //glGetFloatv(GL_PROJECTION_MATRIX, m); 317 //glLoadIdentity(); 318 //glOrtho(-1,1,-1,1,-1,1); 319 320 volume.getBounds(min, max); 321 static GLdouble n[6][3] = { 322 {-1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 0.0, 0.0}, 323 {0.0, -1.0, 0.0}, {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0} 324 }; 325 static GLint faces[6][4] = { 326 { 0, 1, 2, 3}, { 3, 2, 6, 7}, { 7, 6, 5, 4}, 327 { 4, 5, 1, 0}, { 5, 6, 2, 1}, { 7, 4, 0, 3} 328 }; 329 330 GLdouble v[8][3]; 331 v[0][0] = v[1][0] = v[2][0] = v[3][0] = min[0]; 332 v[4][0] = v[5][0] = v[6][0] = v[7][0] = max[0]; 333 v[0][1] = v[1][1] = v[4][1] = v[5][1] = min[1]; 334 v[2][1] = v[3][1] = v[6][1] = v[7][1] = max[1]; 335 v[0][2] = v[3][2] = v[4][2] = v[7][2] = min[2]; 336 v[1][2] = v[2][2] = v[5][2] = v[6][2] = max[2]; 337 glColor3f(0.3,0.4,0.6); 338 for(UInt32 i = 0; i<6; i++) 339 { 340 glBegin(GL_QUADS); 341 glNormal3dv(&n[i][0]); 342 glVertex3dv(&v[faces[i][0]][0]); 343 glNormal3dv(&n[i][0]); 344 glVertex3dv(&v[faces[i][1]][0]); 345 glNormal3dv(&n[i][0]); 346 glVertex3dv(&v[faces[i][2]][0]); 347 glNormal3dv(&n[i][0]); 348 glVertex3dv(&v[faces[i][3]][0]); 349 glEnd(); 350 } 351 //glLoadMatrixf(m); 352 //glMatrixMode(GL_MODELVIEW); 353 //glPopMatrix(); 354 } 355 else 356 { 357 drawVolume(volume); 358 pNode->getFunctor()(&denv); 359 } 360 361 EndQueryT endq = (EndQueryT) win->getFunction(_funcEndQueryARB); 362 endq(GL_SAMPLES_PASSED_ARB); 363 //glEndQueryARB(GL_SAMPLES_PASSED_ARB); 364 cur_node++; 365 } 366 367 240 368 241 369 if(pNode->getFirstChild() != NULL) … … 261 389 { 262 390 _pRoot->addChild(pNode); 391 uNumNodes++; 263 392 } 264 393 else … … 294 423 _pRoot->insertChildAfter(pLast, pNode); 295 424 } 425 uNumNodes++; 296 426 } 297 427 else 298 428 { 299 429 _pRoot->addChild(pNode); 300 } 301 } 302 uNumNodes++; 430 uNumNodes++; 431 } 432 } 433 303 434 } 304 435 branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderPartition.cpp
r268 r271 523 523 _currMatrix.second.mult(objPos); 524 524 525 Real32 objVol; 526 objVol = _oDrawEnv.getRTAction()->getActNode()->getVolume().getScalarVolume(); 527 pNewElem->setBBC ( objVol ); 525 DynamicVolume objVol; 526 objVol = _oDrawEnv.getRTAction()->getActNode()->getVolume(); 527 //objVol.transform(_currMatrix.second); 528 pNewElem->setVol ( objVol ); 528 529 529 530 pNewElem->setFunctor ( func ); branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderTreeNode.cpp
r267 r271 66 66 _oMatrixStore ( ), 67 67 _rScalarVal (0.f ), 68 _rBBCVal (0.f ),69 68 _lightsState (0 ) 70 69 { branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderTreeNode.h
r267 r271 101 101 Real32 getScalar (void ); 102 102 103 void set BBC (Real32 rBBC);104 Real32 getBBC(void );103 void setVol (DynamicVolume vol ); 104 DynamicVolume getVol (void ); 105 105 106 106 void setLightsState (UInt64 state ); … … 133 133 Real32 _rScalarVal; 134 134 135 Real32 _rBBCVal;135 DynamicVolume _dVol; 136 136 137 137 UInt64 _lightsState; branches/Dirk_RenderTraversalWork/Source/System/Action/RenderTraversal/OSGRenderTreeNode.inl
r267 r271 195 195 196 196 inline 197 void RenderTreeNode::set BBC(Real32 rBBC)198 { 199 _ rBBCVal = rBBC;200 } 201 202 inline 203 Real32 RenderTreeNode::getBBC(void)204 { 205 return _ rBBCVal;197 void RenderTreeNode::setVol(DynamicVolume vol) 198 { 199 _dVol = vol; 200 } 201 202 inline 203 DynamicVolume RenderTreeNode::getVol(void) 204 { 205 return _dVol; 206 206 } 207 207 … … 233 233 _rScalarVal = 0.f; 234 234 235 _rBBCVal = 0.f;236 237 235 _lightsState = 0; 238 236 }
