I want to create a cube and paint each side a texture that is loaded from my hard drive. The code below does this for me, but I feel that I'm doing it the hard way. I'm curious to know if there is a better way to handle this. Is there a simpler way to paint each side of a cube a unique texture?
Thanks in advance!
Thanks in advance!
Global top=LoadMesh("models\surface.X") PositionMesh top,0,0,0 ; Create trunk mesh bottom=CopyMesh(top) FlipMesh bottom PositionMesh bottom,0.0,-1.0,0.0 side1=CopyMesh(top) RotateMesh side1,90,0,0 PositionMesh side1,0,0.0,0.0 side2=CopyMesh(top) RotateMesh side2,0,0,90 PositionMesh side2,0.0,0.0,0.0 side3=CopyMesh(top) RotateMesh side3,0,90,90 PositionMesh side3,0.0,0.0,0.0 side4=CopyMesh(top) RotateMesh side4,-90,90,0 PositionMesh side4,0.0,0.0,0.0 For i=1 To MAX_CUBES mytex = retriveimage() br1=CreateBrush(255,255,255) BrushTexture br1, mytex PaintMesh top,br1 FreeTexture mytex FreeBrush br1 mytex = retriveimage() br2=CreateBrush(255,255,255) BrushTexture br2, mytex PaintMesh bottom,br2 FreeTexture mytex FreeBrush br2 mytex = retriveimage() br3=CreateBrush(255,255,255) BrushTexture br3, mytex PaintMesh side1,br3 FreeTexture mytex FreeBrush br3 mytex = retriveimage() br4=CreateBrush(255,255,255) BrushTexture br4, mytex PaintMesh side2,br4 FreeTexture mytex FreeBrush br4 mytex = retriveimage() br5=CreateBrush(255,255,255) BrushTexture br5, mytex PaintMesh side3,br5 FreeTexture mytex FreeBrush br5 mytex = retriveimage() br6=CreateBrush(255,255,255) BrushTexture br6, mytex PaintMesh side4,br6 FreeTexture mytex FreeBrush br6 topcopy=CopyMesh(top) AddMesh bottom,topcopy AddMesh side1, topcopy AddMesh side2, topcopy AddMesh side3, topcopy AddMesh side4, topcopy s.cubes = New cubes s\rotx# = 0.3 + Rnd(1.0) s\roty# = 0.3 + Rnd(1.0) s\rotz# = 0.3 + Rnd(1.0) s\rots# = 0.3 + Rnd(1.0) s\mesh=CopyEntity(topcopy) ScaleMesh s\mesh, 1.8,1.8,1.8 RotateEntity s\mesh, Rand(360), Rand(360), Rand(36) PositionEntity s\mesh, Rand(-MAX_FIELD/2,MAX_FIELD/2), Rand(-45,MAX_FIELD), Rand(-MAX_FIELD/2, MAX_FIELD/2) FreeEntity topcopy Cls Color 255,0,0 Text 0,0,"Loading cube " + i Flip Next FreeEntity top FreeEntity bottom FreeEntity side1 FreeEntity side2 FreeEntity side3 FreeEntity side4