Changeset 1951 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 01/07/07 18:39:35 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r1867 r1951 2183 2183 Vector3 AxisAlignedBox3::Diagonal() const 2184 2184 { 2185 return (mMax - mMin);2185 return (mMax - mMin); 2186 2186 } 2187 2187 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
r1950 r1951 25 25 static int texWidth = 256; 26 26 static int texHeight = 256; 27 static Vector3 scaleFactor = Vector3(2000.0f, 2000.0f, 2000.0f); 28 static Vector3 translFactor = Vector3(1000.0f, 1000.0f, 1000.0f); 27 29 28 30 static void cgErrorCallback() … … 64 66 //gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 3, 5000.0); 65 67 //gluPerspective(60.0, (GLfloat)w/(GLfloat)h, 0.5, 10.0); 66 glOrtho(-1 000, 1000, -1000, 1000, 1, 1000);68 glOrtho(-1, 1, -1, 1, 0.5, 15); 67 69 } 68 70 … … 70 72 void Display() 71 73 { 72 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);73 glMatrixMode(GL_MODELVIEW);74 glPushMatrix();75 76 74 //globalLinesRenderer->DrawGeometry(); 77 78 75 globalLinesRenderer->CastGlobalLines(Beam(), 0); 79 80 76 PrintGLerror("display"); 81 77 82 glPopMatrix();83 78 glutSwapBuffers(); 84 79 } … … 152 147 void GlobalLinesRenderer::DrawGeometry() 153 148 { 154 //mRenderer->mUseFalseColors = true; 155 ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 156 157 Intersectable::NewMail(); 158 159 for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 160 { 161 RenderObject(*oit); 162 } 149 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 150 glMatrixMode(GL_MODELVIEW); 151 152 glPushMatrix(); 153 { 154 glLoadIdentity(); 155 //translFactor = Vector3(-1, -1, -1); 156 157 glScalef(scaleFactor.x, scaleFactor.y, scaleFactor.z); 158 glTranslatef(translFactor.x, translFactor.y, translFactor.z); 159 160 //cout << "scale: " << scaleFactor << endl; 161 //cout << "transl: " << translFactor << endl; 162 163 //mRenderer->mUseFalseColors = true; 164 ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 165 166 Intersectable::NewMail(); 167 168 for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 169 { 170 RenderObject(*oit); 171 } 172 } 173 glPopMatrix(); 163 174 } 164 175 … … 197 208 198 209 AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 199 const Vector3 midPoint = bbox.Center(); 200 //const Vector3 viewPoint = midPoint + Vector3(-800, 0, 0); 201 const Vector3 viewPoint = midPoint + Vector3(2, 0, 0); 202 203 cout << "midPoint: " << midPoint << endl; 204 cout << "viewPoint: " << viewPoint << endl; 210 211 Vector3 center = bbox.Center(); 212 translFactor = -center; 213 //translFactor.z = 0; 214 //translFactor = Vector3(-1500, -1500, -1500); 215 float diag = 2.0f / Magnitude(bbox.Diagonal()); 216 scaleFactor = Vector3(diag, diag, diag); 217 218 Vector3 midPoint = Vector3(0, 0, 0); 219 Vector3 viewPoint = Vector3(0, 0, 500); 220 221 cout << "mid point: " << midPoint << endl; 222 cout << "view point: " << viewPoint << endl; 205 223 cout << "scene: " << bbox << endl; 206 224 … … 246 264 cgCreateProgramFromFile(sCgContext, 247 265 CG_SOURCE, 248 "../src/depth_peeling.cg", 266 mNewBuffer->IsRectangleTexture() ? 267 "../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg", 249 268 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 250 269 NULL, … … 269 288 cgGLLoadProgram(sCgPassThroughProgram); 270 289 } 271 272 290 273 291 // setup the rendering context for the RenderTexture … … 289 307 midPoint.x, midPoint.y, midPoint.z, 290 308 0, 1, 0); 291 292 309 } 293 310 mNewBuffer->EndCapture(); … … 331 348 void GlobalLinesRenderer::ApplyDepthPeeling(Beam &beam, const int samples) 332 349 { 333 //if (mNewBuffer->IsDoubleBuffered())334 // glDrawBuffer(GL_BACK);335 336 350 mNewBuffer->BeginCapture(); 337 351 { 338 352 //cgGLBindProgram(sCgPassThroughProgram); 339 353 //cgGLEnableProfile(sCgFragmentProfile); 340 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 341 glMatrixMode(GL_MODELVIEW); 342 glPushMatrix(); 343 { 344 //glutSolidTorus(0.25, 1, 32, 64); 345 DrawGeometry(); 346 } 347 glPopMatrix(); 354 DrawGeometry(); 348 355 } 349 356 mNewBuffer->EndCapture(); 350 357 351 358 //mNewBuffer->BindDepth(); 352 float *data = new float[texWidth * texHeight];359 /*float *data = new float[texWidth * texHeight]; 353 360 //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 354 361 const int texFormat = GL_LUMINANCE; … … 356 363 357 364 delete [] data; 358 359 PrintGLerror(" get data");365 */ 366 PrintGLerror("firstpass"); 360 367 361 368 if (mNewBuffer->IsRectangleTexture()) cout << "rect" << endl; 362 //else cout << "haga"<<endl;363 369 364 370 for(int i = 0; i < mMaxDepth; ++ i) … … 380 386 cgGLEnableTextureParameter(sTextureParam); 381 387 382 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 383 glMatrixMode(GL_MODELVIEW); 384 glPushMatrix(); 385 { 386 //glutSolidTorus(0.25, 1, 32, 64); 387 DrawGeometry(); 388 } 388 //glutSolidTorus(0.25, 1, 32, 64); 389 DrawGeometry(); 390 389 391 glPopMatrix(); 390 392 … … 395 397 } 396 398 397 PrintGLerror(" display 1");399 PrintGLerror("endpeeling"); 398 400 399 401 //mNewBuffer->Bind(); 400 402 mNewBuffer->BindDepth(); 401 403 mNewBuffer->EnableTextureTarget(); 402 403 404 PrintGLerror("display 2"); 405 glColor3f(1,1,1); 406 glBegin(GL_QUADS); 407 glTexCoord2f(0, 0); glVertex3f(-1000, -1000, -0.5f); 408 glTexCoord2f(1, 0); glVertex3f( 1000, -1000, -0.5f); 409 glTexCoord2f(1, 1); glVertex3f( 1000, 1000, -0.5f); 410 glTexCoord2f(0, 1); glVertex3f(-1000, 1000, -0.5f); 411 glEnd(); 412 413 if (mNewBuffer->IsFloatTexture()) 414 { 415 // cgGLDisableTextureParameter(textureParam); 416 // cgGLDisableProfile(theProfile); 417 } 418 else 419 { 420 mNewBuffer->DisableTextureTarget(); 421 } 422 } 423 424 425 } 404 405 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 406 407 if (mNewBuffer->IsRectangleTexture()) 408 { 409 glBegin(GL_QUADS); 410 glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f); 411 glTexCoord2f(mNewBuffer->GetWidth(), 0); glVertex3f( 1, -1, -0.5f); 412 glTexCoord2f(mNewBuffer->GetWidth(), mNewBuffer->GetHeight()); glVertex3f( 1, 1, -0.5f); 413 glTexCoord2f(0, mNewBuffer->GetHeight()); glVertex3f(-1, 1, -0.5f); 414 glEnd(); 415 } 416 else 417 { 418 glBegin(GL_QUADS); 419 glTexCoord2f(0, 0); glVertex3f(-1, -1, -0.5f); 420 glTexCoord2f(1, 0); glVertex3f( 1, -1, -0.5f); 421 glTexCoord2f(1, 1); glVertex3f( 1, 1, -0.5f); 422 glTexCoord2f(0, 1); glVertex3f(-1, 1, -0.5f); 423 glEnd(); 424 } 425 426 mNewBuffer->DisableTextureTarget(); 427 PrintGLerror("displaytexture"); 428 } 429 430 431 }
Note: See TracChangeset
for help on using the changeset viewer.