gg.IrrBMAX free view camera?

BlitzMax Forums/BlitzMax Programming/gg.IrrBMAX free view camera?

gman(Posted 2005) [#1]
has anyone implemented a good freelook camera using the Irrlicht mods? (or in Irrlicht itself?) ie. you can pitch, roll, and yaw? i can move the camera without a problem, but im having an issue getting it "look" around easily.

thx.


gman(Posted 2005) [#2]
nm... i finally figured it out after three days and endless Irrlicht forum scouring :)


Jan_(Posted 2005) [#3]
please, show how to!


gman(Posted 2005) [#4]
EDIT: here you go :) this is tested on a regular camera created with addCameraSceneNode(). not sure how it will act with the maya or FPS camera. call this once per game loop passing in the T_irrICameraSceneNode. it will essentially point the camera straight ahead and set the up vector based on its current rotation so you can use the regular ISceneNode rotation commands on it and it will affect where the camera is viewing. with it you can roll the camera simply by rotating the camera node around the Z axis.

' causes the cam to look forward based on current cam orientation
Function updateCam(cam:T_irrICameraSceneNode)
	Local m:T_irrMatrix4=T_irrMatrix4.create()
	' get the current rotation of the camera		
    	m.setRotationDegrees(cam.getRotation())
		
	' transform the up vector based on the current rotation
	Local u:T_irrVector3df=T_irrVector3df.createFromVals(0,1,0)
	m.transformVect(u)
	cam.setUpVector(u)
		
	' transform the target point based on the current location and rotation
	Local v:T_irrVector3df=T_irrVector3df.createFromVals(0,0,100)		
    	m.transformVect(v)
	v.PlusEq(cam.getPosition())
	cam.setTarget(v)
EndFunction