Texturing a custom mesh with different textures

Started by
1 comment, last by Dawoodoz 13 years, 2 months ago
Hi,
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?
Advertisement
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 :( ?
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.

This topic is closed to new replies.

Advertisement