How to change viewing angle of geometry

Hi everyone! I am playing around with TGeoManager to draw some 3D pictures. I’m looking at the result using ROOT’s OpenGL viewer. I would like to select the viewing angle by code. I tried:

TView *view = gPad->GetView();
Int_t irep;

That didn’t seem to do much.

I now tried this:

TGLViewer::ECameraType camera = TGLViewer::kCameraOrthoXOZ;
TGLViewer *v = (TGLViewer *)gPad->GetViewer3D();
TGLOrthoCamera& o = v->CurrentCamera();

Double_t zoom      = 0.78;
Double_t dolly     = 4;
Double_t center[3] = {0,0,0};
Double_t hRotate   = 0.01;
Double_t vRotate   = 0.01;

v->SetOrthoCamera(camera, zoom, dolly, center, hRotate, vRotate);

Which almost does what I want. The only thing is that I don’t really seem to be able to slightly rotate the camera.


You’re getting closer :slight_smile: in fact what you do should be ok.
The angle is in radians.

You can also call the following two functions directly on the camera:

 virtual void Configure(Double_t zoom, Double_t dolly,
                                 Double_t center[3],
                                Double_t hRotate, Double_t vRotate) = 0;
virtual Bool_t RotateRad(Double_t hRotate, Double_t vRotate);

Also, you should call
void RequestDraw(Short_t LOD = TGLRnrCtx::kLODHigh);
void DoDraw();
on the gl viewer afterwards to force it to redraw.

Maybe look also at the examples in tutorials/eve/, in particular geom_atlas.C. It does something similar to what you are trying to achieve.


thanks for your reply!