Rotate a Mesh like an Entity?

Blitz3D Forums/Blitz3D Programming/Rotate a Mesh like an Entity?

You could do something like this ... but vertex manipulation is slow.

Note that each time you rotate a mesh the yaw, pitch and roll are always zeroised. Perhaps if you rotatemesh each axis separately this will work for you .. I doubt it though.

Oops .. too slow but same idea!!


Function UpdateGame()

	TurnEntity pivotBlock,0,.1,.1	
	
	MESHrotate( test , pivotBlock )

	;newP#=EntityPitch(pivotBlock)
	;newY#=EntityYaw(pivotBlock)
	;newR#=EntityRoll(pivotBlock)

	DebugLog "Pitch:"+newP+" Yaw:"+newY+" Roll:"+newR
	
	;RotateMesh test,newP-oldP,newY-oldY,newR-oldR
	;oldP=newP : oldY=newY : oldR=newR

	Select MouseZSpeed() 
		Case -1 
		MoveEntity Camera,0,0,-2
		Case 1 
		MoveEntity Camera,0,0,2
	End Select

End Function

Function MESHrotate( Mesh, Proxy ) 

	; note assumes mesh and proxy have same no of vertices
	Ms = GetSurface( Mesh, 1 )
	Ps = GetSurface( Proxy , 1 )
	
	For v = 0 To CountVertices( Ps )-1
		TFormPoint VertexX( Ps, v ), VertexY( Ps, v ) , VertexZ( Ps, v ) , Proxy , 0
		VertexCoords Ms , v , TFormedX(), TFormedY(), TFormedZ()
	Next	
	
End Function