Hallo,
ich mach jetzt einfach mal copy&paste, da ich das Problem schon in einem englischen Forum gepostet habe aber ich befürchte, dass mir dort niemand helfen kann ....
Hello,
I am at a loss ... I can't establish a proper lighting in my scene.
Screen 1: http://img641.imageshack.us/img641/618/screen1ug.png
Screen 2: http://img121.imageshack.us/img121/7098/screen3re.png
Screen 3: http://img641.imageshack.us/img641/8796/screen2s.png
Screen 4: ImageShack® - Online Media Hosting
Explanation:
In the moment I placed 4 DirectionalLights around my geometry (a heart model), each little cube represents a directional light and they all point to the big cube in the middle of the heart.
But the lightning behavior isn't what I expected it to be.
Plz have a look at the constructor of my HearWindow class and 3 methods ... I would be very delighted if someone can help me.
I am pretty sure I do something wrong while positioning the light sources and set the vector of the light direction but it seems i am to stu*** to figure out what the problem is.
HeartWindow ----------------------------------------------------------------------------------------------------------------------
And here are three methods of this class which are important if you wanna help me ----------------------------------------------------------------------------------------------------------------------------
Danke, danke, danke, dass du dir die Arbeit gemacht hast, dich bis her durch zu schlagen .... hoffe du kannst mir helfen ; )
Liebe Grüße
ich mach jetzt einfach mal copy&paste, da ich das Problem schon in einem englischen Forum gepostet habe aber ich befürchte, dass mir dort niemand helfen kann ....
Hello,
I am at a loss ... I can't establish a proper lighting in my scene.
Screen 1: http://img641.imageshack.us/img641/618/screen1ug.png
Screen 2: http://img121.imageshack.us/img121/7098/screen3re.png
Screen 3: http://img641.imageshack.us/img641/8796/screen2s.png
Screen 4: ImageShack® - Online Media Hosting
Explanation:
In the moment I placed 4 DirectionalLights around my geometry (a heart model), each little cube represents a directional light and they all point to the big cube in the middle of the heart.
But the lightning behavior isn't what I expected it to be.
Plz have a look at the constructor of my HearWindow class and 3 methods ... I would be very delighted if someone can help me.
I am pretty sure I do something wrong while positioning the light sources and set the vector of the light direction but it seems i am to stu*** to figure out what the problem is.
HeartWindow ----------------------------------------------------------------------------------------------------------------------
Java:
public class HeartWindow extends Applet
{
private Canvas3D canvas3D;
private TransformGroup tg;
private SimpleUniverse universe;
private ArrayList<HeartAdapter> materialList;
private static HeartWindow instance;
private Transform3D transform;
private BoundingSphere bounds;
private final Vector3f HEART_CENTER_VECTOR = new Vector3f(0.30968136f, -0.09346509f,-0.30586654f);
private final Point3f HEART_CENTER_POINT = new Point3f( 0.30968136f, -0.09346509f,-0.30586654f);
private HeartWindow()
{
//Create a canvase3d to display the heart with instantiate a SimpleUniverse with it
setLayout(new BorderLayout());
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
this.canvas3D = new Canvas3D(config);
add("Center", canvas3D);
this.universe = new SimpleUniverse(canvas3D);
//set up view with the ViewingPlatform utility class
this.universe.getViewingPlatform().setNominalViewingTransform();
//create contentBG and set up an OrbitBehavior in the view-branch-graph
BranchGroup bg = new BranchGroup();
this.tg = new TransformGroup();
//set capability to be able to extend children
this.tg.setCapability(TransformGroup.ALLOW_CHILDREN_EXTEND);
bg.addChild(tg);
//this bounds surrounds the whole heart geometry and is importont for this behavior, lights etc.
this.bounds = new BoundingSphere(new Point3d(HEART_CENTER_POINT.getX(),
HEART_CENTER_POINT.getY(),
HEART_CENTER_POINT.getZ()), 2);
//set up OrbitBehavior
OrbitBehavior orbit = new OrbitBehavior(canvas3D, OrbitBehavior.REVERSE_ALL);
orbit.setRotationCenter(new Point3d(HEART_CENTER_POINT.getX(), HEART_CENTER_POINT.getY(), HEART_CENTER_POINT.getZ()));
orbit.setSchedulingBounds(bounds);
orbit.setMinRadius(0);
//set up OrbitBehavior
ViewingPlatform viewingPlatform = universe.getViewingPlatform();
viewingPlatform.setViewPlatformBehavior(orbit);
//transform the position of the TransformGroup to the heart center positon
setTransformGroupToHeartCenter();
//add an AmbientLight source into the heart center
AmbientLight ambientLight = new AmbientLight(new Color3f(0.8f, .80f, .80f));
ambientLight.setInfluencingBounds(bounds);
tg.addChild(ambientLight);
addCubeToHeartCenter();
//add 4 DirectionalLights
// setUpDirectionalLight(new Vector3f(0f, -1f, 0.2f) , new Vector3f(0.0f, 0.0f, 0.0f), getAndSetupSphere());
setUpDirectionalLight(new Vector3f(0f, -1.5f, 0.2f) ,HEART_CENTER_VECTOR, getAndSetupSphere());
setUpDirectionalLight(new Vector3f(0f, 0.2f, 1.5f) , HEART_CENTER_VECTOR, getAndSetupSphere());
setUpDirectionalLight(new Vector3f(1.5f, -1.2f, -0.15f), HEART_CENTER_VECTOR, getAndSetupSphere());
setUpDirectionalLight(new Vector3f(0f, 0.2f, -1f) , HEART_CENTER_VECTOR, getAndSetupSphere());
// setUpDirectionalLight(new Vector3f(0f, -1.5f, 0.2f), new Vector3f(0f,0f,0f), getAndSetupSphere());
// setUpDirectionalLight(new Vector3f(0.4f, 0.7f, -1.8f), new Vector3f(0f, 0f, 0f), getAndSetupSphere());
//get an instance of an ArrayList for saving the different materials
materialList = new ArrayList<HeartAdapter>();
//create heart geometry
this.materialList = GeometryFactory.createHeartGeometry();
// Point3f heartCenter;
// heartCenter = GeometryFactory.getHeartCenter();
//create heart geometry as one shape - experimental
//for more information please have a look at the class descrition of CompleteHeartGeometryInOneShape
// this.materialList = HeartGeometryFabric.createHeartGeometryInOneShape();
//add all materials from the list to viewGraph
for(int i = 0; i < materialList.size(); i++) {
tg.addChild(materialList.get(i));
}
And here are three methods of this class which are important if you wanna help me ----------------------------------------------------------------------------------------------------------------------------
Java:
private void addCubeToHeartCenter()
{
Transform3D transform = new Transform3D();
transform.setTranslation(HEART_CENTER_VECTOR);
TransformGroup tgMoveToCenter = new TransformGroup(transform);
ColorCube cube = new ColorCube(0.05f);
tgMoveToCenter.addChild(cube);
this.tg.addChild(tgMoveToCenter);
}
private void setUpDirectionalLight(Vector3f positionOfLight, Vector3f lightVector, ColorCube sphere)
{
Transform3D transform = new Transform3D();
transform.setTranslation(positionOfLight);
TransformGroup tgMove = new TransformGroup(transform);
DirectionalLight light = new DirectionalLight();
light.setColor(new Color3f(0.5f, .5f, .5f));
BoundingSphere bounds = new BoundingSphere();
light.setInfluencingBounds(bounds);
tgMove.addChild(light);
tgMove.addChild(sphere);
this.tg.addChild(tgMove);
light.setDirection(lightVector);
}
private ColorCube getAndSetupSphere()
{
ColorCube sphere = new ColorCube(0.02);
sphere.setAppearance(HeartAppearance.getInstance());
return sphere;
}
Danke, danke, danke, dass du dir die Arbeit gemacht hast, dich bis her durch zu schlagen .... hoffe du kannst mir helfen ; )
Liebe Grüße