Iterate all materials

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Iterate all materials

Post by mecio »

Hi there.

I wonder if is there any option to iterate all node materials?
I have something like this.

Code: Select all

 node->getMaterial(0).Shininess = 0.0f;
Now I would like to apply the same changes to all avaiable materials for this node.
I am looking for something like this

Code: Select all

 
 for(int i=0; i<node->number_of_materials(); i++){
   node->getMaterial(i).Shinness = 0.0f;
}
 
Or some kind of iterator, foreach loop...

The problem is that all my world looks like metal and when i turn on the lights it looks horrible.

Thanks from the mountain!
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Iterate all materials

Post by serengeor »

mecio wrote:Hi there.

I wonder if is there any option to iterate all node materials?
I have something like this.

Code: Select all

 node->getMaterial(0).Shininess = 0.0f;
Now I would like to apply the same changes to all avaiable materials for this node.
I am looking for something like this

Code: Select all

 
 for(int i=0; i<node->number_of_materials(); i++){
   node->getMaterial(i).Shinness = 0.0f;
}
 
Or some kind of iterator, foreach loop...

The problem is that all my world looks like metal and when i turn on the lights it looks horrible.

Thanks from the mountain!
Have you tried looking at API doc?
Working on game: Marrbles (Currently stopped).
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Re: Iterate all materials

Post by mecio »

My fault ;(

Code: Select all

 
 for(int i=0; i<node->getMaterialCount(); i++){
            node->getMaterial(i).Shininess = 0.0f;
        }
 
Thanks for help anyway.
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Iterate all materials

Post by serengeor »

It was not that hard, now, was it? :wink:
Working on game: Marrbles (Currently stopped).
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Re: Iterate all materials

Post by mecio »

It was easy :) but now I have another problem. Some parts of my world does not has textures. I see them painted with blue color but I would like them to disappear.

Is there any switch, flag to do that?
serengeor
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Re: Iterate all materials

Post by serengeor »

mecio wrote:It was easy :) but now I have another problem. Some parts of my world does not has textures. I see them painted with blue color but I would like them to disappear.

Is there any switch, flag to do that?
Maybe try changing material type, though I haven't done much of material work myself so I don't know if this is the case.

http://irrlicht.sourceforge.net/docu/na ... 0cbc5430f1
Working on game: Marrbles (Currently stopped).
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Re: Iterate all materials

Post by mecio »

I was experiment with material type and the best resoult is EMT_TRANSPARENT_ALPHA_CHANNEL_REF but i have no idea how to disable thoses blue shapes.

I looks like
Image
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Iterate all materials

Post by hybrid »

Well, alpha_channel works only with textures. So make the blue parts black and use transparent_add, or texture the whole part and use an alpha of 0 to make them disappear.
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Re: Iterate all materials

Post by mecio »

Is there any solution to do it programaticaly?
I am thinking about something like this

Code: Select all

 for(int i=0; i<node->getMaterialCount(); i++){
          if(node->getMaterial(i).hasTexture{ 
                node->getMaterial(i).setTransparent(0);
          }
}
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Re: Iterate all materials

Post by mecio »

I have found something

Code: Select all

 
  for(int i=0; i<node->getMaterialCount(); i++){
            if(node->getMaterial(i).getTexture(0) == 0){
                node->getMaterial(i).PointCloud = true;
            }
}
 
But Now I see small blue points...
I need to replace

Code: Select all

node->getMaterial(i).PointCloud = true;
with something better.
Something that makes material be invisible. Any ideas?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Iterate all materials

Post by hybrid »

Do you want to make the whole blue *mesh* invisible? Why not just removing it completely? Otherwise give it a transparent material (vertex color) and change the vertices to 0 alpha value. Or change the color mask to disabled. Or depth check to false. Many ways, which are all inferior to not processing the mesh at all.
mecio
Posts: 9
Joined: Sun Aug 14, 2011 11:14 am

Re: Iterate all materials

Post by mecio »

It's not just a blue mesh. It's a whole world with blue planes somewhere. So I don't want to edit it manualy.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: Iterate all materials

Post by hybrid »

Well, apparently you have to know which parts form the blue meshes already now. So instead of just changing the material, simply remove the whole meshbuffer. This does work from your code.
Post Reply