How to apply two textures to two sides of a cube

Blitz3D Forums/Blitz3D Programming/How to apply two textures to two sides of a cube

I have created 100 cubes, more oblong rectangle shapes which represent cars 'bodies'. I wish to apply the numbers 0 to 99 to the top and bottom of each car. I plan to use 10 number images (0-9), to create the 0 to 99 textures, then identify the top and bottom of each oblong as I create each car body and apply the number to the top and bottom face once I have identified them. So I have my numbers,

1. Would I be better using gifs or pngs for the numbers.
2. How do I glue the numbers together to make a single texture (i.e. 3 next to 6 would make my 36 texture.)
3. How do I identify the top and bottom faces of my cubes.
4. How do I then apply the texture to the two identified faces?

Thanks in advance, BP.

1) Textures are best as PNGs (you can't use GIFs).
2) Can you not use 2 quads (replacing each cube face) with a digit on each?
3) Not sure.
4) Create a new quad surface with vertices at the same positions?

thanks of to find out what a quad is (;-)

quad = quadrangle = face = 2 triangles (and 4 vertices)

This example shows a quad:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

;create new mesh
mesh = CreateMesh()
;create surface
surf = CreateSurface(mesh)

;create 4 vertices
v0 = AddVertex(surf,  1,  1, 0, 1.0, 1.0)
v1 = AddVertex(surf,  1, -1, 0, 1.0, 0.0)
v2 = AddVertex(surf, -1, -1, 0, 0.0, 0.0)
v3 = AddVertex(surf, -1,  1, 0, 0.0, 1.0)

;create 2 triangles
AddTriangle surf, v0, v1, v2
AddTriangle surf, v2, v3, v0

;create camera
cam = CreateCamera()
MoveEntity cam, 0, 0, -5

;main loop
Repeat

	;w = wireframe
	WireFrame KeyDown(17)
	RenderWorld
	
	Text 0, 0, "w = wireframe"
	Flip

;esc = exit	
Until KeyHit(1)

End

Are you creating the meshes from code, or are you loading them from a file. And in that case, are you using LoadMesh or LoadAnimMesh ?

The meshes are being created from code, thanks for the code example will fire up my Blitz PC when I get home and try it out. Right tried it out, added another mesh, so I suppose I somehow add my png(s) to each surf somehow ?:-

Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

;create new mesh(s)
mesh = CreateMesh()
mesh2 = CreateMesh()
;create surface(s)
surf = CreateSurface(mesh)
surf2 = CreateSurface(mesh2)

;create 4 vertices
v0 = AddVertex(surf,  1,  1, 0, 1.0, 1.0)
v1 = AddVertex(surf,  1, -1, 0, 1.0, 0.0)
v2 = AddVertex(surf, -1, -1, 0, 0.0, 0.0)
v3 = AddVertex(surf, -1,  1, 0, 0.0, 1.0)
;create another 4 vertices
v4 = AddVertex(surf2,  3,  1, 0, 1.0, 1.0)
v5 = AddVertex(surf2,  3, -1, 0, 1.0, 0.0)
v6 = AddVertex(surf2, 1, -1, 0, 0.0, 0.0)
v7 = AddVertex(surf2, 1,  1, 0, 0.0, 1.0)

;create 2 triangles
AddTriangle surf, v0, v1, v2
AddTriangle surf, v2, v3, v0
;create 2 more triangles
AddTriangle surf2, v4, v5, v6
AddTriangle surf2, v6, v7, v4

;create camera
cam = CreateCamera()
MoveEntity cam, 0, 0, -5

;main loop
Repeat

	;w = wireframe
	WireFrame KeyDown(17)
	RenderWorld
	
	Text 0, 0, "w = wireframe"
	Flip

;esc = exit	
Until KeyHit(1)

End



Yes, maybe this example might be helpful:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

;create texture that contains numbers
SetFont LoadFont("Arial", 20, 1)
tex = CreateTexture(16, 16, 1+8, 10)
For i = 0 To 9
	Color 255, 0, 0
	Rect 0, 0, 16, 16
	Color 255, 255, 0
	Text 8, 8, i, 1, 1
	CopyRect 0, 0, 16, 16, 0, 0, BackBuffer(), TextureBuffer(tex, i)
Next

;create new mesh
mesh = CreateMesh()

;create surface 1
surf1 = CreateSurface(mesh)

;create 4 vertices
v0 = AddVertex(surf1,  0,  1, 0, 1.0, 0.0)
v1 = AddVertex(surf1,  0, -1, 0, 1.0, 1.0)
v2 = AddVertex(surf1, -1, -1, 0, 0.0, 1.0)
v3 = AddVertex(surf1, -1,  1, 0, 0.0, 0.0)

;create 2 triangles
AddTriangle surf1, v0, v1, v2
AddTriangle surf1, v2, v3, v0

;create surface 2
surf2 = CreateSurface(mesh)

;create 4 vertices
v0 = AddVertex(surf2,  1,  1, 0, 1.0, 0.0)
v1 = AddVertex(surf2,  1, -1, 0, 1.0, 1.0)
v2 = AddVertex(surf2,  0, -1, 0, 0.0, 1.0)
v3 = AddVertex(surf2,  0,  1, 0, 0.0, 0.0)

;create 2 triangles
AddTriangle surf2, v0, v1, v2
AddTriangle surf2, v2, v3, v0

;create brush, used for painting on the mesh
brush = CreateBrush()

;create camera
cam = CreateCamera()
MoveEntity cam, 0, 0, -5

;used for delaying counter
nxt = MilliSecs()

;main loop
Repeat

	;w = wireframe
	WireFrame KeyDown(17)
	;turn mesh
	;TurnEntity mesh, 1, 2, 3

	;counter that puts number's digits into 'c1' and 'c2'
	If MilliSecs() > nxt Then
		nxt = nxt + 250
		cc = cc + 1
		c1 = (cc / 10) Mod 10
		c2 = cc Mod 10	
	End If	
	
	;----update texture-----

	;select texture for brush
	BrushTexture brush, tex, c1
	;assign brush to surface 1
	PaintSurface surf1, brush
	;select texture for brush
	BrushTexture brush, tex, c2
	;assign brush to surface 2
	PaintSurface surf2, brush


	;render world
	RenderWorld	
	Flip

;esc = exit	
Until KeyHit(1)

End


that code looks ideal, have gave it a whirl AND it does the job brilliantly. Thanks for the help.