www.jpct.net

jPCT - a 3d engine for Java => Bugs => Topic started by: Klaudiusz on October 11, 2007, 11:11:29 pm

Title: Wrong normals rotations when object has a parent which is scaled
Post by: Klaudiusz on October 11, 2007, 11:11:29 pm
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.

Code: [Select]
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();

}

}
Title: Re: Wrong normals rotations when object has a parent which is scaled
Post by: EgonOlsen on October 12, 2007, 12:19:50 pm
I'll look into it on monday. Thanx for the test case. This is always very helpful to me.
Title: Re: Wrong normals rotations when object has a parent which is scaled
Post by: EgonOlsen on October 15, 2007, 07:17:58 pm
Please try the jar at http://www.jpct.net/download/beta/jpct.jar (http://www.jpct.net/download/beta/jpct.jar) to see if this fixes your problem.
Title: Re: Wrong normals rotations when object has a parent which is scaled
Post by: Klaudiusz on October 17, 2007, 11:05:17 am
Everything works fine. Thank You!