Multitexturing?
-
- Posts: 18
- Joined: Sat Nov 17, 2007 11:34 am
Multitexturing?
Okay... so I know how the ideea works just I don't know how to do this with irrlicht.
So i have a chracter... and it has skin hair bla bla bla...
The thing is I want to be able to choose the hair(that is modified my a texture). So how do I apply a texture to some polygons(not all just a surface).
Thank you
So i have a chracter... and it has skin hair bla bla bla...
The thing is I want to be able to choose the hair(that is modified my a texture). So how do I apply a texture to some polygons(not all just a surface).
Thank you
you can only apply textures to mesh buffers not to single vertices !!!
so your hair (for example) must be a mesh buffer, then you can get the mesh buffer with Irrlicht and apply a new texture to it...
so your hair (for example) must be a mesh buffer, then you can get the mesh buffer with Irrlicht and apply a new texture to it...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
-
- Posts: 18
- Joined: Sat Nov 17, 2007 11:34 am
Ohh, I'm sorrysanctus2099 wrote:You lost me
of course, if you create a mesh in an editor and you apply multiple textures to it then every texture uses a seperate mesh buffer, that's how multi texturing works...sanctus2099 wrote:And if I have both the hair and the rest in file can I do that? And will they remain animated?
then you load the mesh as usual and create a node...
from this node you can get the mesh:
Code: Select all
IAnimatedMesh* mesh = node->getMesh();
Code: Select all
IMeshBuffer* mbuf = mesh->getMeshBuffer(0); // 0 for the first buffer (texture)
Code: Select all
mbuf->getMaterial().setTexture(0, texture);
Last edited by Acki on Fri Jan 04, 2008 5:36 pm, edited 1 time in total.
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Modifying the texture image would be slow, you'd be changing the pixels and uploading them. You'd also be editing all surfaces that have that texture. It would also be ugly unless you're doing a direct copy, so it's best to do texture manipulation on the hardware using a render target.
Acki's method is the simplest and best, just have a one pixel hair texture that you use for all your models, search for the dummy texture at load time and replace it with a custom one.
Acki's method is the simplest and best, just have a one pixel hair texture that you use for all your models, search for the dummy texture at load time and replace it with a custom one.
If you assign different texture for hair and rest of the character in your modeling program than Irrlicht will create separate mesh buffers for them on its own. Only thing you then need to do is to find which mesh buffer contain hair texture which can be done by simple trial and error method.
Basic structure of mesh scene nodes is as follows:
scene node contain mesh (pointer to one)
mesh contain one or more mesh buffers
mesh buffer contain material (as well as vertices indices and bounding box)
material contain texture
You may look at this objects: SMaterial, IMeshBuffer, SMeshBuffer, IMesh, SMesh
IAnimatedMeshSceneNode which you are probably using have getMesh() function which returns pointer in to IAnimatedMesh use its interface to change texture.
Basic structure of mesh scene nodes is as follows:
scene node contain mesh (pointer to one)
mesh contain one or more mesh buffers
mesh buffer contain material (as well as vertices indices and bounding box)
material contain texture
You may look at this objects: SMaterial, IMeshBuffer, SMeshBuffer, IMesh, SMesh
IAnimatedMeshSceneNode which you are probably using have getMesh() function which returns pointer in to IAnimatedMesh use its interface to change texture.
Re: Multitexturing?
in your modeling program, group your polygons into materials, by selecting vertices and setting a group name to these vertices, at the same time, do create a material to those vertices as well, then uv map those same vertices.sanctus2099 wrote:Okay... so I know how the ideea works just I don't know how to do this with irrlicht.
So i have a chracter... and it has skin hair bla bla bla...
The thing is I want to be able to choose the hair(that is modified my a texture). So how do I apply a texture to some polygons(not all just a surface).
Thank you
repeat the same steps until all your polygons have been assigned.
in your code, get a reference to your material and then load the texture to that material. with that, you can make it dynamic so much so that you can code it in such a way that any texture can be loaded on a material of your choice.
isn't that amazing? you should pat yourself on the back for doing that hard stuff.
but wait...
you can shorten your flow by simply using irredit to do the scene setup and from there you simply load the irr file later.
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
Re: Multitexturing?
Hi Sanctus2099.sanctus2099 wrote:Okay... so I know how the ideea works just I don't know how to do this with irrlicht.
So i have a chracter... and it has skin hair bla bla bla...
The thing is I want to be able to choose the hair(that is modified my a texture). So how do I apply a texture to some polygons(not all just a surface).
Thank you
This is pretty simple. You don't do it in IRRlicht!
You have to do it in a modeler software (Blender, 3Ds, Lightwave, etc.)
You select your polygons in the software, then create a new surface for them.
You will have to export it so that IRRlicht can read it. Surface definitions once defined in the modeler are available inside IRRlicht. So you could change the texture dynamicaly.