Draw 3d objects with gl viewer in different pads

Hi,

I would like to draw several 3d objects using the gl viewer into different pads of the same canvas. When I do myobj->Draw(“ogl”), I get the object drawn within the default gui, but not been able to draw it in different pads (each of those showing different projections of the same scene for example).

Any suggestion for doing this ?

Cheers,
Sergio

see examples in tutorial glsurfaces.C.
You must use the CVS version and specify the option “gl” instead
of “ogl” when drawing your 3d objects.

Rene

Hi Rene,

many thanks for your answer !!! Actually I tried that and the results looks very similar to what I get using the x3d viewer. I surely was not very clear defining my problem… I wanted to have access to the nice features shown in the root user-guide while using the open gl external viewer (lighting, materials, cameras, etc…) . I.e, I would like to be able to draw in different pads of the same canvas my 3d objects, and then modify lighting or camera views independently in each pad. With the “gl” option instead of the “ogl” I found that not working.

Am I missing something else ?

Thanks again.

cheers.
Sergio

[quote=“segonzal”]
!!! Actually I tried that and the results looks very similar to what I get using the x3d viewer. I surely was not very clear defining my problem… I wanted to have access to the nice features shown in the root user-guide while using the open gl external viewer (lighting, materials, cameras, etc…) . I.e, I would like to be able to draw in different pads of the same canvas my 3d objects, and then modify lighting or camera views independently in each pad. With the “gl” option instead of the “ogl” I found that not working.

Am I missing something else ?
Sergio[/quote]

  1. The current gl viewer is a singleton, and after we replaced TGLPixmap class (it was an obsolete primitive viewer) with TGLViewer, we cannot have several gl-pads with geometry (this is the way TGLViewer done). :frowning:
  2. Colour/transparency GUI works only in the standalone viewer. In pad we should have standard editors, but right now we do not have editor for TGeom or for TGLPhysicalShape, and even worse - TGLViewer works in such way, that it’s not trivial to implement correct selection/editor initialization. The only thing you can do with gl-viewer in pad :
  3. set clipping plane/box
  4. switch on/off lights
  5. set guides.

glsurfaces Rene mentioned is a different thing, that has nothing common with TGLViewer, it’s a variant of THistPainter (right now we can draw only subset of possible lego/surface otpions).

Hello Sergio, I am not sure I can suggest you what you want exactly.
Please, have a look at the picture attached. It is a screenshoot of the a single ROOT session with several different OpenGL views produced by the standard $ROOTSYS/tutorias/na49view.C macro (the further details can be found on root.bnl.gov )


To clarify what Timur said:

We are currently working in extensions of the GL viewer such that the
GL viewer can run in standard ROOT TPads, still taking advantage
of the hardware graphics accelerator.

A snapshot of this work is visible in the tutorial glsurfaces.C. Currently
the TGeo classes cannot be seen in this mode, but we expect to have it
working in the near future.
The advantage of this mode is that it is possible to have 3-d AND 2-d
standard graphics in the same pad, and/or to have a canvas with a detector shown in one pad and histograms shown in other pads.

We are also working on graphics editors for the geometry classes. They are supposed to work in the same way that, eg, the histogram editors.

Rene

With the current CVS head (thanks to Andrei Gheata) it is now possible to see different detector views in different pads of the same canvas using
the GL viewer and the hardware graphics acceleration.
see an example in this script. The file alice.root can be found at
ftp://root.cern.ch/root/alice.root

void paintAlice() { if (!gSystem->AccessPathName("alice.root")) { TGeoManager::Import("alice.root"); } else { printf(" ERROR: To run this script you must copy the Alice geometry from\n"); printf(" ftp://root.cern.ch/root/alice.root\n"); return; } TCanvas *c = new TCanvas("glAlice", "The ALICE geometry"); c->Divide(2,2,0,0); c->cd(1); gGeoManager->GetVolume("FMD1")->Draw("gl"); c->cd(2); gGeoManager->GetVolume("B076")->Draw("gl"); c->cd(3); gGeoManager->GetVolume("0STR")->Draw("gl"); c->cd(4); gGeoManager->GetVolume("RICH")->Draw("gl"); }

