| 247 | } |
| 248 | |
| 249 | void G4OpenInventorViewer::SetView () { |
| 250 | |
| 251 | // Get G4 camera infos : |
| 252 | const G4Point3D target |
| 253 | = fSceneHandler.GetScene()->GetStandardTargetPoint() |
| 254 | + fVP.GetCurrentTargetPoint (); |
| 255 | G4double radius = fSceneHandler.GetScene()->GetExtent().GetExtentRadius(); |
| 256 | if(radius<=0.) radius = 1.; |
| 257 | const G4double cameraDistance = fVP.GetCameraDistance (radius); |
| 258 | const G4Vector3D& direction = fVP.GetViewpointDirection().unit(); |
| 259 | const G4Point3D cameraPosition = target + cameraDistance * direction; |
| 260 | //const G4double pnear = fVP.GetNearDistance (cameraDistance, radius); |
| 261 | //const G4double pfar = fVP.GetFarDistance (cameraDistance, pnear, radius); |
| 262 | const G4Normal3D& up = fVP.GetUpVector (); |
| 263 | |
| 264 | /* |
| 265 | printf("debug : target : %g %g %g\n",target.x(), |
| 266 | target.y(), |
| 267 | target.z()); |
| 268 | printf("debug : dir : %g %g %g\n",direction.x(), |
| 269 | direction.y(), |
| 270 | direction.z()); |
| 271 | printf("debug : pos : %g %g %g\n",cameraPosition.x(), |
| 272 | cameraPosition.y(), |
| 273 | cameraPosition.z()); |
| 274 | //printf("debug : near %g far %g\n",pnear,pfar); |
| 275 | */ |
| 276 | |
| 277 | SoCamera* camera = GetCamera(); |
| 278 | if(!camera) return; |
| 279 | |
| 280 | // viewer camera setup : |
| 281 | camera->position.setValue((float)cameraPosition.x(), |
| 282 | (float)cameraPosition.y(), |
| 283 | (float)cameraPosition.z()); |
| 284 | |
| 285 | SbVec3f sbTarget((float)target.x(), |
| 286 | (float)target.y(), |
| 287 | (float)target.z()); |
| 288 | SbVec3f sbUp((float)up.x(), |
| 289 | (float)up.y(), |
| 290 | (float)up.z()); |
| 291 | sbUp.normalize(); |
| 292 | // Need Coin's camera->pointAt(sbTarget,sbUp); not in the SGI API |
| 293 | // Stole Coin's code... |
| 294 | pointAt(camera,sbTarget,sbUp); |
| 295 | |
| 296 | //camera->height.setValue(10); |
| 297 | //camera->nearDistance.setValue((float)pnear); |
| 298 | //camera->farDistance.setValue((float)pfar); |
| 299 | //camera->focalDistance.setValue((float)cameraDistance); |
| 300 | |
| 301 | if(camera->isOfType(SoOrthographicCamera::getClassTypeId())) { |
| 302 | if (fVP.GetFieldHalfAngle() == 0.) { |
| 303 | //FIXME : ((SoOrthographicCamera*)camera)->height.setValue(); |
| 304 | //FIXME : (Don't think we have to do that.) |
| 305 | } else { |
| 306 | //FIXME : Have to set a perspective camera ! |
nothing calls this directly
no test coverage detected