Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
hierarchical_scene.C
Go to the documentation of this file.
1 /// \file
2 /// \ingroup tutorial_eve
3 ///
4 /// \image html eve_hierarchical_scene.png
5 /// \macro_code
6 ///
7 /// \author Matevz Tadel
8 
9 const Int_t Ns = 7;
10 
11 void add_blobs(TEveElement* p, Float_t rad, Float_t height, Float_t size,
12  Int_t level)
13 {
14  if (level <= 0) return;
15 
16  for (Int_t i = 0; i < Ns; ++i) {
17  auto x = new TEveGeoShape("SS");
18  x->SetShape(new TGeoSphere(0, size));
19  Double_t phi = TMath::TwoPi() * i / Ns;
20  x->RefMainTrans().SetPos(rad*TMath::Cos(phi),
21  rad*TMath::Sin(phi),
22  height);
23  x->SetMainColor(TColor::GetColorPalette
24  (gRandom->Integer(TColor::GetNumberOfColors())));
25  p->AddElement(x);
26 
27  add_blobs(x, 0.8 * rad, 0.8 * height, 0.8 * size, level - 1);
28  }
29 }
30 
31 void hierarchical_scene()
32 {
33  TEveManager::Create();
34 
35  TColor::SetPalette(1, 0);
36  gRandom = new TRandom3(0);
37 
38  auto s = gEve->SpawnNewScene("Hierarchical Scene", "OoogaDooga");
39  s->SetHierarchical(kTRUE);
40 
41  gEve->GetDefaultViewer()->AddScene(s);
42 
43  add_blobs(s, 6, 4, 0.5, 4);
44 
45  gEve->Redraw3D(kTRUE);
46 }