jPCT-AE - a 3d engine for Android > Support

modelViewProjectionMatrix

<< < (6/6)

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.

--- End quote ---

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):


--- Code: ---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);

--- End code ---

--- End quote ---

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


--- 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;
}
--- End code ---

Navigation

[0] Message Index

[*] Previous page

Go to full version