How I can make my objects animate?


ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I just made spheres through TGomaterial, TGeoVolum… etc.

But really what I want is let them animate follow straight line, like uniform motion of straight line.

The problem is that all of root’s tutorials which I saw provide rotational motion…(root/tutorials/graphics/anim.C or root/tutorials/geom/shapesAnim.C)

Furthermore, they make objects rotate by changing view.

Here is problem : How can I make my objects animate like uniform motion of straight line?

It is very thankful for solutions or just link references related to this topic.

I modified and simplified shapesAnim.C to generate a sphere moving along a straight line.


TNode *node2;

void shapesAnim2() {
   TCanvas *c1 = new TCanvas("c1","Geometry Shapes",10,10,500,500);

   //  Define some volumes
   TBRIK *brik  = new TBRIK("BRIK","BRIK","void",200,150,150);
   TSPHE *sphe1 = new TSPHE("SPHE1","SPHE1","void",0,140, 0,180, 0,360);

   brik->SetLineColor(1);

   sphe1->SetLineColor(kBlack);


   //  Build the geometry hierarchy
   TNode *node1 = new TNode("NODE1","NODE1","BRIK");
   node1->cd();


   node2 = new TNode("NODE14","NODE14","SPHE1",10, 250,300);


   // Draw this geometry in the current canvas
   node1->cd();
   node1->Draw();
   c1->Update();

   //start a Timer
   TTimer *timer = new TTimer(20);
   timer->SetCommand("Animate()");
   timer->TurnOn();
}

void Animate()
{
   node2->SetPosition(node2->GetX()+1,
                      node2->GetY()+1,
                      node2->GetZ()+1);
   gPad->Modified();
   gPad->Update();
}

really, really thanks… you are my savior… thanks…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.