How to program with Balloon3D
Last updated at 4:10 pm UTC on 14 January 2006
Question On 5/5/2004: How can I program with Balloon3D so as to place a texture to a geometric object?
Answer Boris Gaertner Let us look to this problem in some detail. The example
should show two intersecting surfaces that are colored with textures: One with a green chess-board pattern, the other with a red one. An white ambient light is added to the scene - without that light both surfaces would appear black! This is very important. To see a texture, you have to use either a scene light (white ambient
light is always a good start) or you have to add a material with light emission to your geometric object. This is done with:
mat := B3DMaterial new.
mat emission: (Color gray: 0.99).
sceneObj material: mat.
A texture is an image that you place on an objects surface. You cannot use a form directly, you have to send it the message #asTexture to convert it into a texture.
When you use a texture, you have to add the texture to the scene object and texture coordinates to the mesh. Texture coordinates are an instance of B3DTexture2Array. The elements are points - one for every vertex of the mesh). Point coordinates in the range 0.0 .. 1.0 are mapped onto the texture. For point coordinates outside that range the texture is repeated.
... The examples of the tutorial [In Squeak 3.6 or later, bring up the world menu, choose "open" and then "Balloon3D Tutorial"] were written for an earlier version of Balloon3D. Later the automatic computation of vertext normals was removed and that is the reason that some examples appear black. Attached B3DTutorialFix.zip you find a change set that adds the computation of vertex normals. Vertex normals are needed when geometric objects are colored with directed lights. The fix contains also a button in the presenter window that you can use to switch to hardware acceleration. (This requires OpenGL!)
Do other people get crashes when using Hardware acceleration on Linux?
I've tried with both the 3.6-3 and 3.7-5868(beta), and I consistently get segfaults.. e.g.:
1134253376  in B3DScene>renderOn:
I'm running redhat 9.0 with a NVidia GEForce 3.
thanks, Daniel Faken (9/1/2004)