Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Balloon3D examples
Last updated at 1:42 pm UTC on 16 January 2006

Example one

rend _ B3DRenderEngine defaultForPlatformOn: Display.
rend viewport: (Rectangle origin: 10@10 extent: 200@200).
rend clearViewport: Color black. "This causes an error: MessageNotUnderstood: origin"
cam _ B3DCamera new.
cam initialize.
cam position: 0@0@2.
rend clearDepthBuffer.
rend loadIdentity.
cam renderOn: rend.
"tex _ Form fromUser.
rend texture: tex."
rend trackEmissionColor: true.
rend normal: 0@0@1.
rend color: Color white.
rend drawPolygonAfter: [
rend
"texCoords: -1@-1;"
vertex: -1@-1@0;
"texCoords:1@-1;"
vertex: 1@-1@0;
"texCoords: 1@1;"
vertex: 1@1@0;
"texCoords: -1@1;"
vertex: -1@1@0.
].
rend flush.

Example 2


se := B3DSceneExplorerMorph new openInWorld.

so := B3DSceneObject named: 'cone'.
cone := B3DIndexedMesh vrml97Cone.

"Do I need to create colors for the vertices?"
colors := B3DColor4Array new: (cone vertices size ).
1 to: (colors size) do:[:i| colors at: i put: (B3DColor4 r: 1 g: 0 b: 0
a: 0.5)].
so geometry: ((B3DIndexedMesh vrml97Cone) vertexColors: colors).
so material: (B3DMaterial new emission: Color yellow).

"Camera seems critical"
camera _ B3DCamera new.
camera position: 0@0@-1.5.

scene _ B3DScene new.
scene defaultCamera: camera.

"the headLight code is from B3DSceneExplorerMorph. Is it important?"
headLight := B3DSpotLight new.
headLight position: 0@-1@0.
headLight target: 0@0@0.
headLight lightColor: (B3DMaterialColor color: (Color blue)).
headLight attenuation: (B3DLightAttenuation constant: 1.0 linear: 0.0
squared: 0.0).
headLight minAngle: 5.
headLight maxAngle: 6.
scene lights add: headLight.

"This seems to work, except it's dark gray"
scene objects add: so.

"Now do the sphere, dark gray also"
so1 := B3DSceneObject named: 'Sphere'.
so1 geometry: (B3DIndexedMesh vrml97Sphere).
so1 material: (B3DMaterial new emission: Color green).

scene objects add: so1.

"Is this necessary? It's from B3DSceneExplorerMorph"
" No, remove this. You need materials. Materials define
the surface color of a body. "

"scene objects do: [ :object |
object material: nil]."

"Now change the displayed B3DSceneExplorerMorph, but,
the cone and sphere are both dark gray"
se scene: scene.