modelViewProjectionMatrix

Started by Thomas., July 20, 2012, 11:11:34 AM

Previous topic - Next topic

Thomas.

#15
Object3D.getID() ... Object3D has still same ID or it can be reset?

EgonOlsen

The ids will be assigned by the engine, but you can set/reset the counter. However...why would you want to?

Thomas.

#17
I want to store MVM and IRenderHook in HashMap, render and return all original IRenderHook...

edit: and original shader...

EgonOlsen

Ok, but why do you want to reset the id for that?

Thomas.

I don't want to reset IDs, I thought, that jPCT can reset them in some cases...

EgonOlsen

I misunderstood you there...no, jPCT doesn't reset the id by itself.

Thomas.

Ok and IDs are also unique between worlds or not?

EgonOlsen



Thomas.

Could you add method for get RenderHook from Object3D?

EgonOlsen

I've added that method. Please download the latest beta jar.

Thomas.

Quote from: EgonOlsen on July 27, 2012, 07:45:55 PM
I've added that method. Please download the latest beta jar.

Thanks ;) I can set uniforms per object, now.

Quote from: EgonOlsen on July 20, 2012, 08:25:28 PM
I've added support for a new uniform called "projectionMatrix" to the beta jar. The model view matrix can be calculated like this (unoptimized):


Matrix mc=new Matrix();
Matrix mv=obj.getWorldTransformation();
mc.setTo(world.getCamera().getBack());
SimpleVector v=world.getCamera().getPosition();
v.scalarMul(-1);
mc.translate(v);
mv.matMul(mc);


In these calculations is small bug. If someone will need it, here is fixed code.

private Matrix calcModelViewMatrix(World world, Object3D object) {
Camera cam = world.getCamera();
Matrix mc = new Matrix();
Matrix modelView = object.getWorldTransformation();
Matrix backMatrix = cam.getBack();
mc.setTo(backMatrix);
SimpleVector v = cam.getPosition();
v.scalarMul(-1);
modelView.translate(v);
modelView.matMul(mc);
return modelView;
}