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;
view->Setview(10,20,30,irep);
gPad->Modified();
gPad->Update();

That didn’t seem to do much.

I now tried this:

TGLViewer::ECameraType camera = TGLViewer::kCameraOrthoXOZ;
TGLViewer *v = (TGLViewer *)gPad->GetViewer3D();
v->SetCurrentCamera(camera);
v->CurrentCamera().SetExternalCenter(kTRUE);
TGLOrthoCamera& o = v->CurrentCamera();
o.SetEnableRotate(kTRUE);

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.

Hi,

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);
or
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.

Best,
Matevz

thanks for your reply!