title: How to apply textures to a model in openscenegraph?
body: <p>I have a flt model which has references to *tga texture files. I converted these *.tga files into *.dds files using Nvidia texture utiilty tool (nvdxt.exe). </p>
  
  <p>I know how to read and apply single  .dds texture file to my model (terrain.flt) :-</p>
  
  <pre><code>osg::ref_ptr&lt;osg::Node&gt; terrainModel (osgDB::readNodeFile("c:/my_folder/terrain.flt"));
  osg::ref_ptr&lt;osg::Texture2D&gt; tex (new osg::Texture2D);
  osg::ref_ptr&lt;osg::Image&gt; image (osgDB::readImageFile("c:/my_folder/road.dds "));
  
  tex-&gt;setImage(image.get());
  
  osg::ref_ptr&lt;osg::StateSet&gt; state=terrainModel-&gt;getOrCreateStateSet(); 
  
  state-&gt;setTextureAttributeAndModes(0,tex.get(),osg::StateAttribute::ON);
  </code></pre>
  
  <p>but i don't know how to read and apply all these textures *.dds to my model (terrain.flt).</p>
  
  <p>my attempt :-</p>
  
  <pre><code>osg::ref_ptr&lt;osg::Node&gt; terrainModel (osgDB::readNodeFile("c:/my_folder/terrain.flt"));
  
  osg::ref_ptr&lt;osg::Texture2DArray&gt; texArray (new osg::Texture2DArray);
  
  for(int i=0;i&lt;my_folder_files.size();i++)
  {
     osg::ref_ptr&lt;osg::Image&gt; image (osgDB::readImageFile("c:/my_folder/"+file(i)));
     texArray-&gt;setImage(i,image);
  
  }  
  
  osg::ref_ptr&lt;osg::StateSet&gt; state=terrainModel-&gt;getOrCreateStateSet(); 
  
  state-&gt;setTextureAttributeAndModes(0,texArray.get(),osg::StateAttribute::ON);
  </code></pre>
  
  <p>but, it is not working. Help me.</p>