Apply texture to single cube face

Blitz3D Forums/Blitz3D Programming/Apply texture to single cube face

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 did this function a while back. It could be helpful to you.

It was designed to have the front surface change, but it would be easy to modify it so all the faces could be textured differently.

Function createscreen(frntbrush,genbrush=0,parent=0)
  mesh=CreateMesh(parent)
  If genbrsh=0 Then genbrsh=frntbrsh

  fsurf=CreateSurface(mesh,frntbrush)
  AddVertex fsurf,-.5,-.5,.5,1,1;0
  AddVertex fsurf,-.5,.5,.5,1,0;1
  AddVertex fsurf,.5,.5,.5,0,0;2
  AddVertex fsurf,.5,-.5,.5,0,1;3

  AddTriangle (fsurf,2,1,0);front
  AddTriangle (fsurf,3,2,0)

  gsurf=CreateSurface(mesh,genbrush)
  AddVertex gsurf,-.5,-.5,.5,0,0;0
  AddVertex gsurf,-.5,.5,.5,0,1;1
  AddVertex gsurf,.5,.5,.5,1,1;2
  AddVertex gsurf,.5,-.5,.5,1,0;3
  AddVertex gsurf,-.5,-.5,-.5,0,0;4
  AddVertex gsurf,-.5,.5,-.5,0,1;5
  AddVertex gsurf,.5,.5,-.5,1,1;6
  AddVertex gsurf,.5,-.5,-.5,1,0;7

  AddTriangle (gsurf,4,5,7);back
  AddTriangle (gsurf,5,6,7)

  AddTriangle (gsurf,7,2,3);rside
  AddTriangle (gsurf,6,2,7)

  AddTriangle (gsurf,1,5,4);lside
  AddTriangle (gsurf,0,1,4)

  AddTriangle (gsurf,1,6,5);top
  AddTriangle (gsurf,1,2,6)

  AddTriangle (gsurf,4,7,0);bottom
  AddTriangle (gsurf,7,3,0)

  UpdateNormals mesh
  Return mesh

End Function