Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TEveTriangleSetGL.cxx
Go to the documentation of this file.
1// @(#)root/eve:$Id$
2// Authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TEveTriangleSetGL.h"
13#include "TEveTriangleSet.h"
14#include "TVector3.h"
15
16#include "TGLIncludes.h"
17
18/** \class TEveTriangleSetGL
19\ingroup TEve
20GL-renderer for TEveTriangleSet class.
21
22See also: TGLObject, TGLLogicalShape.
23*/
24
25
26////////////////////////////////////////////////////////////////////////////////
27/// Constructor.
28
30{
31 // fDLCache = false; // Disable display list.
33}
34
35////////////////////////////////////////////////////////////////////////////////
36/// Destructor.
37
41
42////////////////////////////////////////////////////////////////////////////////
43/// Set model object.
44
50
51////////////////////////////////////////////////////////////////////////////////
52/// Set bounding-box from the model.
53
55{
56 // !! This ok if master sub-classed from TAttBBox
58}
59
60
61////////////////////////////////////////////////////////////////////////////////
62/// Low-level GL rendering.
63
65{
67 Bool_t isScaled = refTS.RefMainTrans().IsScale();
68
72
74
80 glVertexPointer(3, GL_FLOAT, 0, refTS.fVerts);
82
83 Int_t* tng = refTS.fTrings;
84 Float_t* nrm = refTS.fTringNorms;
85 UChar_t* col = refTS.fTringCols;
86
87 TVector3 e1, e2, n;
88
89 glBegin(GL_TRIANGLES);
90 for(Int_t t=0; t<refTS.fNTrings; ++t) {
91 if (nrm) {
92 glNormal3fv(nrm); nrm += 3;
93 } else {
94 Float_t* v0 = refTS.Vertex(tng[0]);
95 Float_t* v1 = refTS.Vertex(tng[1]);
96 Float_t* v2 = refTS.Vertex(tng[2]);
97 e1.SetXYZ(v1[0]-v0[0], v1[1]-v0[1], v1[2]-v0[2]);
98 e2.SetXYZ(v2[0]-v0[0], v2[1]-v0[1], v2[2]-v0[2]);
99 n = e1.Cross(e2);
100 if (!isScaled) n.SetMag(1);
101 glNormal3d(n.x(), n.y(), n.z());
102 }
103 if (col) {
104 TGLUtil::Color3ubv(col); col += 3;
105 }
109 tng += 3;
110 }
111 glEnd();
112
114 glPopAttrib();
116}
float Float_t
Float 4 bytes (float)
Definition RtypesCore.h:71
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void SetBBox() override
Set bounding-box from the model.
void DirectDraw(TGLRnrCtx &rnrCtx) const override
Low-level GL rendering.
TEveTriangleSetGL()
Constructor.
TEveTriangleSet * fM
~TEveTriangleSetGL() override
Destructor.
Bool_t SetModel(TObject *obj, const Option_t *opt=nullptr) override
Set model object.
Made from a list of vertices and a list of triangles (triplets of vertex indices).
TObject * fExternalObj
first replica
Base-class for direct OpenGL renderers.
Definition TGLObject.h:22
Bool_t fMultiColor
Definition TGLObject.h:28
void SetAxisAlignedBBox(Float_t xmin, Float_t xmax, Float_t ymin, Float_t ymax, Float_t zmin, Float_t zmax)
Set axis-aligned bounding-box.
Definition TGLObject.cxx:85
The TGLRnrCtx class aggregates data for a given redering context as needed by various parts of the RO...
Definition TGLRnrCtx.h:41
static void Color3ubv(const UChar_t *rgb)
Wrapper for glColor3ubv.
Definition TGLUtil.cxx:1762
Mother of all ROOT objects.
Definition TObject.h:41
const Int_t n
Definition legend1.C:16