Re: [osg-users] How to apply multiple textures to a model in openscenegraph?

2013-08-02 Thread Robert Osfield
HI Lokesh,

A Texture2DArray is something designed for shader work, the fixed
function pipeline won't access it so you'll need to write shaders for
it.

However, I can't see why you'd want to collection of images like you
have and apply using a Texture2DArray.  These images all have specific
names suggesting that are associated with specific geometries in the
model.  If you load an OpenFlight model it should load all the
textures it needs.

Could it be that you actually problem is totally different from the
problem you seem to be attempting to solve?

Robert.

On 22 May 2013 18:53, Lokesh Kumar lokeshkumar.2...@msit.in wrote:
 Hi,

 I have a flt model and multiple *.dds texture files in a Directory :-

 my folder  directory structure:-


 my_folder
|- terrain.flt
|- road.dds
|- city.dds
|- building1.dds
|- building2.dds
|- building3.dds
|- building3.dds
|- building4.dds
|- building5.dds
|- banner1.dds
|- banner1.dds




 I know how to read and apply single  .dds texture file to my model 
 (terrain.flt) :-


 Code:
 osg::ref_ptrosg::Node terrainModel 
 (osgDB::readNodeFile(c:/my_folder/terrain.flt));
 osg::ref_ptrosg::Texture2D tex (new osg::Texture2D);
 osg::ref_ptrosg::Image image 
 (osgDB::readImageFile(c:/my_folder/road.dds ));

 tex-setImage(image.get());

 osg::ref_ptrosg::StateSet state=terrainModel-getOrCreateStateSet();

 state-setTextureAttributeAndModes(0,tex.get(),osg::StateAttribute::ON);







 but i don't know how to read and apply all these textures to my model 
 (terrain.flt).

 my attempt :-


 Code:
 osg::ref_ptrosg::Node terrainModel 
 (osgDB::readNodeFile(c:/my_folder/terrain.flt));

 osg::ref_ptrosg::Texture2DArray texArray (new osg::Texture2DArray);

 for(int i=0;ifolder_files.size();i++)
 {
osg::ref_ptrosg::Image image 
 (osgDB::readImageFile(c:/my_folder/+file(i)));
texArray-setImage(i,image);

 }

 osg::ref_ptrosg::StateSet state=terrainModel-getOrCreateStateSet();

 
 state-setTextureAttributeAndModes(0,texArray.get(),osg::StateAttribute::ON);




 but, it is not working. Help me.

 Thank you!

 Cheers,
 Lokesh

 --
 Read this topic online here:
 http://forum.openscenegraph.org/viewtopic.php?p=54110#54110





 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org
 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] How to apply multiple textures to a model in openscenegraph?

2013-07-31 Thread Lokesh Kumar
Hi,

I have a flt model and multiple *.dds texture files in a Directory :-

my folder  directory structure:-


 my_folder
|- terrain.flt
|- road.dds 
|- city.dds 
|- building1.dds 
|- building2.dds
|- building3.dds 
|- building3.dds 
|- building4.dds 
|- building5.dds 
|- banner1.dds
|- banner1.dds




I know how to read and apply single  .dds texture file to my model 
(terrain.flt) :-


Code:
osg::ref_ptrosg::Node terrainModel 
(osgDB::readNodeFile(c:/my_folder/terrain.flt));
osg::ref_ptrosg::Texture2D tex (new osg::Texture2D);
osg::ref_ptrosg::Image image (osgDB::readImageFile(c:/my_folder/road.dds 
));

tex-setImage(image.get());

osg::ref_ptrosg::StateSet state=terrainModel-getOrCreateStateSet(); 

state-setTextureAttributeAndModes(0,tex.get(),osg::StateAttribute::ON);







but i don't know how to read and apply all these textures to my model 
(terrain.flt).

my attempt :-


Code:
osg::ref_ptrosg::Node terrainModel 
(osgDB::readNodeFile(c:/my_folder/terrain.flt));
 
osg::ref_ptrosg::Texture2DArray texArray (new osg::Texture2DArray);

for(int i=0;ifolder_files.size();i++)
{
   osg::ref_ptrosg::Image image 
(osgDB::readImageFile(c:/my_folder/+file(i)));
   texArray-setImage(i,image);
  
}  
   
osg::ref_ptrosg::StateSet state=terrainModel-getOrCreateStateSet(); 


state-setTextureAttributeAndModes(0,texArray.get(),osg::StateAttribute::ON);




but, it is not working. Help me. 

Thank you!

Cheers,
Lokesh

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=54110#54110





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org