AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Lighting having no effect

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> 3D Graphics API's for Java
View previous topic :: View next topic  
Author Message
Dave
Guest





PostPosted: Thu Apr 13, 2006 7:12 pm    Post subject: Lighting having no effect Reply with quote



I am trying to add lighting to a simple 4x4 QuadArray terrain mesh.

However all that seems to happen is that the color I have specified for the
Shape3D object is displayed purely i.e. no shading at all just 100% the same
color all over the object. The only effect the light seems to be having is
direction i.e. you can only see the shape at all when one surface is
pointing down the way.

I have tried both AmbientLight and DirectionalLight and they are both having
no effect. My addLight method and Terrain class constructor is below.

public void addLight(Color3f color)
{
// Creates a bounding sphere for the lights
BoundingSphere bounds = new BoundingSphere();
bounds.setRadius(1000d);
AmbientLight lightA = new AmbientLight(true, color);
lightA.setInfluencingBounds(bounds);
// Then add it to the root BranchGroup
rootBranchGroup.addChild(lightA);
}

public Terrain(float[ ][ ] hf, Appearance app)
{
heightField = hf;
appearance = app;
geometryInfo = new GeometryInfo(GeometryInfo.QUAD_ARRAY);

Point3f[ ] coordinates = new Point3f[64];

//... "coordinates" generated here ...

geometryInfo.setCoordinates(coordinates);
NormalGenerator normalGenerator = new NormalGenerator();
normalGenerator.generateNormals(geometryInfo);
geometryArray = geometryInfo.getGeometryArray();
}
Back to top
Nick Wiedenbrück
Guest





PostPosted: Thu Apr 13, 2006 11:12 pm    Post subject: Re: Lighting having no effect Reply with quote



Hi Dave again,

i don't understand lightning in Java3D well, either.
But i've got some hints.

The first thing you need is a Material for your Shape3D
object, that you can create using the Appearance class:

app.setMaterial(new Material()); (That is a sufficient Material)

Possibly, this is all that is missing.
A second hint is to use the SpotLight class.

Good luck,
Nick
Back to top
Dave
Guest





PostPosted: Sat Apr 15, 2006 2:12 pm    Post subject: Re: Lighting having no effect Reply with quote



"Nick Wiedenbrück" <nick-w (AT) web (DOT) de> wrote in message
news:e1ml03$s10$1 (AT) news01 (DOT) versatel.de...
Quote:
Hi Dave again,

i don't understand lightning in Java3D well, either.
But i've got some hints.

The first thing you need is a Material for your Shape3D
object, that you can create using the Appearance class:

app.setMaterial(new Material()); (That is a sufficient Material)

Possibly, this is all that is missing.

This fixed it, thanks again. Smile
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> 3D Graphics API's for Java All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.