
A column having a logo that rotates can be very useful. You can put it in front of a building or, changing the logo to a label, put in front of a group of 3D windows to define the area of a group of "something" (games, by example). Or it can be the identification for an space in front of a Portal (look the figure).
Download the piece and its textures:
The creation of the Class has the "instance variable" of the part: logo:
TGroup subclass: #ColumnLogo4x6x4 instanceVariableNames: 'inControl tframe logo ' classVariableNames: '' poolDictionaries: '' category: 'MyCroquet'
The "initialize" method has the "find" for the logo - we did something similar to the "door":
And has an startStepping because we will rotate the logo continuously.
initialize
super initialize.
tframe := (TLoad3DSMax new initializeWithFileName:
(FileDirectory pathFrom:
{FileDirectory default pathName. 'Content'. 'columnLogo4x6x4'. 'columnLogo4x6x4.ase'})
scale: 0.1 shadeAngle: 90.1 textureMode: GLReplace) frame.
tframe collapse.
tframe boundsDepth: 3.
tframe initBounds.
self addChild: tframe.
tframe objectOwner: self.
"Finding logo"
logo := (tframe find:[:frm | frm objectName = 'logo']) at: 1.
self startStepping.
inControl := false.
The "time-step-loop" (stepAt) will be (the velocity can be changed):
stepAt: currentTime logo addRotationAroundY: 1.
The keyDown: pointer method is like ever (don't have cloning because it's a piece with action):
keyDown: pointer | c | c := pointer event2D keyCharacter. "To move X+" c = $w ifTrue:[ tframe translation: tframe translation+( tframe localTransform column1*0.5). inControl := true. ]. "To move X-" c = $s ifTrue:[ tframe translation: tframe translation-( tframe localTransform column1*0.5). inControl := true. ]. "To turn left" c = $a ifTrue:[ tframe addRotationAroundY:-1. inControl := true. ]. "To turn right" c = $d ifTrue:[ tframe addRotationAroundY: 1. inControl :=true. ]. "To go up:Y+" c = $z ifTrue:[ tframe translation: tframe translation+( tframe localTransform column2*0.5). inControl := true. ]. "To go down (oops!):Y-" c = $x ifTrue:[ tframe translation: tframe translation-( tframe localTransform column2*0.5). inControl := true. ]. "To move Z+" c = $c ifTrue:[ tframe translation: tframe translation+( tframe localTransform column3*0.5). inControl:= true. ]. "To move Z-" c = $v ifTrue:[ "Z-" tframe translation: tframe translation-( tframe localTransform column3*0.5). inControl := true. ].
Don't forget to do the exercice, recreating the example, changing the logo, the color of the column etc.... Look some pictures:
PREVIOUS LESSON NEXT LESSON T. CONTENTS HOMEPAGE
