2 // Author: Matevz Tadel 2007
4 /*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
12 #include "TEveJetConeGL.h"
13 #include "TEveJetCone.h"
17 #include "TGLRnrCtx.h"
18 #include "TGLIncludes.h"
20 //______________________________________________________________________________
21 // OpenGL renderer class for TEveJetCone.
24 ClassImp(TEveJetConeGL)
26 //______________________________________________________________________________
27 TEveJetConeGL::TEveJetConeGL() :
32 // fDLCache = kFALSE; // Disable display list.
35 /******************************************************************************/
37 //______________________________________________________________________________
38 Bool_t TEveJetConeGL::SetModel(TObject* obj, const Option_t* /*opt*/)
42 if (SetModelCheckClass(obj, TEveJetCone::Class())) {
43 fM = dynamic_cast<TEveJetCone*>(obj);
49 //______________________________________________________________________________
50 void TEveJetConeGL::SetBBox()
54 // !! This ok if master sub-classed from TAttBBox
55 SetAxisAlignedBBox(((TEveJetCone*)fExternalObj)->AssertBBox());
58 /******************************************************************************/
60 //______________________________________________________________________________
61 void TEveJetConeGL::DirectDraw(TGLRnrCtx & rnrCtx) const
63 // Render with OpenGL.
65 printf("TEveJetConeGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
67 glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
69 glDisable(GL_CULL_FACE);
70 glEnable(GL_NORMALIZE);
72 glBegin(GL_TRIANGLE_FAN);
73 glVertex3fv(fM->fApex);
74 if ( fM->fBasePoints.size() > 2)
76 TEveJetCone::vTEveVector_ci prev = fM->fBasePoints.end(); --prev;
77 TEveJetCone::vTEveVector_ci i = fM->fBasePoints.begin();
78 TEveJetCone::vTEveVector_ci next = i; ++next;
81 TEveVector beg_normal = TMath::Cross((*i - fM->fApex).Arr(), (*next - *prev).Arr(), norm_buf.Arr());
83 glNormal3fv(beg_normal);
84 glVertex3fv(fM->fBasePoints.front());
86 prev = i; i = next; ++next;
88 while (i != fM->fBasePoints.begin())
90 glNormal3fv(TMath::Cross((*i - fM->fApex).Arr(), (*next - *prev).Arr(), norm_buf.Arr()));
95 ++next; if (next == fM->fBasePoints.end()) next = fM->fBasePoints.begin();
98 glNormal3fv(beg_normal);
99 glVertex3fv(fM->fBasePoints.front());