[GOODIE] Texture-mapped spheres

Raab, Andreas Andreas.Raab at disney.com
Fri Feb 4 06:34:53 UTC 2000


Dan,

[Note: I'm cc-ing to the list]

> Would it be simple to make the full texture appear?

Well, I can't stand a challenge ;-) Below is an improved version which does
look 'right' (where the meaning of 'right' certainly depends - in reality
you have a perspective and not a parallel projection :-) and that also
supports drag and drop. Oh, and as an extra: Try changing the color of the
Morph...

  Andreas

PS. Why is it that I always use a browser as texture?!

'From Squeak2.7 of 5 January 2000 [latest update: #1762] on 3 February 2000
at 9:59:31 pm'!
Morph subclass: #B3DSphereMorph
	instanceVariableNames: 'geometry angle texture '
	classVariableNames: ''
	poolDictionaries: ''
	category: 'Balloon3D-Demo Morphs'!

!B3DSphereMorph methodsFor: 'initialization' stamp: 'ar 2/3/2000 21:55'!
initialize
	super initialize.
	geometry _ B3DIndexedMesh vrml97Sphere. "Create sphere"
	self extent: 100 at 100.		"Make me square"
	self color: Color white.	"White for starters"
	angle _ 0.! !


!B3DSphereMorph methodsFor: 'drawing' stamp: 'ar 2/3/2000 21:47'!
drawOn: aCanvas
	^aCanvas asBalloonCanvas render: self! !

!B3DSphereMorph methodsFor: 'drawing' stamp: 'ar 2/3/2000 21:54'!
renderOn: aRenderer
	"Render the receiver. Since we want a parallel projection we don't
need a camera."
	aRenderer viewport: self bounds.
	aRenderer clearDepthBuffer.
	aRenderer material: (B3DMaterial new emission: self color).
	aRenderer transformBy: (B3DRotation angle: angle axis: 0 at 1@0).
	texture ifNotNil:[aRenderer texture: texture].
	geometry renderOn: aRenderer.! !


!B3DSphereMorph methodsFor: 'stepping' stamp: 'ar 2/3/2000 21:53'!
step
	angle _ angle + 5.
	self changed.! !

!B3DSphereMorph methodsFor: 'stepping' stamp: 'ar 2/3/2000 21:54'!
stepTime
	^50! !

!B3DSphereMorph methodsFor: 'stepping' stamp: 'ar 2/3/2000 21:54'!
wantsSteps
	^true! !


!B3DSphereMorph methodsFor: 'drag-and-drop' stamp: 'ar 2/3/2000 21:57'!
acceptDroppingMorph: aMorph event: evt
	texture _ aMorph imageForm asTexture.! !

!B3DSphereMorph methodsFor: 'drag-and-drop' stamp: 'ar 2/3/2000 21:56'!
wantsDroppedMorph: aMorph event: evt
	^true! !





More information about the Squeak-dev mailing list