Elp, Entity yaw.

Blitz3D Forums/Blitz3D Programming/Elp, Entity yaw.

Try this Yavin, you're axis were all wrong so I've changes a couple of things. I've positioned camera directly above - it works.


;
;
;	Asteroids Remake.
;
;	This mini project has been started as a test bed for some of the things
;	I plan to implement into the SolarShatter code base.
;
;

Graphics3D 800,600,32,2
SetBuffer BackBuffer()
Cls

HidePointer()



Global cam=CreateCamera()
PositionEntity cam,0,20,0
RotateEntity cam,90,0,0
Global light=CreateLight()
Global switch=False
Global background=CreatePlane()
Global texture_background=LoadTexture("img/bg1.jpg")
ScaleTexture texture_background,40,30
PositionTexture texture_background,.50,.50
EntityTexture background,texture_background

Global line_vert=LoadImage("img/vert.jpg")
Global line_hor=LoadImage("img/hor.jpg")
Global Target=LoadImage("img/target.bmp"):MidHandle target:MaskImage target,255,0,255
Global PLayer_Ship=LoadMesh("models/ship.3ds")
ScaleEntity player_ship,.02,.02,.02
HideEntity PLayer_Ship

Type player
	Field x#
	Field y#
	Field z#
	Field turn_rate#
	Field turn_amount#
	Field sight_pivot
	Field model
End Type

Global player.player = New player
	player\x=0
	player\y=0
	player\z=0
	player\turn_rate=1.5
	
	player\model=CopyEntity(player_ship)
	PositionEntity player\model,0,0,0			
	player\sight_pivot=CreatePivot( player\model)
	PositionEntity player\sight_pivot,0,0,-2
	t=CreateSphere(3, player\sight_pivot):ScaleEntity t, 30, 30, 30

;Play out the game intro

Intro()

Function Intro()

	GUI()
	
End Function

End

;========================
;========================
;========================

Function GUI()
	Local ENDGUI=False
	
	Repeat
		Cls
		
			GUI_Update()
			GUI_Render()
			
			UpdateWorld()
			RenderWorld()
			
			GUI_Render_2D()
			
			If KeyHit(57)=1 Then Game()
			
		Flip False
	Until KeyHit(1) Or ENDGUI=True
	
End Function

;========================
;========================
;========================

Function GUI_Update()
	
	
End Function

;========================
;========================
;========================

Function GUI_Render()

End Function

;========================
;========================
;========================

Function GUI_render_2D()

End Function

;========================
;========================
;========================

Function GAME()
	Local ENDGAME=False
	
	Repeat
		Cls
		
			GAME_Update()
			GAME_Render()
			
			UpdateWorld()
			RenderWorld()
			
			GAME_render_2d()
		Flip 
	Until KeyHit(1) Or ENDGAME=True
		
End Function

Function GAME_update()
		
	PositionEntity player\sight_pivot,-19.1+(MouseX()/20.99),0, -(-14.2+(MouseY()/20.99)), 1
	game_align(player\model, player\sight_pivot,1)

End Function

;========================
;========================
;========================

Function game_align( Entity, Target, Smooth# )

	dp# = GAME_LIMIT ( DeltaPitch( Entity , Target ) , -Smooth , Smooth )
	dy# = GAME_LIMIT ( DeltaYaw( Entity , Target ), -Smooth , Smooth )
	TurnEntity Entity, 0 , dy , 0, 1
		 
End Function

;========================
;========================
;========================

Function GAME_LIMIT#( q# , low# , hi# )

	If q < low q = low
	If q > hi q = hi

	Return q
	
End Function

;========================
;========================
;========================


Function GAME_render()
	PositionEntity player\model, player\x,0,player\z
End Function




Function GAME_render_2D()

	DrawImage line_hor,0,MouseY(),0
	DrawImage line_vert,MouseX(),0,0
	DrawImage target,MouseX(),1+MouseY(),0
	Text 1,1,"Yaw :"+EntityYaw(player\model,1)
	Text 1,20,"pit :"+EntityPitch(player\model,1)
	Text 1,30,"rol :"+EntityRoll(player\model,1)

End Function