multiple textures on one cube

Blitz3D Forums/Blitz3D Programming/multiple textures on one cube

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I would recomend using a 3d modelling program to do this, but if you don't want to, you could use the following little program. I don't know if this is the best way to do this, because it is my first expirience making a mesh with code, but it seems to work ok.
Graphics3D 640,480
camera=CreateCamera()
PositionEntity camera,0,0,-5

tex1=CreateBrush(255,255,255)
tex2=CreateBrush(255,255,0)
tex3=CreateBrush(255,0,0)
tex4=CreateBrush(0,0,255)
tex5=CreateBrush(0,255,255)
tex6=CreateBrush(255,0,255)

cube=CreateMesh()
surf1=CreateSurface(cube,tex1)
surf2=CreateSurface(cube,tex2)
surf3=CreateSurface(cube,tex3)
surf4=CreateSurface(cube,tex4)
surf5=CreateSurface(cube,tex5)
surf6=CreateSurface(cube,tex6)
AddVertex(surf1,1,1,1)
AddVertex(surf1,1,-1,1)
AddVertex(surf1,-1,-1,1)
AddVertex(surf1,-1,1,1)
AddTriangle(surf1,2,1,0)
AddTriangle(surf1,3,2,0)

AddVertex(surf2,1,1,-1)
AddVertex(surf2,1,-1,-1)
AddVertex(surf2,-1,-1,-1)
AddVertex(surf2,-1,1,-1)
AddTriangle(surf2,0,1,2)
AddTriangle(surf2,0,2,3)

AddVertex(surf3,1,1,1)
AddVertex(surf3,1,-1,1)
AddVertex(surf3,1,-1,-1)
AddVertex(surf3,1,1,-1)
AddTriangle(surf3,0,1,2)
AddTriangle(surf3,0,2,3)

AddVertex(surf4,-1,1,1)
AddVertex(surf4,-1,-1,1)
AddVertex(surf4,-1,-1,-1)
AddVertex(surf4,-1,1,-1)
AddTriangle(surf4,2,1,0)
AddTriangle(surf4,3,2,0)

AddVertex(surf5,1,-1,-1)
AddVertex(surf5,-1,-1,-1)
AddVertex(surf5,-1,-1,1)
AddVertex(surf5,1,-1,1)
AddTriangle(surf5,2,1,0)
AddTriangle(surf5,3,2,0)

AddVertex(surf6,1,1,-1)
AddVertex(surf6,-1,1,-1)
AddVertex(surf6,-1,1,1)
AddVertex(surf6,1,1,1)
AddTriangle(surf6,0,1,2)
AddTriangle(surf6,0,2,3)

While Not KeyDown(1)
TurnEntity cube,1,1,1
UpdateWorld
RenderWorld
Flip
Wend
End

I hope it helps!