// Macro to create and render a mobile design in using ROOT and OpenGL // Code inspired by ROOT tutorial $ROOYSYS/tutorials/geom/rootgeom.C by Andrei Gheata // Mobile design and code by Nate Schulz (nschulz@gmail.com) void renderMobile() { // 3D space and model code // Partially based on the ROOT tutorial $ROOYSYS/tutorials/geom/rootgeom.C by Andrei Gheata gStyle->SetCanvasPreferGL(true); gSystem->Load("libGeom"); TGeoManager *geom = new TGeoManager("simple1", "Simple geometry"); //--- define some materials TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0,0,0); TGeoMaterial *matAl = new TGeoMaterial("Al", 26.98,13,2.7); // //--- define some media TGeoMedium *Vacuum = new TGeoMedium("Vacuum",1, matVacuum); TGeoMedium *Al = new TGeoMedium("Root Material",2, matAl); // Create 3D Space TGeoVolume *top = geom->MakeBox("TOP", Vacuum, 270., 270., 120.); geom->SetTopVolume(top); TGeoVolume *model = geom->MakeBox("ROOT", Vacuum, 110., 50., 5.); model->SetVisibility(kFALSE); TGeoVolume *mainShaft = geom->MakeTube("Main Shaft", Al, 5, 10, 40); mainShaft->SetLineColor(kWhite); model->AddNode(mainShaft, 1, new TGeoRotation("rot5",0,0,90,180,90,270)); // Shortest Bar with displays TGeoVolume *lowShortBar = geom->MakeBox("lowShortBar", Al, 60, 2., 2.); lowShortBar->SetLineColor(kWhite); model->AddNode(lowShortBar, 1, new TGeoTranslation(0, 0., 0.)); TGeoVolume *bar1LeftDrop = geom->MakeBox("bar1LeftDrop", Al, 2, 16, 2); bar1LeftDrop->SetLineColor(kWhite); model->AddNode(bar1LeftDrop, 2, new TGeoTranslation(-58, -14., 0.)); TGeoVolume *bar1LeftDisplay = geom->MakeBox("bar1LeftDisplay", Al, 16, 9, 2); bar1LeftDisplay->SetLineColor(kWhite); model->AddNode(bar1LeftDisplay, 2, new TGeoTranslation(-58, -30., 0.)); TGeoVolume *bar1RightDrop = geom->MakeBox("bar1RightDrop", Al, 2, 16, 2); bar1RightDrop->SetLineColor(kWhite); model->AddNode(bar1RightDrop, 2, new TGeoTranslation(58, -14., 0.)); TGeoVolume *bar1RightDisplay = geom->MakeBox("bar1RightDisplay", Al, 16, 9, 2); bar1RightDisplay->SetLineColor(kWhite); model->AddNode(bar1RightDisplay, 2, new TGeoTranslation(58, -30., 0.)); // Medium Bar with displays TGeoVolume *middleMediumBar = geom->MakeBox("middleMediumBar", Al, 120, 2., 2.); middleMediumBar->SetLineColor(kWhite); model->AddNode(middleMediumBar, 1, new TGeoTranslation(0, 6., 0.)); TGeoVolume *bar2LeftDrop = geom->MakeBox("bar2LeftDrop", Al, 2, 25, 2); bar2LeftDrop->SetLineColor(kWhite); model->AddNode(bar2LeftDrop, 2, new TGeoTranslation(-118, -18., 0.)); TGeoVolume *bar2LeftDisplay = geom->MakeBox("bar2LeftDisplay", Al, 24, 16, 2); bar2LeftDisplay->SetLineColor(kWhite); model->AddNode(bar2LeftDisplay, 2, new TGeoTranslation(-118, -30., 0.)); TGeoVolume *bar2RightDrop = geom->MakeBox("bar2RightDrop", Al, 2, 25, 2); bar2RightDrop->SetLineColor(kWhite); model->AddNode(bar2RightDrop, 2, new TGeoTranslation(118, -18., 0.)); TGeoVolume *bar2RightDisplay = geom->MakeBox("bar2RightDisplay", Al, 24, 16, 2); bar2RightDisplay->SetLineColor(kWhite); model->AddNode(bar2RightDisplay, 2, new TGeoTranslation(118, -30., 0.)); // Long Bar with displays TGeoVolume *topLongBar = geom->MakeBox("topLongBar", Al, 194, 2., 2.); topLongBar->SetLineColor(kWhite); model->AddNode(topLongBar, 1, new TGeoTranslation(0, 12., 0.)); TGeoVolume *bar3LeftDrop = geom->MakeBox("bar3LeftDrop", Al, 2, 24, 2); bar3LeftDrop->SetLineColor(kWhite); model->AddNode(bar3LeftDrop, 2, new TGeoTranslation(-192, -14., 0.)); TGeoVolume *bar3LeftDisplay = geom->MakeBox("bar3LeftDisplay", Al, 32, 20, 2); bar3LeftDisplay->SetLineColor(kWhite); model->AddNode(bar3LeftDisplay, 2, new TGeoTranslation(-194, -30., 0.)); TGeoVolume *bar3RightDrop = geom->MakeBox("bar3RightDrop", Al, 2, 24, 2); bar3RightDrop->SetLineColor(kWhite); model->AddNode(bar3RightDrop, 2, new TGeoTranslation(192, -14., 0.)); TGeoVolume *bar3RightDisplay = geom->MakeBox("bar3RightDisplay", Al, 32, 20, 2); bar3RightDisplay->SetLineColor(kWhite); model->AddNode(bar3RightDisplay, 2, new TGeoTranslation(194, -30., 0.)); // Video Sphere TGeoVolume *sphere = geom->MakeSphere("sphere", Al, 0, 25.0, 0, 180.0, 0, 360.0); sphere->SetLineColor(kWhite); gGeoManager->GetVolume("sphere")->SetTransparency(50); model->AddNode(sphere, 1, new TGeoTranslation(0, -30., 0.)); top->AddNode(model, 1, new TGeoTranslation(0, 0, 0)); //--- close the geometry geom->CloseGeometry(); top->Draw("ogl"); }