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

modelViewProjectionMatrix

<< < (2/6) > >>

EgonOlsen:
I could add something like that, but it feels a bit strange to me, because the matrix actually isn't an attribute of an object. Anyway, this leaves some questions: What if the object wasn't visible before? And what if it was but 2-x frames in the past? Does that matter?

Wouldn't it be better to simply inject the projection matrix (which doesn't change between frames unless you change the fov) into the shader and let the application control the injection of an additional model view matrix (which is simple the world transformation from the last frame in that case). That requires slightly more code on your side, but it seems to be the more logical and flexible solution to me.

About that render-method: You can simply extend FrameBuffer and add it yourself. Just iterate over all objects in the world, set your shader and call the super-method. I don't see the need for such a special purpose method to be part of the general API.

Thomas.:
If the object wasn't visible before? I didn't thinking about this, it is problem, object will has some "random" speed. But I don't show objects in middle of screen, so it will be fine. And if the object was never visible, be ideal send current MVPM, it has zero speed.

OK, it would be fine, but I don't know how to create model view matrix from transformation...?

Fine, I'll try it.

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

Thomas.:

--- Quote from: EgonOlsen on July 20, 2012, 05:44:06 pm ---About that render-method: You can simply extend FrameBuffer and add it yourself. Just iterate over all objects in the world, set your shader and call the super-method. I don't see the need for such a special purpose method to be part of the general API.

--- End quote ---

Did you mean extends World? There is no method for get GLSLShader from Object3D. I have to copy all to array, draw and return original shader. It is not well solution, but probably there is nothing else...

And how can I set uniform for specific object, if many objects use one shader? Or uniforms are per shader?

EgonOlsen:
Yes, i meant to extend World. I've also added the getter for shaders to the beta-jar.

About the uniforms: They are per shader but you can set them per object, if you implement the IRenderHook interface and use setCurrentObject3D() and/or beforeRendering() for this.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version