Texturing a Random Checkerboard?

Blitz3D Forums/Blitz3D Beginners Area/Texturing a Random Checkerboard?

x2(Posted 2007) [#1]
I have been racking my brains on a texturing problem for a week and have no solution so I am throwing the question up here for the community... Help!

I am trying to achieve a checker board effect on a large square mesh (single surface). The checker pattern is randomized at the start of the game so I can not used a static grid texture and apply it to the mesh. I have successfully loaded a small UV mapped texture and can place this one "square" on the mesh at any location I wish. Now I need to place another 20 or so on the same mesh to create my game board. To keep things simple I really want to use only one mesh for the board and not a set of "tiles". I have no idea how to best achieve this.

My first thought was to use multitexturing but that would be completely inefficient and has extreme limitations. What I think needs to be achieved is to paint or stamp each little square onto the mesh texture at run time. Am I on the right track here?

The code is rather long and complex but starts off by creating a mesh, a surface and 4 vertices at 0,0,0 + 100,0,0 + 100,0,100 + 0,0,100 linked to the surface. I then connect the vertices to create two triangles from v0+v1+v2 and v0+v2+v3. I then color the mesh white.

Next I clear the textureflags and load a 16x16 UV clamped texture which is completely red (one square). I then scale the texture by .10, .10. Finally I texture the board mesh on texture layer 2 and position the UV on the texture so the square appears where I need it.

All thoughts and comments appreciated!

-- X2


big10p(Posted 2007) [#2]
A quick, dirty way is simply to have a 2x2 check texture applied to your quad and then simply multiply the UV's of the quad appropriately so the texture is repeated across it.

A better way, probably, is to build your board mesh of individual quads - one for each board square.


x2(Posted 2007) [#3]
Well the grid is not uniform so pattern repetition is not possible. I.e., There maybe a squares across the north (top) side of the mesh and diminishing in frequency as they progress to the south (bottom) side.

Think: A pyramid of squares displayed on a square surface.

As I stated previously, I was really hoping to avoid a game board consisting of individual quads. Doing so will add an additional level of complexity to the code as well as increasing the triangle and surface counts. (Note to self: I could possibly code this using just 1 or 2 surfaces.)

Looking at other game examples, how would one apply a snow texture to the peaks of a terrain MESH (not terrain)? Obviously this could be painted offline with a static mesh but if mountains had been generated dynamically then a function to locate high points and change the texture would be required. Maybe the answer lies along the lines of a terrain editor or paint program?

BTW Chris, I used your Juicy Fonts utility on a project a few years ago and it was hands down the best tool for the job!

Thanks -- X2


Stevie G(Posted 2007) [#4]

As I stated previously, I was really hoping to avoid a game board consisting of individual quads. Doing so will add an additional level of complexity to the code as well as increasing the triangle and surface counts. (Note to self: I could possibly code this using just 1 or 2 surfaces.)



How big is your board exactly? Creating a quad per square, setting it's uv's and addmesh to the whole board entity isn't going to be a hardship surely?




Stevie


x2(Posted 2007) [#5]
Thanks for the feedback but my goal in posting here was to learn something new in B3D. If what I'm asking about can not be accomplished with Blitz and I learn as much, then I have achieved my goal.

Let's say my next project was a plane with randomly sized and placed circles on the plane? The only way I can think to accomplish this would be to create one very large texture, draw all the circles on it then apply the texture to the plane. Ok, I could probably do this on a few textures using transparency and get the desired effect.

Does anyone know of a way to cookie cutter and stamp a reasonably high quality texture all over a plane at random locations?

Maybe I should move this to the advanced 3D forum?

-- X2


x2(Posted 2007) [#6]
*bump*