Rene

[quote=“brun”] The file alice.root can be found at
ftp://root.cern.ch/root/alice.root[/quote]
Is the URL correct? I can not download it.
Web browsers says,

Valeri, the file alice.root is there. Refresh your browser.

You should see the picture below. With the mouse you can rotate, zoom, pan the individual pads.

Rene


[quote=“brun”]Valeri, the file alice.root is there.[/quote]Hello Rene. Thank you very much for your file. I was able to download it from home.
First I tried the well-known Pad wired view (with no OpenGL) , i.e. I applied method Draw with no parameter. I got some strange result. See second picture attached. Does that mean the “old” way to paint any ROOT TObject with “Draw” method can not be applied for TGeo’s ?
Anyway, I think the original Sergio’s question was (may be I am wrong, he did not elaborate yet) about [quote=“segonzal”]“different projections of the same scene”[/quote] simultaneously?" I.e. I thought the question was about the capability my first attachment demonstrates.

I have one extra question. The “import” geometry output:

Info in <TGeoManager::SetTopVolume>: Top volume is FMD1. Master volume is ALIC Painter created --- Drawing 62 nodes with 5 visible levelssuggests the “number of the visible levels” is the object property. Does this mean one can not render one and the same object with the different visible levels simultanelously?




Hi Valeri,

Are you sure you have compiled the head with the latest modifications ?

You should not get this message with the new stuff

Currently there are 2 modes: by default the visible depth is computed automatically such that the number of nodes on the screen is less than gGeoManager->GetMaxVisNodes(); The second mode is when the user calls gGeoManager->SetVisLevel(n), when “n” becomes a global parameter. What you ask I guess is if one can produce a view of a volume having a depth and another view with another depth. The answer is yes:

gGeoManager->SetVisLevel(3);
myVolume->Draw("ogl");
new TCanvas();
gGeoManager->SetVisLevel(5);
myVolume->Draw("ogl");

Cheers,

Hi Rene, Valer and Andrei,

first of all many thanks for all your answers. I’ve just compiled the head version (today) and was just able to use Rene’s macro with the Draw method (skipping the “gl” option). The result is the attached picture, which I think is the correct one. But I did not manage to get it working with “gl”, I just got empty pads.

The output of Rene’s macro is:

Processing paintAlice.C…
Info: TGeoManager::Import : Reading geometry from file
Info in TGeoManager::CloseGeometry: Geometry loaded from file…
Info in TGeoManager::SetTopVolume: Top volume is ALIC. Master volume is ALIC
Info in TGeoManager::CloseGeometry: Voxelization retrieved from file
Info in TGeoManager::BuildCache: — Maximum geometry depth is 11
Info in TGeoManager::CloseGeometry: 2514970 nodes/ 2869 volume UID’s in default geometry
Info in TGeoManager::CloseGeometry: ----------------modeler ready----------------
Painter created
— Drawing 62 nodes with 5 visible levels
— Drawing 152 nodes with 4 visible levels
— Drawing 460 nodes with 5 visible levels
— Drawing 789 nodes with 4 visible levels

Did I forgot to add some option during the compilation (I just used ./configure, make).

Thanks again for all your help.

Cheers,
Sergio

No, this is not the right picture.
It looks like you installed ROOT without GL support.
On which system are you running? Could you send me the files
config.status and config.log (in $ROOTSYS).

Rene

[quote=“segonzal”]Hi Rene, Valer and Andrei,

first of all many thanks for all your answers. I’ve just compiled the head version (today) and was just able to use Rene’s macro with the Draw method (skipping the “gl” option). The result is the attached picture, which I think is the correct one. But I did not manage to get it working with “gl”, I just got empty pads.

Sergio[/quote]

Try to resize pad or click/move l-pressed mouse in a canvas :slight_smile: