How to map a scene on a cube

Blitz3D Forums/Blitz3D Programming/How to map a scene on a 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.

So here goes, the multicam example plus cube texturing (resizing the image _really_ slows it down, so I left it out):



Graphics3D 640,480

tex=CreateTexture( 64,64 )
SetBuffer TextureBuffer( tex )
Color 255,0,0:Rect 0,0,32,32:Rect 32,32,32,32
Color 255,128,0:Rect 32,0,32,32:Rect 0,32,32,32
SetBuffer BackBuffer()
Color 255,255,255

cone=CreateCone(20)
EntityTexture cone,tex

sphere=CreateSphere(10)
PositionEntity sphere,2,0,0
EntityTexture sphere,tex

cylinder=CreateCylinder(20)
PositionEntity cylinder,-2,0,0
EntityTexture cylinder,tex

cubetex = CreateTexture(256,256,1+16+32+256)
cubebuffer = CreateImage(256,256)
cube=CreateCube()
PositionEntity cube,0,0,-8
EntityTexture cube,cubetex

light=CreateLight()
TurnEntity light,45,45,0

pivot=CreatePivot()

z_cam=CreateCamera( pivot )
CameraViewport z_cam,0,0,320,240
PositionEntity z_cam,0,0,-5

y_cam=CreateCamera( pivot )
CameraViewport y_cam,320,0,320,240
PositionEntity y_cam,0,5,0
TurnEntity y_cam,90,0,0

x_cam=CreateCamera( pivot )
CameraViewport x_cam,0,240,320,240
TurnEntity x_cam,0,-90,0
PositionEntity x_cam,-5,0,0

cube_cam = CreateCamera()
CameraViewport cube_cam,320,240,320,240
TurnEntity cube_cam,180,0,0
PositionEntity cube_cam,0,0,-5


While Not KeyHit(1)

    TurnEntity cube,.1,.2,.3
    TurnEntity cylinder,.4,.6,.8

	If KeyDown(203) MoveEntity pivot,-.1,0,0
	If KeyDown(205) MoveEntity pivot,.1,0,0
	If KeyDown(200) MoveEntity pivot,0,.1,0
	If KeyDown(208) MoveEntity pivot,0,-.1,0
	If KeyDown(30) MoveEntity pivot,0,0,.1
	If KeyDown(44) MoveEntity pivot,0,0,-.1

	UpdateWorld
	RenderWorld
	Text 0,0,"Front"

    CopyRect 0,0,256,256,0,0,BackBuffer(),ImageBuffer(cubeBuffer)
    ; ResizeImage cubeBuffer,256,256
    CopyRect 0,0,256,256,0,0,ImageBuffer(cubeBuffer),TextureBuffer(cubeTex)

	Text 320,0,"Top"
	Text 0,240,"Left"
	Text 320,240,"Cube"
	Flip



Wend

End