44 fX(x), fY(y), fZ(z), fColor(color)
47 class Box :
public Shape
67 fDX(dX), fDY(dY), fDZ(dZ)
76 buffer.ClearSectionsValid();
78 buffer.fColor = fColor;
79 buffer.fTransparency = 0;
80 buffer.fLocalFrame =
kFALSE;
81 buffer.SetLocalMasterIdentity();
82 buffer.fReflection =
kFALSE;
83 buffer.SetSectionsValid(TBuffer3D::kCore);
88 Double_t halfLength[3] = { fDX, fDY, fDZ };
89 buffer.SetAABoundingBox(origin, halfLength);
90 buffer.SetSectionsValid(TBuffer3D::kBoundingBox);
96 buffer.SetRawSizes(8, 3*8, 12, 3*12, 6, 6*6);
97 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
103 buffer.fPnts[ 0] = fX - fDX; buffer.fPnts[ 1] = fY - fDY; buffer.fPnts[ 2] = fZ - fDZ;
104 buffer.fPnts[ 3] = fX + fDX; buffer.fPnts[ 4] = fY - fDY; buffer.fPnts[ 5] = fZ - fDZ;
105 buffer.fPnts[ 6] = fX + fDX; buffer.fPnts[ 7] = fY + fDY; buffer.fPnts[ 8] = fZ - fDZ;
106 buffer.fPnts[ 9] = fX - fDX; buffer.fPnts[10] = fY + fDY; buffer.fPnts[11] = fZ - fDZ;
107 buffer.fPnts[12] = fX - fDX; buffer.fPnts[13] = fY - fDY; buffer.fPnts[14] = fZ + fDZ;
108 buffer.fPnts[15] = fX + fDX; buffer.fPnts[16] = fY - fDY; buffer.fPnts[17] = fZ + fDZ;
109 buffer.fPnts[18] = fX + fDX; buffer.fPnts[19] = fY + fDY; buffer.fPnts[20] = fZ + fDZ;
110 buffer.fPnts[21] = fX - fDX; buffer.fPnts[22] = fY + fDY; buffer.fPnts[23] = fZ + fDZ;
115 buffer.fSegs[ 0] = fColor ; buffer.fSegs[ 1] = 0 ; buffer.fSegs[ 2] = 1 ;
116 buffer.fSegs[ 3] = fColor ; buffer.fSegs[ 4] = 1 ; buffer.fSegs[ 5] = 2 ;
117 buffer.fSegs[ 6] = fColor ; buffer.fSegs[ 7] = 2 ; buffer.fSegs[ 8] = 3 ;
118 buffer.fSegs[ 9] = fColor ; buffer.fSegs[10] = 3 ; buffer.fSegs[11] = 0 ;
119 buffer.fSegs[12] = fColor ; buffer.fSegs[13] = 4 ; buffer.fSegs[14] = 5 ;
120 buffer.fSegs[15] = fColor ; buffer.fSegs[16] = 5 ; buffer.fSegs[17] = 6 ;
121 buffer.fSegs[18] = fColor ; buffer.fSegs[19] = 6 ; buffer.fSegs[20] = 7 ;
122 buffer.fSegs[21] = fColor ; buffer.fSegs[22] = 7 ; buffer.fSegs[23] = 4 ;
123 buffer.fSegs[24] = fColor ; buffer.fSegs[25] = 0 ; buffer.fSegs[26] = 4 ;
124 buffer.fSegs[27] = fColor ; buffer.fSegs[28] = 1 ; buffer.fSegs[29] = 5 ;
125 buffer.fSegs[30] = fColor ; buffer.fSegs[31] = 2 ; buffer.fSegs[32] = 6 ;
126 buffer.fSegs[33] = fColor ; buffer.fSegs[34] = 3 ; buffer.fSegs[35] = 7 ;
133 buffer.fPols[ 0] = fColor ; buffer.fPols[ 1] = 4 ; buffer.fPols[ 2] = 8 ;
134 buffer.fPols[ 3] = 4 ; buffer.fPols[ 4] = 9 ; buffer.fPols[ 5] = 0 ;
135 buffer.fPols[ 6] = fColor ; buffer.fPols[ 7] = 4 ; buffer.fPols[ 8] = 9 ;
136 buffer.fPols[ 9] = 5 ; buffer.fPols[10] = 10 ; buffer.fPols[11] = 1 ;
137 buffer.fPols[12] = fColor ; buffer.fPols[13] = 4 ; buffer.fPols[14] = 10 ;
138 buffer.fPols[15] = 6 ; buffer.fPols[16] = 11 ; buffer.fPols[17] = 2 ;
139 buffer.fPols[18] = fColor ; buffer.fPols[19] = 4 ; buffer.fPols[20] = 11 ;
140 buffer.fPols[21] = 7 ; buffer.fPols[22] = 8 ; buffer.fPols[23] = 3 ;
141 buffer.fPols[24] = fColor ; buffer.fPols[25] = 4 ; buffer.fPols[26] = 1 ;
142 buffer.fPols[27] = 2 ; buffer.fPols[28] = 3 ; buffer.fPols[29] = 0 ;
143 buffer.fPols[30] = fColor ; buffer.fPols[31] = 4 ; buffer.fPols[32] = 7 ;
144 buffer.fPols[33] = 6 ; buffer.fPols[34] = 5 ; buffer.fPols[35] = 4 ;
146 buffer.SetSectionsValid(TBuffer3D::kRaw);
152 class SBPyramid :
public Shape
173 fDX(dX), fDY(dY), fDZ(dZ)
181 if (reqSections & TBuffer3D::kCore) {
182 buffer.ClearSectionsValid();
184 buffer.fColor = fColor;
185 buffer.fTransparency = 0;
186 buffer.fLocalFrame =
kFALSE;
187 buffer.SetLocalMasterIdentity();
188 buffer.fReflection =
kFALSE;
189 buffer.SetSectionsValid(TBuffer3D::kCore);
192 if (reqSections & TBuffer3D::kBoundingBox) {
193 Double_t halfLength[3] = { fDX, fDY, fDZ/2.0 };
194 Double_t origin[3] = { fX , fY, fZ + halfLength[2]};
195 buffer.SetAABoundingBox(origin, halfLength);
196 buffer.SetSectionsValid(TBuffer3D::kBoundingBox);
201 if (reqSections & TBuffer3D::kRawSizes) {
202 buffer.SetRawSizes(5, 3*5, 8, 3*8, 5, 6 + 4*5);
203 buffer.SetSectionsValid(TBuffer3D::kRawSizes);
206 if (reqSections & TBuffer3D::kRaw) {
209 buffer.fPnts[ 0] = fX - fDX; buffer.fPnts[ 1] = fY - fDY; buffer.fPnts[ 2] = fZ;
210 buffer.fPnts[ 3] = fX + fDX; buffer.fPnts[ 4] = fY - fDY; buffer.fPnts[ 5] = fZ;
211 buffer.fPnts[ 6] = fX + fDX; buffer.fPnts[ 7] = fY + fDY; buffer.fPnts[ 8] = fZ;
212 buffer.fPnts[ 9] = fX - fDX; buffer.fPnts[10] = fY + fDY; buffer.fPnts[11] = fZ;
213 buffer.fPnts[12] = fX; buffer.fPnts[13] = fY ; buffer.fPnts[14] = fZ + fDZ;
219 buffer.fSegs[ 0] = fColor ; buffer.fSegs[ 1] = 0 ; buffer.fSegs[ 2] = 1 ;
220 buffer.fSegs[ 3] = fColor ; buffer.fSegs[ 4] = 1 ; buffer.fSegs[ 5] = 2 ;
221 buffer.fSegs[ 6] = fColor ; buffer.fSegs[ 7] = 2 ; buffer.fSegs[ 8] = 3 ;
222 buffer.fSegs[ 9] = fColor ; buffer.fSegs[10] = 3 ; buffer.fSegs[11] = 0 ;
223 buffer.fSegs[12] = fColor ; buffer.fSegs[13] = 0 ; buffer.fSegs[14] = 4 ;
224 buffer.fSegs[15] = fColor ; buffer.fSegs[16] = 1 ; buffer.fSegs[17] = 4 ;
225 buffer.fSegs[18] = fColor ; buffer.fSegs[19] = 2 ; buffer.fSegs[20] = 4 ;
226 buffer.fSegs[21] = fColor ; buffer.fSegs[22] = 3 ; buffer.fSegs[23] = 4 ;
233 buffer.fPols[ 0] = fColor ; buffer.fPols[ 1] = 4 ; buffer.fPols[ 2] = 0 ;
234 buffer.fPols[ 3] = 1 ; buffer.fPols[ 4] = 2 ; buffer.fPols[ 5] = 3 ;
236 buffer.fPols[ 6] = fColor ; buffer.fPols[ 7] = 3 ; buffer.fPols[ 8] = 0 ;
237 buffer.fPols[ 9] = 4 ; buffer.fPols[10] = 5 ;
238 buffer.fPols[11] = fColor ; buffer.fPols[12] = 3 ; buffer.fPols[13] = 1 ;
239 buffer.fPols[14] = 5 ; buffer.fPols[15] = 6 ;
240 buffer.fPols[16] = fColor ; buffer.fPols[17] = 3 ; buffer.fPols[18] = 2 ;
241 buffer.fPols[19] = 6 ; buffer.fPols[20] = 7 ;
242 buffer.fPols[21] = fColor ; buffer.fPols[22] = 3 ; buffer.fPols[23] = 3 ;
243 buffer.fPols[24] = 7 ; buffer.fPols[25] = 4 ;
245 buffer.SetSectionsValid(TBuffer3D::kRaw);
261 std::vector<Shape *> fShapes;
273 aShape =
new Box(
kRed, 0.0, 0.0, 0.0, 20.0, 20.0, 20.0);
274 fShapes.push_back(aShape);
275 aShape =
new Box(
kBlue, 50.0, 100.0, 200.0, 5.0, 10.0, 15.0);
276 fShapes.push_back(aShape);
277 aShape =
new SBPyramid(
kGreen, 20.0, 25.0, 45.0, 30.0, 30.0, 90.0);
278 fShapes.push_back(aShape);
291 gPad->GetViewer3D(option);
307 std::vector<Shape *>::const_iterator ShapeIt = fShapes.begin();
309 while (ShapeIt != fShapes.end()) {
313 TBuffer3D & buffer = shape->GetBuffer3D(reqSections);
317 shape->GetBuffer3D(reqSections);
326 void viewer3DMaster()
328 printf(
"\n\nviewer3DMaster: This frame demonstates master frame use of 3D viewer architecture.\n");
329 printf(
"Creates two boxes and a square based pyramid, described in master frame.\n\n");
331 MyGeom * myGeom =
new MyGeom;
Use this attribute class when an object should have 3D capabilities.
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
#define ClassDef(name, id)
Abstract 3D shapes viewer.
virtual Int_t AddObject(const TBuffer3D &buffer, Bool_t *addChildren=0)=0
Generic 3D primitive description class.
Mother of all ROOT objects.
you should not use this method at all Int_t Int_t z