]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/EveBase/TEveJetConeGL.cxx
From Boris: add support for mass cuts with daughter particle specification.
[u/mrichter/AliRoot.git] / EVE / EveBase / TEveJetConeGL.cxx
1 // @(#)root/eve:$Id$
2 // Author: Matevz Tadel 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 "TEveJetConeGL.h"
13 #include "TEveJetCone.h"
14
15 #include "TMath.h"
16
17 #include "TGLRnrCtx.h"
18 #include "TGLIncludes.h"
19
20 //______________________________________________________________________________
21 // OpenGL renderer class for TEveJetCone.
22 //
23
24 ClassImp(TEveJetConeGL)
25
26 //______________________________________________________________________________
27 TEveJetConeGL::TEveJetConeGL() :
28    TGLObject(), fM(0)
29 {
30    // Constructor.
31
32    // fDLCache = kFALSE; // Disable display list.
33 }
34
35 /******************************************************************************/
36
37 //______________________________________________________________________________
38 Bool_t TEveJetConeGL::SetModel(TObject* obj, const Option_t* /*opt*/)
39 {
40    // Set model object.
41
42    if (SetModelCheckClass(obj, TEveJetCone::Class())) {
43       fM = dynamic_cast<TEveJetCone*>(obj);
44       return kTRUE;
45    }
46    return kFALSE;
47 }
48
49 //______________________________________________________________________________
50 void TEveJetConeGL::SetBBox()
51 {
52    // Set bounding box.
53
54    // !! This ok if master sub-classed from TAttBBox
55    SetAxisAlignedBBox(((TEveJetCone*)fExternalObj)->AssertBBox());
56 }
57
58 /******************************************************************************/
59
60 //______________________________________________________________________________
61 void TEveJetConeGL::DirectDraw(TGLRnrCtx & rnrCtx) const
62 {
63    // Render with OpenGL.
64
65    printf("TEveJetConeGL::DirectDraw LOD %d\n", rnrCtx.CombiLOD());
66
67    glPushAttrib(GL_ENABLE_BIT | GL_POLYGON_BIT);
68
69    glDisable(GL_CULL_FACE);
70    glEnable(GL_NORMALIZE);
71
72    glBegin(GL_TRIANGLE_FAN);
73    glVertex3fv(fM->fApex);
74    if ( fM->fBasePoints.size() > 2)
75    {
76       TEveJetCone::vTEveVector_ci prev = fM->fBasePoints.end(); --prev;
77       TEveJetCone::vTEveVector_ci i    = fM->fBasePoints.begin();
78       TEveJetCone::vTEveVector_ci next = i; ++next;
79
80       TEveVector norm_buf;
81       TEveVector beg_normal = TMath::Cross((*i - fM->fApex).Arr(), (*next - *prev).Arr(), norm_buf.Arr());
82
83       glNormal3fv(beg_normal);
84       glVertex3fv(fM->fBasePoints.front());
85
86       prev = i;  i = next;  ++next;
87
88       while (i != fM->fBasePoints.begin())
89       {
90          glNormal3fv(TMath::Cross((*i - fM->fApex).Arr(), (*next - *prev).Arr(), norm_buf.Arr()));
91          glVertex3fv(*i);
92
93          prev = i;
94          i    = next;
95          ++next; if (next == fM->fBasePoints.end()) next = fM->fBasePoints.begin();
96       }
97          
98       glNormal3fv(beg_normal);
99       glVertex3fv(fM->fBasePoints.front());
100    }
101    glEnd();
102
103    glPopAttrib();
104 }