Exemple #1
0
func (me *Camera) init() {
	me.Cull.Frustum = true
	me.SetScene(-1)
	me.Perspective = Options.Cameras.PerspectiveDefaults
	unum.Mat4Identities(&me.thrApp.matProj, &me.thrPrep.matProj)
	me.Controller.init()
}
Exemple #2
0
func (me *Controller) init() {
	me.Params = Options.Cameras.DefaultControllerParams
	me.dir, me.UpVec, me.autoUpdate = unum.Vec3{0, 0, -1}, unum.Vec3{0, 1, 0}, true
	me.UpAxis = me.UpVec
	unum.Mat4Identities(&me.thrPrep.mat, &me.thrApp.mat)
	htarget := &unum.Vec3{X: me.dir.X, Y: 0, Z: me.dir.Z}
	htarget.Normalize()
	if htarget.Z >= 0 {
		if htarget.X >= 0 {
			me.hAngle = 360 - unum.RadToDeg(math.Asin(htarget.Z))
		} else {
			me.hAngle = 180 + unum.RadToDeg(math.Asin(htarget.Z))
		}
	} else {
		if htarget.X >= 0 {
			me.hAngle = unum.RadToDeg(math.Asin(-htarget.Z))
		} else {
			me.hAngle = 90 + unum.RadToDeg(math.Asin(-htarget.Z))
		}
	}
	me.vAngle = -unum.RadToDeg(math.Asin(me.dir.Y))
	me.applyRotation()
	me.applyTranslation()
}