Re: [ROOT] Query about 3-d drawing classes

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Apr 02 2002 - 09:08:22 MEST


Hi Tom,

Tom Roberts wrote:
> 
> I am new to root, and have been trying to use the 3-d drawing classes.
> Does anybody have a simple example of ray-tracing through a target?
> Is there a tutorial or set of examples anywhere? The Root User's Guide
> has none, and the examples in $ROOTSYS/tutorials are not very complete.
> 
> I have several puzzles:
>  1) I don't understand what coordinates are being used. For instance,
>     when I change the {dx,dy,dz} in a TBRIK constructor the picture
>     does not change. It looks like there is some sort of automatic
>     scaling going on (this TBRIK is the only object). I guess I'll
>     just draw an invisible TBRIK object enclosing the entire system.

When you draw a geometry 3-d object in the pad, it is automatically scaled
to occupy the full pad. As you have found out, simply place this object inside
another object (the reference frame) to see it scaled.

>  2) The TBRIK object does not seem to fill itself. I tried many
>     variations on SetFillColor() and SetFillStyle(). None worked.

Color Fill area is not supported (yet) when drawing 3-d geometry objects
in the pad. It is supported by X3D or OpenGL. To see the graphics in your pad
with the x3D viewer, use the "View" option "View with X3D" in the canvas tool
bar.
See the HELP button in the X3D viewer to switch between the various drawing
modes.
The default view is "wireframe" mode. To switch to "hidden line" mode,
press the character "E" when your mouse is in the X3D canvas.
To toggle the "hidden surface" mode, press the character "R", etc

>  3) I cannot figure out how to get TPolyLine3D to display its line.
>     This could be related to (1) and the coordinates are simply off
>     the screen. Using a thin and narrow TBRIK for each ray is difficult,
>     as I need to figure out how to rotate them....

I do not understand this point

>  4) the TNode-s seem to automatically link themselves together in
>     a list. The use of TNode::cd() is rather puzzling. Anybody know
>     what is going on?

The TNode can be used to create a hierarchy in your geometry. What is puzzling?

>  5) TGeometry seems to be related to this, but shapes.C does not use
>     one, and the nodes (or shapes ?) seem to be linked into the canvas?
> 

A default TGeometry object is created by ROOT if you do not create one.
see $ROOTSYS/tutorials/na49.C for an example with several levels of hierarchy.

> Below is my test script, based upon tutorials/shapes.C. The TBRIK
> object displays its lines, and I can rotate it using the mouse,
> but it is not filled.

Proceed as indicated above to see your objects with the X3D viewer.
You can also add the statement
    c1->x3d();
at the end of your script (see your code below)

Rene Brun
> 
> Any help or pointers would be appreciated.
> 
> Tom Roberts     tjrob@fnal.gov
> 
> {
>    c1 = new TCanvas("c1","Test Ray-Tracing",800,600);
>    c1->SetFillColor(10);
> 
>    TBRIK *tgt = new TBRIK("Target","Target","void",150,150,150);
>    tgt->SetLineColor(1);
>    tgt->SetFillColor(2);
>    tgt->SetFillStyle(1001);
> 
>    //  Build the geometry hierarchy
>    node1 = new TNode("NODE1","NODE1",tgt);
>    node1->cd();
> 
>    // Draw this geometry in the current canvas
>    node1->cd();
>    node1->Draw();
>    c1->Update();
     c1->x3d();  //<===add this line to view your scene with the X3D viewer
> }



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:47 MET