MiniB3D

Blitz3D Forums/Blitz3D Programming/MiniB3D

Hi, Using miniB3D, (yes it's in the B3D forum - the commands are the same)

What I have is a chessboard. Instead of the chessboard rotating I would like to move the camera around the chessboard.

Chessboard is on the x,y plane with z pointing upwards. And I want to look down onto the x,y plane.
Anyone help? (without using turnentity)

Strict
Import sidesign.minib3d

Graphics3D 1024,768,32,1

'---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'CONSTANTS
'-------------------
Const C_PA_Width:Int	= 128
Const C_PA_Depth:Int	= 128

'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'GLOBALS
'---------------
Global G_PA_Mesh:TMesh = CreateMesh:TMesh()
Global G_PA_Surf:TSurface = CreateSurface:TSurface( G_PA_Mesh )

Global G_Sphere_Centre:TMesh = CreateSphere(8)
	ScaleEntity G_Sphere_Centre,5,5,5
	EntityColor G_Sphere_Centre, 0,255,0
	PositionEntity G_Sphere_Centre,0,0,0


Global G_Camera_Radius:Float = 256
Global G_Camera_Height:Float = 64
Global G_Camera_Rot_X:Float = 90+10
Global G_Camera_Rot_Z: Float = 0

Global G_Camera:TCamera = CreateCamera()
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'INITIALISE
'---------------
For Local y:Int = 0 To C_PA_Depth
	For Local x:Int = 0 To C_PA_Depth
		G_PA_Surf.AddVertex( x-64, y-64, 0.0 )
	Next
Next

For Local y:Int = 0 To C_PA_Depth-1
	For Local x:Int = 0 To C_PA_Width-1
	
		Local a:Int = (x+0)+(y+0)*(C_PA_Width+1)
		Local b:Int = (x+1)+(y+0)*(C_PA_Width+1)
		Local c:Int = (x+1)+(y+1)*(C_PA_Width+1)
		Local d:Int = (x+0)+(y+1)*(C_PA_Width+1)
	
		G_PA_Surf.AddTriangle( a,b,c )
		G_PA_Surf.AddTriangle( a,c,d )
	Next
Next

'------------------------------------------------------------------------------------------------------
Repeat
	Local c_x# = G_Camera_Radius * Cos(G_Camera_Rot_Z#+90)
	Local c_y# = G_Camera_Radius * Sin(G_Camera_Rot_Z#+90)
	Local c_z# = G_Camera_Height#
	
	PositionEntity G_Camera, c_x#, c_y#, c_z#
	
	PointEntity G_Camera, G_Sphere_Centre
	
	G_Camera_Rot_Z# = G_Camera_Rot_Z# + 1

	RenderWorld
	
	Flip

Until KeyHit(KEY_ESCAPE)

FlushKeys()
WaitKey()
End


Why without using TurnEntity ? It offers prob. the most easy solution. Then you can create a Pivot, attach the Camera to it, move the Camera back and then turn the pivot during the loop.
Anyway, my maths are worthless, but I noticed that PointEntity has an optional 'roll' parameter. You could maybe insert (G_Camera_Rot_Z+90) there.
It sort of does the job, but not quite: the movement seems rather typical
Import sidesign.minib3d

Graphics3D 1024,768,32,2

chess = CreateCube()
ScaleEntity chess, 1, 1, 0.01


cam = CreateCamera()

MoveEntity cam, 0, 0, -15

ang = 0

Repeat

	ang = ang + 2

	x# = Cos(ang) * 5
	y# = Sin(ang) * 5
	z# = -5
	
	PositionEntity cam, x, y, z
	PointEntity cam, chess, ang + 90

	RenderWorld
	Flip

Until KeyHit(key_escape)

End


I prefer the usual convention that Y+ is up.

Import sidesign.minib3d

Graphics3D 1024, 768, 32, 2

chess = CreateCube()
ScaleEntity chess, 1, 0.01, 1

cam = CreateCamera()
PositionEntity cam, 0, 5, -15
camerazoom cam, 8

piv = CreatePivot()
EntityParent cam, piv
PointEntity cam, chess

Repeat

	rotateentity piv, 0, ang, 0
	ang = (ang + 1) Mod 360
	
	RenderWorld
	Flip

Until KeyHit(key_escape)


Thanks guys. Working Great!
Jim