In short: I have generated a 2D colored honeycomb structure using at first TPolyLine (now I used TCutG) and I would like now to move to 3D (or at least in a first step to give a 3D effect).
I thought that the easiest way will be to “convert” my TPolyLine to TPolyLine3D.
This works fine of course until I realized that I can not fill a TPolyLine3D area.
Can I ? If not can you suggest a workaround ? I tried to use “geometry” but I it is a bit overkill for what I want to achieve.
Yes triangle are simple to pain in 3D because they are in a plane. There is no such 3D primitives right now. Also, can you take care of the hidden triangles ? (drawing order). If not, a better implementation using OpenGL would be needed.
May be you can send what you have right now using 3D polylines ?
I think I can, in fact I think it does not matter much for me since the polygons I want to draw are on the same plane.
Sure, it is still very primitive, but it works :
{
gROOT->Reset();
gSystem->Load("libMayaHisto.so");
TMayaHisto *m0 = new TMayaHisto("histo","MAYA",32,32,5);
TPolyLine3D *hex3D ;
TH3I *blank = new TH3I("blank","",1,-1,35,1,-1,35,1,-1,35);
TIter next(m0->GetArrayOfPADs());
TObject *obj;
TCutG *hexa ;
blank->Draw();
Double_t x[7],y[7] ;
Double_t z[7] = {0.} ;
while ((obj=next())) { // loop over all functions
hexa = ((TCutG*)obj) ;
for(int i=0;i<=7;i++){
hexa->GetPoint(i%7,x[i],y[i]);
if(hexa->GetFillColor()>1){
cout << hexa->GetFillColor() << endl ;
}
}
hex3D = new TPolyLine3D(7,x,y,z,"");
// hex3D->SetFillColor(hexa->GetFillColor()); // this is the command I though will work !
hex3D->Draw();
}
}
TMayaHisto is the 2D honeycomb histogram made from hexagonal TCutG.
All these TCutG are held in TClonesArray. I attach the resulting picture. The PADs are the hexagonal (blue) structure at the bottom.
Thank you for finding a solution. In fact I made an attempt using NCtoWDC but I think I did not understand how to use it (maybe because I used GetView3D() ).
It took me sometime to answer you back because I wanted to check if your solution works completely for me, which was not straightforward, but the attached picture can convince you that it does finally.
In the near future I will integrate this code to TMayaHisto, and it may solve a small issue I have now: I can not freely rotate (w/ the mouse) the whole scene (the TGraphs stay where they are).
I will certainly come back to this post if I go further in this direction.
To have the rotation working properly, one should implement the proper Draw and Paint methods in the Maya class. Right now the 3D to 2D transformation is done once outside the class. So, when you rotate the cube, the new position is not recomputed like it is the TPolyLine3D case. To understand better what I mean by " proper Draw and Paint methods" have a look at: root.cern.ch/drupal/content/graphics-pad