[Q] B3DDemo tutorial

Boris Gaertner Boris.Gaertner at gmx.net
Tue Feb 18 20:09:32 UTC 2003

David Faught <dave_faught at yahoo.com> wrote

> I am trying to do the tutorial included in the B3DDemo.zip file, which
> is pointed to by the minnow swiki (which seems to be gone right now)
> documentation section on graphics.
> It appears that the ambient lighting does not work, or something like
> that.  The rotating cylinder example and the other objects that I have
> tried to create always come out black.  The rotating cylinder does have
> a spot of blue right at the origin, but is otherwise black.  I have
> tried adding an ambient light, but this does not help anything.
> Any ideas what I need to do here?
A piece of coal will be black under any light. To see the effect of
ambient light, you have to look at a body that reflects colored
light. Ideally, you use a body that reflects all colors.

Translated into the language of B3D, this means that you have to
"cover" your scene object with a material that reflects
colored light. For best results, you should use  Color white
as  ambient part of that material.

When you experiment with B3DSceneMorph>>createDefaultScene
(as proposed in the tutorial), you may wish to try this: (my additions in
boldface types)

   | sceneObj camera mat ambientLight |
   sceneObj _ B3DSceneObject named: 'Sample Cube'.
   sceneObj geometry: (B3DIndexedMesh vrml97Cylinder)..
   mat := B3DMaterial new.
   mat ambientPart: (Color gray: 0.99). 
           " this is suitable for ambient light of all colors. "
           " change the ambient part to see how this property works
               together with the color of the ambient light. "

 sceneObj material: mat.

 camera _ B3DCamera new.
 camera position: 0 at 0@-1.5.
 self extent: 100 at 100.
 scene _ B3DScene new.
 scene defaultCamera: camera.
 scene objects add: sceneObj.
  ambientLight :=B3DAmbientLight new. 
  ambientLight lightColor: (B3DMaterialColor color: Color green). 
  scene lights add: ambientLight.

1. A B3DMaterial defines the visual properties of a solid.
    Without a material, a solid is indeed a piece of coal.

2. (Color gray: 0.99) is almost the same as Color white.
3. You may wish to try
    mat ambientPart: (Color r: 0.7 g: 0.7 b: 0.0)
    and study the effect of different ambient light colors.
    (You should see that the body reflects red, green and
     colors that are mixed from red and green)  

Look also at  B3DDemoSpheres example3
for an example that uses ambient light and a material that
reflects ambient light.

I hope this helps, but feel free to ask again if it does not!

Greetings, Boris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030218/9912acf8/attachment.htm

More information about the Squeak-dev mailing list