Face scaling

Blitz3D Forums/Blitz3D Programming/Face scaling

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.

Ok, here is the code. Up and DOWN to scale the face, and LEFT and RIGHT to rotate the camera. Hope this helps a bit :)

Graphics3D 800,600
SetBuffer BackBuffer()


cam=CreatePivot()
camera=CreateCamera(cam)
PositionEntity camera,0,0,-10

light=CreateLight()

sphere=CreateSphere()

mesh = CreateMesh()
surf = CreateSurface(mesh)

scale#=1

v0 = AddVertex (surf, -1, 1, 0.5)
v1 = AddVertex (surf,  1, 1, 0.5)
v2 = AddVertex (surf, -1,-1, 0.5)
v3 = AddVertex (surf,  1,-1, 0.5)

v4 = AddVertex (surf,  0.5,8  , 0)
v5 = AddVertex (surf,  -8 ,0.5, 0)


Dim vert#(3,2)
vert(0,0)=-1
vert(0,1)=1
vert(0,2)=-0.5

vert(1,0)=1
vert(1,1)=1
vert(1,2)=-0.5

vert(2,0)=-1
vert(2,1)=-1
vert(2,2)=-0.5

vert(3,0)=1
vert(3,1)=-1
vert(3,2)=-0.5

tri = AddTriangle (surf,v0,v1,v2)
tri1= AddTriangle (surf,v1,v3,v2)
tri2= AddTriangle (surf,v0,v4,v1)
tri3= AddTriangle (surf,v0,v2,v5)

UpdateNormals(mesh)
EntityFX mesh,16
brush=CreateBrush()
BrushColor brush,200,10,200
BrushShininess brush,1
PaintEntity mesh,brush

While Not KeyHit(1)
	
	
	If KeyDown(200) Then
		scale=scale+0.1
		For loop=0 To 3
			VertexCoords(surf,loop,vert(loop,0)*scale, vert(loop,1)*scale, vert(loop,2)*scale)
		Next
	ElseIf KeyDown(208) Then
		scale=scale-0.1
		For loop=0 To 3
			VertexCoords(surf,loop,vert(loop,0)*scale, vert(loop,1)*scale, vert(loop,2)*scale)
		Next
	End If
	
	If KeyDown(203) Then TurnEntity cam,1,0,0
	If KeyDown(205) Then TurnEntity cam,-1,0,0
	
	TurnEntity light,1,1,0
	
	UpdateWorld
	RenderWorld
	Text 0,0," UP and DOWN to scale mesh. LEFT and RIGHT to rotate.
	Flip
Wend
End