Page 1 of 1

Camera direction is wrong ?

Posted: Sun Oct 07, 2012 5:45 pm
by Azur
In this example i show a wall consisting of cubes.
The camera is placed just in top of the wall

CreateCamera(#camera,0,0,1024,768)
CameraLocate(#camera,3,30,0.1)

If i Change the z position of cameralocate to 0, the camera seems not looking downward.


Code: Select all

EnableExplicit

InitEngine3D()
InitSprite()
InitKeyboard()
EnableWorldPhysics(#True)
EnableWorldCollisions(#True)


Enumeration
	#fenetre
	#light
	#camera
	#cube_texture
	#cube_material
	#gnd_texture
	#gnd_material
	#cube_mesh
	#gnd_mesh
	#gnd_entity
EndEnumeration

Global Dim cube(100000)

Procedure exit()
	End
EndProcedure

Procedure scan()
	Define ev=WindowEvent()
	Select ev
		Case #PB_Event_CloseWindow
			exit()
	EndSelect
	ExamineKeyboard()
	If KeyboardPushed(#PB_Key_Escape)
		exit()
	EndIf
EndProcedure

Procedure render()
	DisableEntityBody(cube(0),#False)
	RenderWorld()
	FlipBuffers()
EndProcedure

Procedure init_world()
	CreateCamera(#camera,0,0,1024,768)
	CameraLocate(#camera,3,30,0.1) ;************************** USE Z=0
	CameraLookAt(#camera,3,0,0)
	
	CreateLight(#light,RGB(255,255,255),0,20,-5)
	
	CreateTexture(#cube_texture,64,64)
	StartDrawing(TextureOutput(#cube_texture))
		FillArea(1,1,-1,RGB(255,177,29))
	StopDrawing()
	CreateMaterial(#cube_material,TextureID(#cube_texture))
	
	CreateTexture(#gnd_texture,64,64)
	StartDrawing(TextureOutput(#gnd_texture))
		FillArea(1,1,-1,$aec663)
	StopDrawing()
	CreateMaterial(#gnd_material,TextureID(#gnd_texture))
	
	CreatePlane(#gnd_mesh,100,100,1,1,1,1)
	CreateEntity(#gnd_entity,MeshID(#gnd_mesh),MaterialID(#gnd_material),0,0,0)
	EntityPhysicBody(#gnd_entity,#PB_Entity_StaticBody,0,0.1,10)
	
	CreateCube(#cube_mesh,1)
	
	Define x.f=-5
	Define y.f=0.5
	
	Define i
	
	Define cmpt=0
	
	For i=0 To 101
		cube(cmpt)=CreateEntity(#PB_Any,MeshID(#cube_mesh),MaterialID(#cube_material),x,y,0)
		EntityPhysicBody(cube(cmpt),#PB_Entity_BoxBody,10,0.1,20)
		x+1
		If x=12
			x=-5
			y+1.1
		EndIf
		cmpt+1
	Next i
	
EndProcedure

If OpenWindow(#fenetre,0,0,1024,768,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
	If OpenWindowedScreen(WindowID(#fenetre),0,0,1024,768,0,0,0)
		WorldShadows(#PB_Shadow_Modulative)
		init_world()
		Repeat
			scan()
			render()
		ForEver
	EndIf
EndIf

Re: Camera direction is wrong ?

Posted: Sun Oct 07, 2012 6:19 pm
by Comtois
add this line after CreateCamera() :

Code: Select all

CameraFixedYawAxis(#camera, #False)
Note : Replace 1024 and 768 by 100, size is in percent :
CreateCamera(#camera,0,0,1024,768)