- Timestamp:
- Feb 26, 2009, 12:23:47 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/source/visualization/OpenGL/src/G4OpenGLSceneHandler.cc
r931 r933 160 160 void G4OpenGLSceneHandler::AddPrimitive (const G4Polyline& line) 161 161 { 162 printf("----1");163 162 G4int nPoints = line.size (); 164 163 if (nPoints <= 0) return; … … 369 368 // Draw... 370 369 if (sizeType == world) { // Size specified in world coordinates. 371 printf("G4OpenGLSceneHandler::AddCircleSquare world\n");372 370 DrawXYPolygon (shape, size, centre, pVA); 373 371 374 372 } else { // Size specified in screen (window) coordinates. 375 printf("G4OpenGLSceneHandler::AddCircleSquare screen bitmap size:%d\n",size); 376 377 int test=3; 378 if (test == 1) { 379 // Find window coordinates of centre... 380 GLdouble modelMatrix[16]; 381 glGetDoublev (GL_MODELVIEW_MATRIX, modelMatrix); 382 G4double projectionMatrix[16]; 383 glGetDoublev (GL_PROJECTION_MATRIX, projectionMatrix); 384 GLint viewport[4]; 385 glGetIntegerv(GL_VIEWPORT,viewport); 386 GLdouble winx, winy, winz; 387 gluProject(centre.x(), centre.y(), centre.z(), 388 modelMatrix, projectionMatrix, viewport, 389 &winx, &winy, &winz); 390 391 // Determine ratio window:world... 392 const G4Vector3D& viewpointDirection = 393 fpViewer -> GetViewParameters().GetViewpointDirection(); 394 const G4Vector3D& up = fpViewer->GetViewParameters().GetUpVector(); 395 const G4Vector3D inScreen = (up.cross(viewpointDirection)).unit(); 396 const G4Vector3D p = centre + inScreen; 397 GLdouble winDx, winDy, winDz; 398 gluProject(p.x(), p.y(), p.z(), 399 modelMatrix, projectionMatrix, viewport, 400 &winDx, &winDy, &winDz); 401 G4double winWorldRatio = std::sqrt(std::pow(winx - winDx, 2) + 402 std::pow(winy - winDy, 2)); 403 DrawXYPolygon (shape, size/winWorldRatio, centre, pVA); 404 405 } else if (test == 2) { 406 // glMatrixMode(GL_PROJECTION); 407 glPushMatrix(); 408 // glLoadIdentity(); 409 // gluOrtho2D(0.0,640.0,480.0,10.0); 410 411 // glDisable(GL_DEPTH_TEST); 412 glRotatef (30, 0, -1, 0); 413 glRotatef (20, -1, 0, 0); 414 glRotatef (50, 0, 0, -1); 415 DrawXYPolygon (shape, size, centre, pVA); 416 417 418 glPopMatrix(); 419 420 // glMatrixMode(GL_MODELVIEW); 421 // glEnable(GL_DEPTH_TEST); 422 } else if (test == 3){ // Avec DrawPolygone, mais en forcant 423 424 glPointSize (size); 425 glBegin (GL_POINTS); 426 glVertex3f(centre.x(),centre.y(),centre.z()); 427 glEnd(); 428 //Antialiasing sur les points 429 glEnable (GL_POINT_SMOOTH); 430 //Gestion de la transparence 431 glEnable(GL_BLEND); 432 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 433 434 // const G4Point3D targetPoint 435 // = fSceneHandler.GetScene()->GetStandardTargetPoint() 436 // + fVP.GetCurrentTargetPoint (); 437 // G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius(); 438 // if(radius<=0.) radius = 1.; 439 // const G4double cameraDistance = fVP.GetCameraDistance (radius); 440 // const G4Point3D cameraPosition = 441 // targetPoint + cameraDistance * fVP.GetViewpointDirection().unit(); 442 } else { 443 glRasterPos3d(centre.x(),centre.y(),centre.z()); 444 const GLubyte* marker = 445 G4OpenGLBitMapStore::GetBitMap(shape, size, filled); 446 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 447 glBitmap(GLsizei(size), GLsizei(size), size/2., size/2., 0., 0., marker); 448 } 373 glPointSize (size); 374 glBegin (GL_POINTS); 375 glVertex3f(centre.x(),centre.y(),centre.z()); 376 glEnd(); 377 //Antialiasing 378 glEnable (GL_POINT_SMOOTH); 379 //Transparency 380 glEnable(GL_BLEND); 381 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 382 // glRasterPos3d(centre.x(),centre.y(),centre.z()); 383 // const GLubyte* marker = 384 // G4OpenGLBitMapStore::GetBitMap(shape, size, filled); 385 // glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 386 // glBitmap(GLsizei(size), GLsizei(size), size/2., size/2., 0., 0., marker); 449 387 } 450 388 }
Note: See TracChangeset
for help on using the changeset viewer.