root: 3d graphics r. maunder 1), t.pocheptsov 4) 1) cern – european organization for nuclear...

2
ROOT: 3D Graphics R. Maunder R. Maunder 1) , , T.Pocheptsov T.Pocheptsov 4) 4) 1) 1) CERN – European Organization for Nuclear Research, Geneva, Switzerland CERN – European Organization for Nuclear Research, Geneva, Switzerland 4) 4) Joint Institute for Nuclear Research (JINR) Joint Institute for Nuclear Research (JINR) Viewer Architecture TVirtualViewer3D: Provides generic access to viewers of widely differing capabilities (OpenGL/x3d/TPad). Can test preferences, manage scenes, add objects, adjust camera, lights etc externally (future extension) etc. TBuffer3D: 3D Object hierarchy – describe “shapes”. Generic TBuffer3D for any object in tessellated form. Subclasses for shape specific examples (TBuffer3DSphere etc) which some viewer(s) can tessellate natively. Bool_t PreferLocalFrame() const void BeginScene() Bool_t BuildingScene() const void EndScene() Int_t AddObject(const TBuffer3D & buffer, ...) Int_t AddObject(UInt_t physicalID, const TBuffer3D & buffer, ...) Bool_t OpenComposite(const TBuffer3D & buffer, …) void CloseComposite() void AddCompositeOp(UInt_t operation) …….. TVirtualView er3D Interface TGeoPainter TBuffer3D S1 S2 S4 Transform N ode Volume T1 A_1 TO P A_2 A B_1 N4 N5 C B Shape T1 T1 T1 T1 S3 TG eoM anager AddO bject(...) ‘Standalone’shapes TPolyLine3D etc Producers C onsum ers TView erO penG L Logical /Physical m aps of objects.C an be rebuilt. TView erX3D Scene ofpoints/segm ents/ polys.Single build. TView er3D Pad D irectdraw each tim e. Fram e buffered. N ew Geom etry TGeoXXXX O ld G eom etry TN ode/TB R IK etc O therclients G EA N T4 etc Interm ediaries TVirtualView er3D & TB uffer3D TN ode (g3d G eom ) TVirtualViewer3D & TBuffer3D act as intermediaries – decouple producers (geometry etc) and consumers (viewers) . Interface answers questions such as: “prefer local frame?”, “send child objects?”, “fill what in buffer?” TBuffer3D composed of sections, filled in negotiation with viewer: Create buffer object –shape specific one if suitable, TBuffer3D if not. Optionally test viewer local reference frame – if can fill in local frame with translation matrix in Core. Fill cheap mandatory sections (Core/BoundingBox/ShapeSpecific), and add to viewer: UInt_t extraSections = viewer->AddObject(buffer); Returns extra (costly) sections (Raw Sizes/Raw) if viewer requires – complete and add again. Returns indication if contained children should be sent (addChildren flag) TBuffer3D contents in copied into viewer specific internal data structures. Some viewers (OpenGL) are able to cache Logical (unique “shapes”) and Physical (placed copies) objects from IDs. Recycle TBuffer3D object if required.

Upload: primrose-lynch

Post on 18-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ROOT: 3D Graphics R. Maunder 1), T.Pocheptsov 4) 1) CERN – European Organization for Nuclear Research, Geneva, Switzerland 4) Joint Institute for Nuclear

ROOT: 3D Graphics R. Maunder R. Maunder 11)) , , T.Pocheptsov T.Pocheptsov 4) 4)

1)1) CERN – European Organization for Nuclear Research, Geneva, SwitzerlandCERN – European Organization for Nuclear Research, Geneva, Switzerland4)4) Joint Institute for Nuclear Research (JINR) Joint Institute for Nuclear Research (JINR)

Viewer Architecture

TVirtualViewer3D: Provides generic access to viewers of widely differing capabilities (OpenGL/x3d/TPad). Can test preferences, manage scenes, add objects, adjust camera, lights etc externally (future extension) etc.

TBuffer3D: 3D Object hierarchy – describe “shapes”. Generic TBuffer3D for any object in tessellated form. Subclasses for shape specific examples (TBuffer3DSphere etc) which some viewer(s) can tessellate natively.

Bool_t PreferLocalFrame() const

void BeginScene()Bool_t BuildingScene() constvoid EndScene()

