Page 1 of 1

Mapping a Cube from a texture sheet

Posted: Mon Jul 27, 2020 1:01 am
by Lupo
Hi all,

I'd been many years away from ZGE, bear with me with questions...

Now i'm teaching my son to program games and we are working on a kinda of "Minecraft clone" (I know, nobody tried it ;-) ).
Everything is working great, we are creating a bitmap for each texture, but its a way to map a cube using a texture of a texture sheet, like having a big bitmap with all textures and using it like we used to using a tile or a sprite IRC?

Sorry if the question is too stupid.

Kind regards,
Luis.

PS. Nice to come back and I can't believe the ZX exporter... I was using Jonathan Cauldwell's MPAGD... but I think I would love ZGE zx generator...
I need to try it...

Re: Mapping a Cube from a texture sheet

Posted: Mon Jul 27, 2020 9:45 am
by Kjell
Hi Luis,

There's a couple of ways to do this, but generally you want to calculate ( or look-up ) the appropriate texture coordinates for each cube "type". See attached file for a basic example.

The thing is though .. since Minecraft uses so many cubes it isn't really viable ( performance-wise ) to render each cube as a individual mesh / model. So if you're aiming for a similar number of cubes as Minecraft you're going to have to use OpenGL calls to speed things up.

K

Re: Mapping a Cube from a texture sheet

Posted: Mon Jul 27, 2020 11:40 am
by VilleK
Welcome back Luis :)

Re: Mapping a Cube from a texture sheet

Posted: Mon Jul 27, 2020 4:24 pm
by Lupo
Kjell wrote: Mon Jul 27, 2020 9:45 am Hi Luis,

There's a couple of ways to do this, but generally you want to calculate ( or look-up ) the appropriate texture coordinates for each cube "type". See attached file for a basic example.

The thing is though .. since Minecraft uses so many cubes it isn't really viable ( performance-wise ) to render each cube as a individual mesh / model. So if you're aiming for a similar number of cubes as Minecraft you're going to have to use OpenGL calls to speed things up.

K
Thanks KJell for the example.

I understand the perf issue, Its more a proof of concepts of sorts, so I don't think we're gonna hit that.
Its difficult to work with the little attention span of this generation (I feel really old) ;-)

Another questions:

1. Is it possible to generate a bitmap from a region of another bitmap (like Bitmap Load)?
2. Is it possible to render a font into a mesh, can I rendertext to another surface and use it?

Kind regards,
Luis.

Re: Mapping a Cube from a texture sheet

Posted: Mon Jul 27, 2020 4:25 pm
by Lupo
VilleK wrote: Mon Jul 27, 2020 11:40 am Welcome back Luis :)
Thanks for the welcome!