]>
Commit | Line | Data |
---|---|---|
6196c437 | 1 | // $Header$ |
2 | ||
3 | #ifndef REVE_TriangleSet_H | |
4 | #define REVE_TriangleSet_H | |
5 | ||
6 | #include "RenderElement.h" | |
7 | #include <TNamed.h> | |
8 | #include <TAttBBox.h> | |
64dae94d | 9 | #include <TAtt3D.h> |
6196c437 | 10 | |
11 | #include "ZTrans.h" | |
12 | ||
13 | class TGeoMatrix; | |
14 | ||
15 | namespace Reve { | |
16 | ||
17 | class TriangleSet : public RenderElement, | |
64dae94d | 18 | public TNamed, |
19 | public TAttBBox, | |
20 | public TAtt3D | |
6196c437 | 21 | { |
22 | friend class TriangleSetEditor; | |
23 | friend class TriangleSetGL; | |
24 | ||
3c67f72c | 25 | TriangleSet(const TriangleSet&); // Not implemented |
26 | TriangleSet& operator=(const TriangleSet&); // Not implemented | |
27 | ||
6196c437 | 28 | protected: |
29 | ||
30 | // Vertex data | |
31 | Int_t fNVerts; | |
32 | Float_t* fVerts; //[3*fNVerts] | |
33 | ||
34 | // Triangle data | |
35 | Int_t fNTrings; | |
36 | Int_t* fTrings; //[3*fNTrings] | |
37 | Float_t* fTringNorms; //[3*fNTrings] | |
38 | UChar_t* fTringCols; //[3*fNTrings] | |
39 | ||
40 | // -------------------------------------------------------------- | |
41 | ||
42 | Color_t fColor; | |
43 | ZTrans fHMTrans; | |
44 | ||
45 | public: | |
46 | ||
47 | TriangleSet(Int_t nv, Int_t nt, Bool_t norms=false, Bool_t cols=false); | |
48 | ~TriangleSet(); | |
49 | ||
50 | virtual Bool_t CanEditMainColor() { return kTRUE; } | |
51 | ||
52 | Float_t* Vertex(Int_t i) { return &(fVerts[3*i]); } | |
53 | Int_t* Triangle(Int_t i) { return &(fTrings[3*i]); } | |
54 | Float_t* TriangleNormal(Int_t i) { return &(fTringNorms[3*i]); } | |
55 | UChar_t* TriangleColor(Int_t i) { return &(fTringCols[3*i]); } | |
56 | ||
57 | void SetVertex(Int_t i, Float_t x, Float_t y, Float_t z) | |
58 | { Float_t* v = Vertex(i); v[0] = x; v[1] = y; v[2] = z; } | |
59 | void SetTriangle(Int_t i, Int_t v0, Int_t v1, Int_t v2) | |
60 | { Int_t* t = Triangle(i); t[0] = v0; t[1] = v1; t[2] = v2; } | |
61 | void SetTriangleColor(Int_t i, UChar_t r, UChar_t g, UChar_t b, UChar_t a=255) | |
62 | { UChar_t* c = TriangleColor(i); c[0] = r; c[1] = g; c[2] = b; c[3] = a; } | |
63 | ||
64 | void GenerateTriangleNormals(); | |
65 | void GenerateRandomColors(); | |
64dae94d | 66 | void GenerateZNormalColors(Float_t fac=20, Int_t min=-20, Int_t max=20, |
67 | Bool_t interp=kFALSE, Bool_t wrap=kFALSE); | |
6196c437 | 68 | |
69 | virtual void ComputeBBox(); | |
70 | virtual void Paint(Option_t* = ""); | |
71 | ||
72 | Color_t GetColor() const { return fColor; } | |
73 | void SetColor(Color_t c) { fColor = c; } | |
74 | ||
75 | ZTrans& RefHMTrans() { return fHMTrans; } | |
76 | void SetTransMatrix(Double_t* carr) { fHMTrans.SetFrom(carr); } | |
77 | void SetTransMatrix(const TGeoMatrix& mat) { fHMTrans.SetFrom(mat); } | |
78 | ||
79 | static TriangleSet* ReadTrivialFile(const char* file); | |
80 | ||
81 | ClassDef(TriangleSet, 0) | |
82 | }; // endclass TriangleSet | |
83 | ||
84 | } | |
85 | ||
86 | #endif |