Int_t AddObject(const TBuffer3D & buffer, ...) Int_t AddObject(UInt_t physicalID, const TBuffer3D & buffer, ...) Bool_t OpenComposite(const TBuffer3D & buffer, …)void CloseComposite()void AddCompositeOp(UInt_t operation)

……..

TVirtualViewer3DInterface

TGeoPainter

TBuffer3D

S1

S2

S4

Transform

Node

Volume

T1A_1

TOP

A_2

A

B_1 N4 N5

CB

Shape

T1T1T1

T1

S3

TGeoManager

AddObject(...)

‘Standalone’ shapesTPolyLine3D etc

Producers Consumers

TViewerOpenGLLogical / Physical maps of

objects. Can be rebuilt.

TViewerX3DScene of points/segments/

polys. Single build.

TViewer3DPadDirect draw each time.

Frame buffered.

New GeometryTGeoXXXX

Old GeometryTNode/TBRIK etc

Other clientsGEANT4 etc

IntermediariesTVirtualViewer3D & TBuffer3D

TNode(g3d Geom)

•TVirtualViewer3D & TBuffer3D act as intermediaries – decouple producers (geometry etc) and consumers (viewers) .

•Interface answers questions such as: “prefer local frame?”, “send child objects?”, “fill what in buffer?”

•TBuffer3D composed of sections, filled in negotiation with viewer:•Create buffer object –shape specific one if suitable, TBuffer3D if not.•Optionally test viewer local reference frame – if can fill in local frame with translation matrix in Core.•Fill cheap mandatory sections (Core/BoundingBox/ShapeSpecific), and add to viewer:

UInt_t extraSections = viewer->AddObject(buffer);•Returns extra (costly) sections (Raw Sizes/Raw) if viewer requires – complete and add again.•Returns indication if contained children should be sent (addChildren flag)

•TBuffer3D contents in copied into viewer specific internal data structures.

•Some viewers (OpenGL) are able to cache Logical (unique “shapes”) and Physical (placed copies) objects from IDs.

•Recycle TBuffer3D object if required.

Page 2: ROOT: 3D Graphics R. Maunder 1), T.Pocheptsov 4) 1) CERN – European Organization for Nuclear Research, Geneva, Switzerland 4) Joint Institute for Nuclear

GL Viewer: Can now be used as a standalone viewer and as built in pad. TPad can render classical 2D graphics, using X11 or Windows graphics and 3D graphics using OpenGL. We intend to exploit this to offer wide new range of data representation techniques.root[0] gStyle->SetCanvasPreferGL(kTRUE);

root[1] .x shapes.C

Draw Style: Objects can be drawn as solids and solids with outlines:

R. Maunder R. Maunder 11)) , , T.Pocheptsov T.Pocheptsov 4) 4)

1)1) CERN – European Organization for Nuclear Research, Geneva, SwitzerlandCERN – European Organization for Nuclear Research, Geneva, Switzerland4)4) Joint Institute for Nuclear Research (JINR) Joint Institute for Nuclear Research (JINR)

ROOT: 3D Graphics

Composite Shapes: ROOT ‘s composite shapes (TGeoCompositeShape) can now be visualized with GL viewer:

new TGeoCompositeShape("cs", "sphere - torus")

- ==

* ==

new TGeoCompositeShape("cs", "box * sphere")new TGeoCompositeShape("cs", "sphere + torus")

+ ==

TGeoCompositeShape *cs1 = new TGeoCompositeShape("cs1", "tub1+tub1:r1");TGeoCompositeShape *cs2 = new TGeoCompositeShape("cs2", "tub2+tub2:r1");TGeoCompositeShape *cs3 = new TGeoCompositeShape("cs3", "cs1-cs2");TGeoCompositeShape *cs = new TGeoCompositeShape("cs", "cs3*box:r2");

Clipping: Remove subset of objects to show detector internals etc. Two techniques

•OpenGL® Clip Planes: Multiple renders, each with one or more clip planes, combine together e.g. 3 sides of box:

+ + =

•CSG Operation: Add all object meshes (o1..on), subtract clipping object mesh (c) :o1 + o2 + …… + on – c

Adding both methods, clip planes for interactive setup, CSG for high quality renders.

Pros: Fast and simple, interactive (few planes) Cons: Accurate only for shapes described by planes - approx otherwise.Clipped solids not capped –hollow.

Pros: Any arbitrary clipping shape possible Cons: Cannot adjust interactively Slow, complexProper capping of solids