Please have a look at this small Webstart Jar. (In case my freespace host messes up the Jnlp’s MIME type, please use the the zipped .jnlp version instead.)
There’s a plate which spans the x-z axis (ie it lays on the “floor”). Plus a small model loaded with Kev’s 3ds loader. Directional light comes from the front, ie its vector is (0, 0, -1).
The camera ist at eye-coordinate (0, 0, 20), aiming at (0, 0, 0). It then moves slowly in an arc to (0, 20, 0), always aiming at (0, 0, 0).
The color of the plate (and the model) shouldn’t change, because the Nodes don’t move, just the camera. However they go light red. With the Xith version some days ago the colour didn’t change.
Do I get it wrong, or is there anything unusual with the current Xith3d version?
Many thanks.
PS: Basically the code looks like this:
class Theview
{
private Theview mTheview = new Theview();
public static void main() throws Exception
{
Point3f eye = new Point3f(0, 0, 0);
Point3f aim = new Point3f(0, 0.1f, 0);
for (int i = 0; i < 90; i++) {
eye.z = (float) (20 * Math.cos(Math.toRadians(i)));
eye.y = (float) (20 * Math.sin(Math.toRadians(i)));
mTheview.getTransform().lookAt(eye, aim, new Vector3f(0, 1, 0));
}
public Theview() throws Exception
{
BranchGroup sceneBg = new BranchGroup();
VirtualUniverse universum = new VirtualUniverse();
Locale lokal = new Locale();
lokal.addBranchGraph(sceneBg);
universum.addLocale(lokal);
universum.addView(mTheview);
sceneBg.addChild(getTestplatte());
sceneBg.addChild(new TDSLoader().load("Tube.3ds"));
RenderPeer renderpeer = new RenderPeerImpl();
CanvasPeer canvaspeer = renderpeer.makeCanvas(null, 640, 480, 32, false);
Canvas3D kanvas3d = new Canvas3D();
kanvas3d.set3DPeer(canvaspeer);
mTheview.addCanvas3D(kanvas3d);
DirectionalLight dirLicht = new DirectionalLight(new Color3f(0.8f, 0.8f, 0.8f), new Vector3f(0, 0, -1));
sceneBg.addChild(dirLicht);
AmbientLight ambLicht = new AmbientLight(true, new Color3f(0.6f, 0.6f, 0.6f));
sceneBg.addChild(ambLicht);
mTheview.startView();
}
/**
* @return Shape3D
*/
public static Shape3D getTestplatte()
{
final Point3f[] punktefeld = new Point3f[] {
new Point3f( 0, 0, 0),
new Point3f(15, 0, 0),
new Point3f(15, 0, -10),
new Point3f( 0, 0, -10)
};
final int[] polyverbinder = new int[] {
0, 1, 2,
2, 3, 0
};
final Vector3f[] normalenfeld = new Vector3f[] {
new Vector3f(0, 1, 0),
new Vector3f(0, 1, 0),
new Vector3f(0, 1, 0),
new Vector3f(0, 1, 0)
};
IndexedTriangleArray geo = new IndexedTriangleArray(punktefeld.length, GeometryArray.COORDINATES | GeometryArray.NORMALS, polyverbinder.length);
geo.setCoordinates(0, punktefeld);
geo.setIndex(polyverbinder);
geo.setValidIndexCount(polyverbinder.length);
geo.setNormals(0, normalenfeld);
Appearance ape = new Appearance();
Material material = new Material();
material.setColorTarget(Material.AMBIENT_AND_DIFFUSE);
ape.setMaterial(material);
ape.setPolygonAttributes(new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_BACK, 0));
ape.setColoringAttributes(new ColoringAttributes(new Color3f(1, 0, 0), ColoringAttributes.NICEST));
return new Shape3D(geo, ape);
}
}
I mean: all the surfaces don’t change in colour, because they’re lit with just a directional light, and like the models, the light source doesn’t change its position when the app runs. Just the camera moves.