Skip to main content
GameDev.net gamedev.net
🔒 Locked

[.net] Model with multiple textures

Started by REspawn Dec 12, 2005 at 4:08 AM 4 replies 750+ views
Original Post
REspawn
REspawn
Im gonna change around the question after some response to my original question and some research and expermenting on my part. How can i define subsets of a mesh when i am loading it or after it is created. This is not an .x file. Any help or point in the right direction of what i should look at would be excellent, thanks, -Dave [Edited by - REspawn on December 13, 2005 3:23:28 PM]
Black Knight
Black Knight
It depends on how you store your model...
If you have one mesh and one texture applied to it.Then you have to set the texture of the mesh draw the mesh(the first 20 vertices in this case).Then set the other texture and draw the other mesh(the rest of the vertices).
You can't change the texture while you are drawing the triangles.
REspawn
REspawn
Quote:
Original post by Black Knight
It depends on how you store your model...
If you have one mesh and one texture applied to it.Then you have to set the texture of the mesh draw the mesh(the first 20 vertices in this case).Then set the other texture and draw the other mesh(the rest of the vertices).
You can't change the texture while you are drawing the triangles.


Thanks for the quick reply.
Im storing the model in a CustomVertex.PositionColoredTextured array at the moment and then im applying the texture like this...
theTexture = TextureLoader.FromFile(device, "test.dds");device.SetTexture(0, theTexture);theModel = new Model(device, 8, indices, vertices);


But this is just for testing to get the app to read one model and texture it correctly, i will probably need to change this in the final version because it needs to support multiple models so im open to any suggestions on the best way to store this info.

Thanks again,
-Dave
REspawn
REspawn
So i have pretty much been searching for an answer to this since the first post and the only thing i have come up with is the use of subsets.

The only thing is im not using .x files so now im trying to find if its possible to add subsets to a mesh after its creation or during its creation.
Anyone got any idea if this is the right direction?

My mesh creation code...
theModel = new Model(device, 56, indices, vertices);

thanks,
-Dave
REspawn
REspawn
Bumping this because i changed the question and because someone has to have put more than one texture on a mesh thats not from a .x file.

Thanks for any help,
-Dave
REspawn
REspawn
I found it!
It might have taken nearly 3 days, 90 cups of coffee and no sleep but i got a mesh to have 2 different textures...

Heres the code if anyone else runs into the same trouble and finds this topic...
//To assign the attributesInt32[] attribs = theModel.mesh.LockAttributeBuffer(0);attribs[0] = 0;attribs[1] = 1;attribs[2] = 1;attribs[3] = 0;theModel.mesh.UnlockAttributeBuffer(attribs);//Code for rendering the mesh...device.SetTexture(0, theTexture);theModel.mesh.DrawSubset(0);device.SetTexture(0, otherTexture);theModel.mesh.DrawSubset(1);


Link to info: Click here

Thanks for your help Black Knight it sent me in the right direction,
-Dave

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.