www.quadsoftware.com
FAQ  FAQ   Search  Search   Memberlist  Memberlist   Usergroups  Usergroups
Register  ::  Log in Log in to check your private messages


Post new topic  Reply to topic
 Enabling alpha test for trees « View previous topic :: View next topic » 
Author Message
cmusch
PostPosted: Fri Aug 03, 2007 8:49 am    Post subject: Enabling alpha test for trees Reply with quote



Joined: 02 Aug 2007
Posts: 33

Hi!

I currently am somewhat lost concerning setting up a material for my imported meshes. In particular, I want to enable alpha testing for trees, but I don't really find enough information to help me create a material in the docs, and I couldn't find an example for this either. Any help on this?

thx alot
chris
Back to top
View user's profile Send private message
ALicu
PostPosted: Fri Aug 03, 2007 9:50 am    Post subject: Reply with quote



Joined: 12 Feb 2007
Posts: 1326

Hello,

First you cannot create a material through the SDK (not yet) but this is not a tragedy as you really don’t need it.

A solution is to write the material on disk (as a shader and material text file) but for this you will need to know our material description syntax. We didn’t documented this as we’ve included all the default fixed pipeline materials you may ever need with the build.

By default this are to be found in /Libraries/Materials folder. As their names implies there are material variants for: lit / unlit, with / without alpha test or alpha blend, lightmapping on or off etc.

For your case you will need AlphaTest (per vertex lit and alpha test), AlphaTest-NoLight (no lighting) or Lightmap-AlphaTest (when you apply lightmapping). You just need to use the following code to get the storage and load the appropriate material:

Code:

   // Obtain the program installation storage.
   iStorage *prog_storage = g_storage_man->GetStorageFromPath(NULL);
   if(prog_storage)
   {
      if(prog_storage->GetDevicePath())
      {
         // Construct the path to the standard location of materials.
         // User can search and load materials from other custom locations as well.
         t_string path = prog_storage->GetDevicePath();
         path += M_SZ("/Libraries/Materials");

         iStorage *mat_stor = g_storage_man->GetStorageFromPath(path.Sz());
         if(mat_stor)
         {
            iMaterial * mat = (iMaterial*)mat_stor->ExtractNode(“AlphaTest”);
            
            …



This code is pretty similar with the code found in the UtilStats plugin that loads all the materials from that folder.

After this, when you create your geometry entity template and add new surfaces (with iGeomEntityTemplateModifier::AddNewSurface) you have a member in the cSurfaceDescription structure called material that should point to the loaded material. The newly added surface will have this material assigned. So for a geometrical template you can have multiple surfaces, each with its own material.

This should work for you. The material interface is not yet completely implemented so the materials cannot be created by SDK but using the above approach you can easily overcome this. In the future, we will have more complex materials and its interface will extend. For now the default materials included with Grome should be enough for fixed pipeline rendering.

Regards,
Adrian L.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Based on a template by Dustin Baccetti
Powered by phpBB © 2001, 2005 phpBB Group