About Store Forum Documentation Contact



Post Reply 
Terrain materials access.
Author Message
b1s Offline
Member

Post: #1
Terrain materials access.
Sorry couldn't find this anywhere..
I was just wondering if there was another way to access the terrain materials than just the hmMaterial() function.

I did changes to the terrain materials with that function and I would like to have the ability to change them gradually back.

is this possible?

And sorry again if its already been answered somewhere.


______
The closest i can get to is something like this:

Game::World.areaActive(VecI2(0,0))->data->data()->mshg().mesh(0).parts[0].material(0)->color = Vec4(1,1,1,1);

Im sure there is a better way to do this?
(This post was last modified: 06-29-2011 11:57 AM by b1s.)
06-29-2011 11:23 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Terrain materials access.
why are you trying to change the materials?
I can help more if I know your purpose. (please attach sample images of desired effect and/or short description)
06-30-2011 12:27 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #3
RE: Terrain materials access.
Well lets just say that i would like to change the value of specularity to all terrain materials.

Or even change the materials to something else.
06-30-2011 01:43 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Terrain materials access.
changing material params:
material.specular=..;
material.validate(); // need to call after making a change

getting materials:
-hmMaterial()
-Game::World.areaActive(VecI2(0,0))->data->data()->mshg()...
-or directly through Materials cache:

Code:
Materials.lock();
REPA(Materials)
{
// if(StartsPath(Materials.lockedElm(i).file(), "mtrl/terrain_materials")) // <-optionally process materials located in "mtrl/terrain_materials" folder
  {
     Material &m= Materials.lockedElm(i).data;
  }
}
Materials.unlock();
07-01-2011 11:15 AM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #5
RE: Terrain materials access.
Ok.. I've now tried these and seems like I'm having some issues with all of these.
Tho the specularity thing works now well.

The thing is I'm trying to create weather changes and was wondering
if there would be a way to cover the terrain with snow material and take it also out in real time.

So when I have winter i have winter materials on the terrain and when I change back to summer the materials revert back to their original materials.
07-04-2011 02:39 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #6
RE: Terrain materials access.
You can do ground_material.load("new material") to replace existing with new from disk or something similar
07-04-2011 03:36 PM
Find all posts by this user Quote this message in a reply
Post Reply