I am an example for simple selection tracking.
ProtoObjectObjectTObjectTFrameTSelectionTracker
| frame | normal | position |
| instance | class |
|---|---|
| render | no messages
|
| frame |
|---|
| normal |
|---|
| position |
|---|
| render |
|---|
| renderFrame: ogl parent: parent root: root |
| sel tfm axis angle select dir tri acPointer | acPointer _ ogl camera pointer. acPointer ifNil:[^self]. select := acPointer doSelect. sel := acPointer lastSelection. frame := sel frame ifNil:[^0]. position := sel point ifNil:[^0]. normal := sel normal. normal ifNil:[ tri := sel triangle ifNil:[^0]. normal := ((tri at: 2) - (tri at: 1)) cross: ((tri at: 3) - (tri at: 2)). normal safelyNormalize. ]. tfm := frame globalTransform. position := tfm localPointToGlobal: position. normal := tfm localDirToGlobal: normal. normal safelyNormalize. dir := 0@0@1. angle := (normal dot: dir). (angle = 1.0 or:[angle = -1.0]) ifTrue:[ axis := 0@1@0. ] ifFalse:[ axis := normal cross: dir. axis safelyNormalize. ]. angle := angle arcCos radiansToDegrees negated. self orientation: (B3DRotation axis: axis angle: angle) asMatrix4x4. self translation: position. "Do not pick while rendering the tracker" ^[acPointer doSelect: false. super renderFrame: ogl parent: parent root: root] ensure:[ acPointer doSelect: select. ]. |
| renderFrame: ogl space: sp |
| sel tfm axis angle select dir tri acPointer | acPointer _ ogl camera pointer. acPointer ifNil:[^self]. select := acPointer doSelect. sel := acPointer lastSelection. frame := sel frame ifNil:[^0]. position := sel point ifNil:[^0]. normal := sel normal. normal ifNil:[ tri := sel triangle ifNil:[^0]. normal := ((tri at: 2) - (tri at: 1)) cross: ((tri at: 3) - (tri at: 2)). normal safelyNormalize. ]. tfm := frame globalTransform. position := tfm localPointToGlobal: position. normal := tfm localDirToGlobal: normal. normal safelyNormalize. dir := 0@0@1. angle := (normal dot: dir). (angle = 1.0 or:[angle = -1.0]) ifTrue:[ axis := 0@1@0. ] ifFalse:[ axis := normal cross: dir. axis safelyNormalize. ]. angle := angle arcCos radiansToDegrees negated. self orientation: (B3DRotation axis: axis angle: angle) asMatrix4x4. self translation: position. "Do not pick while rendering the tracker" ^[acPointer doSelect: false. super renderFrame: ogl space: sp] ensure:[ acPointer doSelect: select. ]. |