Wrong normals rotations when object has a parent which is scaled

Started by Klaudiusz, October 11, 2007, 11:11:29 PM

Previous topic - Next topic

Klaudiusz

Hi Egon,

Please take a look on attached example, it shows how normals are modified when object has a parent and this parent is scaled.

import java.awt.Color;

import com.threed.jpct.*;

public class TestSize {

public static void main(String[] args) {
World w = new World();
FrameBuffer fb = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_GL_AA_2X);
fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
fb.enableRenderer(IRenderer.RENDERER_OPENGL);
Object3D Toy= Primitives.getCube(17);


TextureManager tm = TextureManager.getInstance();
Texture vt = new Texture("blue067.jpg");

tm.addTexture("uv", vt);


TextureInfo ti=new TextureInfo(tm.getTextureID("uv"));

Toy.setTexture(ti);
Toy.setEnvmapped(Object3D.ENVMAP_ENABLED);


Object3D Toy2=Toy.cloneObject();
Toy2.translate(50, 0, 0);
Toy.addChild(Toy2);


w.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, 200);
w.getCamera().moveCamera(Camera.CAMERA_MOVEUP, 50);
w.setAmbientLight(250, 250, 250);
Toy.build();
w.addObject(Toy);
Toy2.build();
w.addObject(Toy2);


while(!org.lwjgl.opengl.Display.isCloseRequested()) {

fb.clear(Color.DARK_GRAY);
w.renderScene(fb);
w.draw(fb);
fb.update();
fb.displayGLOnly();
Toy.scale(1.001f);
Toy.rotateX(0.005f);
w.getCamera().lookAt(Toy2.getTransformedCenter());

try {
Thread.sleep(10);
} catch(Exception e) {}

}
fb.dispose();

}

}

EgonOlsen

I'll look into it on monday. Thanx for the test case. This is always very helpful to me.

EgonOlsen