What section of the code renders the textures?

Jun 18, 2013 at 8:09 AM
I simply cannot find the section of the code that actually renders the texture to the face of a cube.

Its a but frustrating, hours of searching through tutorials, and none of them describe efficiently, or how for that matter, how to draw multiple textures to a cube. Thank you for the source code, it is very helpful, but I do wish there were more comments!

So... Could someone show me what class/method or effect applies the textures while drawing? Please and thank you very much!
Jul 14, 2013 at 2:22 AM
Edited Jul 14, 2013 at 2:23 AM
Unfortunately Im still learning the code myself (and the details of XNA/c#)... but first thing - depends on whether you are looking at the NewTake (newer but not finished) code or the TechCraft code (older but more complete).

TechCraft: I think the textures are assigned via the Effects parameters. Have a look at the line as follows in TechCraft4.0Engine\WorldEngine\World.cs:
_solidBlockEffect.Parameters["BlockTexture"].SetValue(_textureAtlas);
(the _textureAtlas is a texture containing the spritesheet of blocks)

Very similar (AFAIK) in NewTake, except that the code is in NewTake\view\Renderers\SimpleRenderer.cs:
_solidBlockEffect.Parameters["Texture1"].SetValue(_textureAtlas);
And getting beyond that - to the effects files themselves (SolidBlockEffect.fx), is getting beyond me to understand properly at this point...

Someone kindly correct me if I'm wrong? :)
Coordinator
Jul 20, 2013 at 10:31 PM
In the original techcraft code...

I think what you're looking for is the BlockInformation class
https://techcraft.codeplex.com/SourceControl/latest#TechCraft/TechCraft4.0Engine/WorldEngine/BlockInformation.cs
This is what the engine uses to determine which texture is used for the different faces of a block.

The actual process of building the vertex buffers and applying the textures is done in the region class
https://techcraft.codeplex.com/SourceControl/latest#TechCraft/TechCraft4.0Engine/WorldEngine/Region.cs

In newtake...
https://techcraft.codeplex.com/SourceControl/latest#TechCraft/NewTake/NewTake/view/blocks/BlockInformation.cs

The actual rendering is done by one of the renderers eg.
https://techcraft.codeplex.com/SourceControl/latest#TechCraft/NewTake/NewTake/view/blocks/VertexBlockRenderer.cs

The newtake code is a bit messy since there was a lot of experimental stuff added to the code

Hope this helps