Geometry and Light

Hello everybody,

I want to make some code to create a sphere geometry like the TestUtils.createSphere() but with uvMapping and some more options and to learn more about geometry :).
I made it but i’ve got some problem with light.

With TestUtils.createSphere() the sphere is lighted correctly (part of the sphere shadowed)

With the same code but with my createSphere the sphere is :

  • not lighted when the light is on negative Z axis
  • completely lighted with no shadows on it when the light is on positive Z axis

i don’t understand the problem with my geometry. With culling on; the normals seems good. What other parameters must be set for the geometry to be correctly lighted ?
(for the moment i only make the coord points (in correct order for the normal but i don’t explicity make the normal) and i put the texture Coords)

Thanks for help,

Adenthar.

Hello Adenthar

Have you set a material on your sphere?
Set ‘shininess’ to 0.0f, so your sphere is not
complete highlighted.

Bye Adi

hello aschwalb,

alas, it’s not that : i take exactly the same material, the same position and the same light : using the TestUtils.createSphere geometry it works, but with my sphere geometry it has this amazing behavior…

the geometry is missing something i think, but i don’t know what…

Adenthar.

Hello Adenthar

I use my own primitives. Sphere with trianglegeometry
or sphere with quadarraygeometry.
I have no idea, how i can integrate an image here,
so i can show you an example.
Also you must do a correct setting for Textureattributes,
Light and Material (for your Appearance).
( HAVE YOU SET THE FLAG ‘GeometryArray.NORMALS’ IN
YOUR GEOMETRY???).
e.g.

int features = …;

final int FLAGS = GeometryArray.COORDINATES | (features&GeometryArray.NORMALS)
| (features&GeometryArray.TEXTURE_COORDINATE_2);

TriangleArray geom = new TriangleArray( maxPoints, FLAGS );
geom.setCoordinates(0, vertex);
if ( (FLAGS&GeometryArray.NORMALS)!=0 )
geom.setNormals( 0, vertex );

Then all works fine in Xith.

Bye Adi