TBillboard


Croquet-Teapot

Comment:

TBillboard always points toward the current camera allowing for such effects as a 2D billboard (if you add a textured rectangle to the frame).

Hierarchy:

ProtoObject
Object
TObject
TFrame
TGroup
TBillboard

Summary:

instance variables:

cameraNorm selectedPoint

methods:

instance class
render no messages

Detail:

instance variables:

cameraNorm
selectedPoint

instance methods:

render
renderFrame: ogl parent: parent root: root

	| cam mat pos out target dir sin angle |
	cam := ogl camera.
	cam ifNotNil:[
		mat := self globalTransform.
		pos := mat a14 @ mat a34.
		out := (mat a13 @ mat a33) normalized.
		mat := cam globalTransform.
		target := mat a14 @ mat a34.
		dir := (target - pos) normalized.
		sin := dir crossProduct: out.
		angle := (dir dotProduct: out) arcCos radiansToDegrees.
		mat := B3DMatrix4x4 identity.
		mat rotationAroundY: angle * sin sign.
		self transformBy: mat.
	].
	^super renderFrame: ogl parent: parent root: root.
renderFrame: ogl space: space

	| cam mat pos out target dir sin angle |
	cam := ogl camera.
	cam ifNotNil:[
		mat := self globalTransform.
		pos := mat a14 @ mat a34.
		out := (mat a13 @ mat a33) normalized.
		mat := cam globalTransform.
		target := mat a14 @ mat a34.
		dir := (target - pos) normalized.
		sin := dir crossProduct: out.
		angle := (dir dotProduct: out) arcCos radiansToDegrees.
		mat := B3DMatrix4x4 identity.
		mat rotationAroundY: angle * sin sign.
		self transformBy: mat.
	].
	^super renderFrame: ogl space: space.

class methods:

^top


- made by Dandelion -