Hi, I found this section of the Croquet SDK doc very nice, but as I added some
code, I guessed someone else will try reusing from TCube, but I took the path of creating TMyCube to isolate the tutorial code from the build. 1. Find the checker.bmp bitmap file and copy it into rchecker.bmp, edit using mspaint or equivalent to change black squares into red. 2. File-in the class TMyCube (icluded below) 3. Add the local object myCube to SimpleWorld>>initialize Simpleworld>>initialize | space portal sky win p3 pic myCube | "added var myCube" "ommited allcode" "add this code at the end of the method" myCube := TMyCube new. myCube translation: 1@2@3. space addChild: myCube. 4. Start Croquet(Master) Clicking on the box makes the box move with circular trajectory Clicking on the moving object stops the animation The code for TMyCube class (transcript from SDK doc) 'From Croquet1.0beta of 11 April 2006 [latest update: #2] on 6 May 2008 at 11:33:51 pm'! TFrame subclass: #TMyCube instanceVariableNames: 'txtr boundSphere move' classVariableNames: '' poolDictionaries: '' category: 'Croquet-Practice'! !TMyCube commentStamp: '<historical>' prior: 0! Added by Carlos! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 22:15'! boundSphere ^boundSphere! ! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 22:17'! eventMask ^EventPointerDown! ! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 23:22'! initialize super initialize. txtr := TTexture new initializeWithFileName: 'rchecker.bmp' mipmap: true shrinkFit: false. boundSphere := TBoundSphere localPosition: (0@0@0) radius: (3 sqrt). boundSphere frame: self. move := false ! ! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 22:17'! pick: atRay ^true! ! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 23:23'! pointerDown: aCroquetEvent move := move not. self update.! ! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 20:45'! render: ogl | dx dy dz | dx := 1.0. dy := 1.0. dz := 1.0. txtr ifNotNil: [txtr enable: ogl]. ogl glBegin( GLQuads). ogl glNormal3f( 0.0, 0.0, 1.0). ogl glTexCoord2f(0.0, 0.0). "1" ogl glVertex3f( dx negated, dy, dz). ogl glTexCoord2f(0.0, 1.0). "2" ogl glVertex3f( dx negated, dy negated, dz). ogl glTexCoord2f(1.0, 1.0). "3" ogl glVertex3f( dx, dy negated, dz). ogl glTexCoord2f(1.0, 0.0). "4" ogl glVertex3f( dx, dy, dz). ogl glTexCoord2f(0.0, 0.0). "1" ogl glVertex3f( dx, dy, dz negated). ogl glTexCoord2f(0.0, 1.0). "2" ogl glVertex3f( dx, dy negated, dz negated). ogl glTexCoord2f(1.0, 1.0). "3" ogl glVertex3f( dx negated, dy negated, dz negated). ogl glTexCoord2f(1.0, 0.0). "4" ogl glVertex3f( dx negated, dy, dz negated). ogl glTexCoord2f(0.0, 0.0). "1" ogl glVertex3f( dx, dy, dz ). ogl glTexCoord2f(0.0, 1.0). "2" ogl glVertex3f( dx, dy negated, dz). ogl glTexCoord2f(1.0, 1.0). "3" ogl glVertex3f( dx, dy negated, dz negated). ogl glTexCoord2f(1.0, 0.0). "4" ogl glVertex3f( dx, dy, dz negated). ogl glTexCoord2f(0.0, 0.0). "1" ogl glVertex3f( dx negated, dy, dz negated). ogl glTexCoord2f(0.0, 1.0). "2" ogl glVertex3f( dx negated, dy negated, dz negated). ogl glTexCoord2f(1.0, 1.0). "3" ogl glVertex3f( dx negated, dy negated, dz). ogl glTexCoord2f(1.0, 0.0). "4" ogl glVertex3f( dx negated, dy, dz). ogl glTexCoord2f(0.0, 0.0). "1" ogl glVertex3f( dx, dy, dz). ogl glTexCoord2f(0.0, 1.0). "2" ogl glVertex3f( dx, dy, dz negated). ogl glTexCoord2f(1.0, 1.0). "3" ogl glVertex3f( dx negated, dy, dz negated). ogl glTexCoord2f(1.0, 0.0). "4" ogl glVertex3f( dx negated, dy, dz). ogl glTexCoord2f(0.0, 0.0). "1" ogl glVertex3f( dx negated, dy negated, dz negated). ogl glTexCoord2f(0.0, 1.0). "2" ogl glVertex3f( dx, dy negated, dz negated). ogl glTexCoord2f(1.0, 1.0). "3" ogl glVertex3f( dx, dy negated, dz). ogl glTexCoord2f(1.0, 0.0). "4" ogl glVertex3f( dx negated, dy negated, dz). ogl glEnd. txtr ifNotNil: [txtr disable: ogl]. ! ! !TMyCube methodsFor: 'as yet unclassified' stamp: 'cc 5/6/2008 23:24'! update | t delta | move ifFalse: [^self]. t := self island time. delta := 3 * (t sin @ t cos @ (t sin * t cos)). self translation: delta. (self future: 50) update.! ! |
Free forum by Nabble | Edit this page |