An OpenGL oddity I could use some help on

Stephan Rudlof squeak-dev at lists.squeakfoundation.org
Wed Oct 16 14:27:48 UTC 2002


Bob,

I've played around (by trial and error, since I don't have time to
understand all the 3D stuff (especially the coordinate system/s)) and found,
that changing the position of the scene light results in much more of the
expected result.

Change:

> !BobsTestMorph methodsFor: 'as yet unclassified' stamp: 'raa 10/2/2002 16:43'!
> createDefaultScene
> 	| sceneObj camera obj lightColor |
> "
> BobsTestMorph new openInWorld
> "
> 	sceneObj _ B3DSceneObject named: 'Sample Cube'.
>
> 	obj _ B3DIndexedMesh vrml97Box copy.
> 	sceneObj texture: ((Form extent: 32 at 32 depth: 32) fillColor: Color gray;
asTexture).
> 	obj faceNormals.
> 	sceneObj geometry: obj.
> 	camera _ B3DCamera new.
> 	camera position: 3.5 at 0@3.5.
> 	camera fov: 20.
> 	self extent: 100 at 100.
> 	scene _ B3DScene new.
> 	scene defaultCamera: camera.
> 	scene objects add: sceneObj.
> 	lightColor _ B3DMaterialColor new.
> 	lightColor ambientPart: (Color gray: 0.5).
> 	lightColor diffusePart: (Color gray: 0.5).
> 	lightColor specularPart: (Color gray: 0.5).
> 	scene lights add: (
> 	  B3DDirectionalLight new lightColor: lightColor; direction: 1 at 1@1

---> B3DDirectionalLight new lightColor: lightColor; direction: 1 at 0@0

> 	).
> ! !

What remains is the missing of the reflection if exactly vertically looking
onto the illuminated side of the cube (light behind camera?).

Note: I've checked this without using the alpha channel, since my current
OpenGL renderer doesn't support it (puuh, getting it running at all was a
hard birth (patched VM compilation)!).


Greetings,

Stephan


Bob Arning wrote:
> Hi all,
> 
> I must be missing something, but what?
> 
> Cheers,
> Bob
> 
> 'From Squeak3.2 of 11 July 2002 [latest update: #4956] on 2 October 2002 at 4:45:13 pm'!
> "Change Set:		lightingTest
> Date:			2 October 2002
> Author:			Bob Arning
> 
> This has been puzzling me for quite a while. I have a simple 3-D scene with a cube and a directional light, like the sun. 
> 
> 	BobsTestMorph new openInWorld
> 
> The effect of the light, as I understand it, should depend on the angle between the light and the surface normals of the cube - not the position of the camera. However, as you move the camera (click and shift-click in this example), the shading of the sides of the cube will sometimes change. As the example is set up, one click in either direction will show a change in shading. Any ideas what's up?"!
> 
> B3DSceneMorph subclass: #BobsTestMorph
> 	instanceVariableNames: ''
> 	classVariableNames: ''
> 	poolDictionaries: ''
> 	category: 'Balloon3D-Demo Morphs'!
> 
> !BobsTestMorph commentStamp: 'raa 10/2/2002 15:35' prior: 0!
> BobsTestMorph new openInWorld!
> 
> 
> !B3DDirectionalLight methodsFor: 'converting' stamp: 'raa 10/2/2002 15:48'!
> direction: aVector
> 
> 	direction _ aVector
> ! !
> 
> 
> !BobsTestMorph methodsFor: 'as yet unclassified' stamp: 'raa 10/2/2002 16:43'!
> createDefaultScene
> 	| sceneObj camera obj lightColor |
> "
> BobsTestMorph new openInWorld
> "
> 	sceneObj _ B3DSceneObject named: 'Sample Cube'.
> 
> 	obj _ B3DIndexedMesh vrml97Box copy.
> 	sceneObj texture: ((Form extent: 32 at 32 depth: 32) fillColor: Color gray; asTexture).
> 	obj faceNormals.
> 	sceneObj geometry: obj.
> 	camera _ B3DCamera new.
> 	camera position: 3.5 at 0@3.5.
> 	camera fov: 20.
> 	self extent: 100 at 100.
> 	scene _ B3DScene new.
> 	scene defaultCamera: camera.
> 	scene objects add: sceneObj.
> 	lightColor _ B3DMaterialColor new.
> 	lightColor ambientPart: (Color gray: 0.5).
> 	lightColor diffusePart: (Color gray: 0.5).
> 	lightColor specularPart: (Color gray: 0.5).
> 	scene lights add: (
> 		B3DDirectionalLight new lightColor: lightColor; direction: 1 at 1@1
> 	).
> ! !
> 
> !BobsTestMorph methodsFor: 'as yet unclassified' stamp: 'raa 10/2/2002 16:41'!
> initialize
> 
> 	super initialize.
> 	self color: Color lightBlue.
> 	self accelerationEnabled: true.
> 	self on: #mouseDown send: #myMouseDown: to: self.
> 
> 
> ! !
> 
> !BobsTestMorph methodsFor: 'as yet unclassified' stamp: 'raa 10/2/2002 16:12'!
> myMouseDown: evt
> 
> 	scene defaultCamera rotateBy: (evt shiftPressed ifTrue: [-15] ifFalse: [15]).
> 	self changed.! !
> 
> !BobsTestMorph methodsFor: 'as yet unclassified' stamp: 'raa 10/2/2002 16:09'!
> step
> 
> 	"nada"! !
> 
> 
> 


-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3




More information about the Squeak-dev mailing list