Jump to content
  • Advertisement
Sign in to follow this  

Texturing a custom mesh with different textures

This topic is 2731 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently making a game that is similar to minecraft because I like the (programming-wise) complexity of the game, but I have a few problems with my version of the game since I only got started with 3D programming a few weeks ago. (Using C# - XNA4.0 with XEN)

The fist problem is that I cannot possible render all the blocks in the game, because there would be to many drawcalls. I circumvented this problem by having "chunks" of blocks like this: BlockType Chunk[16,16,16].
Then I have a chunk-class that takes a block-volume and generates a 3D mesh from it (and filters the nonvisible faces to drastically reduce the number of rendered triangles).
My problem is: Now that I have one big mesh containing the visible faces of each block, how can I assign each face(the two triangles) the right texture???
I played around with colored vertexes and material shaders a bit, but I don't know if it's even possible to let one big vertex-mesh have multiple textures.
For example: There could be (in the volume of the 4096 blocks) about 80% block who use the "stone.dds" texture on each face and 15% of the blocks should use "earth.dds" and the rest maybe "coal".
My only idea so far is this one:
From the existing texture atlas(that contains the visible face of each block in the game once) generate a special "custom made / generated" texture atlas for each chunk. But even with this solution I don't know how to
map the big, generated texure to the mesh.

Another problem I have is this:
When a player builds blocks, they are added to the chunk they are placed in (and the mesh of the chunk is generated again from scratch(no problem here on the performance side since the chunks are only 16³)).
The problem is that if a player builds a large platform above the ground, and starts building houses and stuff on it. The houses and so on are rendered even though they are occluded by the platform the player is building on(looking from the ground / from under the platform).

Any Ideas for these two problems?

Share this post

Link to post
Share on other sites
In the meantime I implemented an Octree to help the performance issues a bit, but I still can't texture the meshes.
Doesn't anyone know how to do this :( ?

Share this post

Link to post
Share on other sites
Make a 3D array of instances that will follow the player and change their model pointers according to the map. Handle NULL model pointers by not rendering. Make sure that your tiles aren't too small and allow a model to occupy more than one tile. The parent tile has the data and the extra tiles store an offset to the parent for collision detection and destruction. I would prefer to have only 1 to 3 layers on each other and store the height for each of the tiles so that you aren't limited by height or performance.

Make your own class for models by looking at Tutorial 07 in the DirectX SDK that gives you the code for rendering from scratch using vertex arrays. This makes debugging a lot easier in the future because the DirectX mesh is like a black box that noone understand.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!