RE: Texture Mapping

From: Fine, Valeri <fine_at_bnl.gov>
Date: Mon, 26 May 2008 17:42:23 -0400


Dear Akira,  

I am sorry, I forgot to provide the link to the ROOT macro. Here you are the screen snapshot
http://root.bnl.gov/QtRoot/pictures/HelloEarth.gif  

produced by the 20 lines long ROOT macro (it uses the standard ROOT plug-in and its Coin implementation) http://root.bnl.gov/QtRoot/root/qtExamples/HelloEarth/earth.C ROOT macro  

void earth()
{
  // Draw the globe using "worldmap.bmp" texture file   if ( gSystem->AccessPathName("earth.iv") ) {     // Create the Inventor file if needed     ofstream out("earth.iv");

    out << "#Inventor V2.1 ascii" << endl;
    out << " Texture2 { filename \"worldmap.bmp\" " << endl;
    out <<"  model REPLACE } "<< endl;
    out << "Sphere {   radius 10 }" << endl;

}

  TCanvas *c = new TCanvas;
  c->SetFillColor(kBlack);
  TVirtualViewer3D *viewer =0;
  if (viewer = TVirtualViewer3D::Viewer3D(c,"oiv")) {
         gEnv->SetValue("Gui.InventorBackgroundShape","earth.iv");
         gEnv->SetValue("Gui.SnapShotFileCounter","100");
        // Start ROOT 3D viewer
         viewer->BeginScene();     viewer->EndScene();

}

}  

It generates the picture from the texture file:  

http://root.bnl.gov/QtRoot/root/qtExamples/HelloEarth/worldmap.bmp  

You can replace on line  

    out << " Texture2 { filename \"worldmap.bmp\" " << endl;

in the macro above to use your own texture file as well. I think you can use this technique right now (it is very simple and requires no OpenGL / Open Inventor / C++ knowledge) and switch to the "official ROOT class later on.  

As my Acat 2007 Workshop talk mentioned, the technique above can be used to attach any Coin3D node to any ROOT 3D class object to get the mixed ROOT/Coin 3D scene as well. (see http://agenda.nikhef.nl/contributionDisplay.py?contribId=105&amp;sessionId=15&amp;confId=55 )  

 Hope this helps, Valeri


From: owner-roottalk_at_root.cern.ch on behalf of Fine, Valeri Sent: Mon 5/26/2008 1:15 PM
To: OKUMURA, Akira; ROOT Talk
Subject: RE: [ROOT] Texture Mapping

Hello Akira,

Do you need something like
http://doc.coin3d.org/Coin/classSoTextureCoordinateSphere.html

backed with

http://doc.coin3d.org/Coin/classSoGeoCoordinate.html

thank you.

      Valeri


From: owner-roottalk_at_root.cern.ch on behalf of OKUMURA, Akira Sent: Mon 5/26/2008 7:47 AM
To: ROOT Talk
Subject: [ROOT] Texture Mapping

Hello ROOTers,

I would like to show a sphere of which surface is a texture mapping of an all-sky image of cosmic gamma rays. Is there any ROOT function to create such sphere using OpenGL? If not, which ROOT classes are good starting point?

I know that OpenGL itself has functions to handle texture mapping but I am not an expert of OpenGL. So I am wondering if I can easily access OpenGL's texture mapping via ROOT system.

Regards,

OKUMURA, Akira oxon_at_ceres.phys.s.u-tokyo.ac.jp Department of Physics, The University of Tokyo 7-3-1 Hongo, Bunkyo-ku, Tokyo 113-0033
TEL/FAX +81 3-5841-4173/4059
Skype : okumura.akira Received on Mon May 26 2008 - 23:42:37 CEST

This archive was generated by hypermail 2.2.0 : Tue May 27 2008 - 17:50:02 CEST