TLaser


Croquet-Teapot

Comment:

TLaser is used by the TUserCamera to show other users what this user is currently pointing at or manipulating.

Hierarchy:

ProtoObject
Object
TObject
TFrame
TGroup
TLaser

Summary:

instance variables:

arrowLength attachment color glowMaterial glowPointMaterial length point radius selected shaft spell

methods:

instance class
accessing events render
instance creation

Detail:

instance variables:

arrowLength
attachment
color
glowMaterial
glowPointMaterial
length
point
radius
selected
shaft
spell

instance methods:

accessing
addAttachment: att


	attachment _ att.
	self addChild: att.
color

	^color.
color: col


	color _ col copy.
	color at: 4 put: 0.35.
	glowMaterial ambientColor: color.
	glowMaterial diffuseColor: color.
	glowPointMaterial ambientColor: color.
	glowPointMaterial diffuseColor: color.
initialize


	| glow |
	super initialize.
	arrowLength _ 0.5.
	radius _ 0.025.
	length _ 1.0.
	color _ #(5.0 0.0 0.1 0.35).

	shaft _ TGroup new.
	shaft rotationAroundX: -90.0.
	self addChild: shaft.

	point _ TGroup new.
	point rotationAroundX: -90.0.
	point translationX: 0.0 y:0.0 z:arrowLength-length.
	self addChild: point.

	glowMaterial _ TMaterial new.
	glowMaterial ambientColor: color asFloatArray.
	glowMaterial diffuseColor: color asFloatArray.
	glowMaterial texture:( TTexture
				new initializeWithFileName: 'neonGlow.png'
				mipmap: true
				shrinkFit: false).
	glowMaterial textureMode: GLModulate.
	glowMaterial cullFace: false.


	glowPointMaterial _ TMaterial new.
	glowPointMaterial ambientColor: color asFloatArray.
	glowPointMaterial diffuseColor: color asFloatArray.
	glowPointMaterial texture:( TTexture
				new initializeWithFileName: 'neonGlowPoint.png'
				mipmap: true
				shrinkFit: false).
	glowPointMaterial textureMode: GLModulate.
	glowPointMaterial cullFace: false.

	1 to: 4 do:[ :i |
	glow _ TTriangle new.
	glow v1: (B3DVector3 x:0 y: arrowLength z:0)
			   v2: (B3DVector3 x:radius*5 y: -0.1 z: 0)
			   v3: (B3DVector3 x:radius*-5 y: -0.1 z: 0).
	glow material: glowPointMaterial.
	glow rotationAroundY: 45.0 * i.
	point addChild: glow.

	glow _ TRectangle new.
	glow extent: (radius*6)@(length - arrowLength).
	glow location: (B3DVector3 x:0 y: (length-arrowLength)/2.0 z:0.0).
	glow material: glowMaterial.
	glow rotationAroundY: 45.0 * i.
	shaft addChild: glow.].

	self solidTree: false.
	spell _ nil.
	^self
length: ln
 
	ln > 0 ifTrue:[
	length _ ln.
	point translationX: 0.0 y: 0.0 z: arrowLength - length.
	shaft frameChildren do:[ :glow |
		glow extent: radius * 6 @ (0.2 + length - arrowLength).
		glow location: (B3DVector3 x: 0 y: length - arrowLength / 2.0 z: 0.0).
		].].
	spell ifNotNil:[spell translation:(B3DVector3 x:0 y: 0 z: length negated).].
removeAttachment


	self removeChild: attachment.
	attachment _ nil.
scale: scale

	super scale: scale.
	arrowLength _ scale * arrowLength.
	radius _ scale * radius.
	length _ scale * length.
setSpell: bool


	bool ifTrue:[
		spell _ TParticle new initializeWithSize: 30.
		spell translation: (B3DVector3 x:0 y:0 z: length negated).
		spell setPositionRangeMin: (0@0@0) max: (0@0@0).
		spell setVelocityRangeMin:(-0.7@1@-0.7) max:(0.7@3@0.7).
		spell setLifetimeRange: (700 to: 1200).
		spell startColor: (B3DColor4 r:1.0  g:1.0 b:0.2 a:0.5).
		self addChild: spell.
		]
	ifFalse:[
		self removeChild: spell.
		spell _ nil.].

events
pointerDown: pointer


	self length: pointer selectedDistance.
pointerMove: pointer


	self length: pointer selectedDistance.
pointerUp: pointer


	self length: 1.0.

class methods:

^top


- made by Dandelion -