How to change a mesh buffers vertex type??

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
gamebeavis
Posts: 12
Joined: Mon Jun 25, 2007 11:45 pm

How to change a mesh buffers vertex type??

Post by gamebeavis »

Hello again. I am trying to modify the 1st tutorial to load an md2 model, then once the model is loaded change it from containing 1 set of texture coords to 2. I am just attempting to see if its possible, the second set of texture coords will just be a duplicate copy of the first (using a for loop to set them all), but I cant seem to locate a command to change the vertex type.

I have set the material type of the AnimatedMeshSceneNode to Lightmap, and loaded a secondary texture into the node. However when I check to see what the mesh buffers vertex type is, it is still not T2Coords, so I cant add the second set into the buffer. Any suggestions??
gamebeavis
Posts: 12
Joined: Mon Jun 25, 2007 11:45 pm

Post by gamebeavis »

Ok, never mind. apparently I am an idiot. I just found out that the 2D coords are actually already loaded with the model, but for some reason the Vertex type is still listed as standard. But the material does work, so YAY!
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I just found out that the 2D coords are actually already loaded with the model, but for some reason the Vertex type is still listed as standard
That sounds like a bug. Can you make a simple model and program that shows the problem?

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

Post by hybrid »

.md2 has only one set of texture coords. When changing to LIGHTMAP materials there is no automatic conversion to a different meshbuffer. This has to be done explicitly. And finally, if the material is working then it is due to the texture coords being the same as the ones for the first texture. May work, but don't rely on that one.
gamebeavis
Posts: 12
Joined: Mon Jun 25, 2007 11:45 pm

Post by gamebeavis »

Ok, so then I guess it might be a bug... You can test it for yourselves, just load the Sydney model that comes with the tutorials and add a light map texture to her (black and white strips works well enough).

So, back to my original question. How do you "explicitly" load a character with 2 sets of texture coords. Does it have to be a model format that already uses them (if so, what formats support that?), or can it simply be called to duplicate the 1st set and change them during runtime??

NOTE: I am not using pure irrlicht. I am using the irrlicht .netCP wrapper. But I dont think that would be the cause here. Since I dont have the ability to compile c++ at work, maybe someone would be willing to test and see if adding a second texture to the c++ tutorial does the same thing...
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

There are models which support lightmaps. These are loaded with the proper vertex structure chosen such that the second set of texture coords is available. Otherwise you have to copy the mesh by replacing all vertices with the S3DVertex2T structure. You can then put the proper coords into the new attributes. There is only a method for converting into tangent meshes, though, so you have to do it manually.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I think I added some confusion to the mix. I thought that beavis was saying that the 2nd set of tcoords were not getting read in. Obviously I was misreading what he was saying.

As hybrid is trying to say, you can allocate a new mesh buffer of the right type [SMeshBufferLightMap] and then copy the vertex data from the existing mesh buffer. Once you've got a replacement vertex buffer you just need to remove the old one from the mesh and add the new one in there.

Travis
gamebeavis
Posts: 12
Joined: Mon Jun 25, 2007 11:45 pm

Post by gamebeavis »

I cant seem to locate SMeshBufferLightMap in the API reference anywhere. Does that still exist??

Maybe the easiest course of action here is simply using a file format that loads into irrlicht natively with 2 sets of texture coords. I normally use milkshape, but I dont think it can generate 2 sets of coords. I think .x does?? Anyone know for sure?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'd have said that Milkshape is one of the formats which support lightmaps. b3d also does, .x does not (IMHO).
Post Reply