Stange Overlay shear effect

Started by devcat, October 18, 2014, 10:46:34 PM

Previous topic - Next topic

devcat

Hi,

i try to apply a shear operation to an Overlay. I tried the following code with the jPCT PC version and it works fine.

// inside some update routine
Matrix mat = overlay.getObject3D().getRotationMatrix();
mat.set(0, 1, shearY);
mat.set(1, 0, shearX);


Then i tried it on android and for some reason it does an additional translation besides the shear operation.
Any suggestions?

Thanks

EgonOlsen

I don't see, why it should do that. Can you try to add a call to


overlay.getObject3D().compile();


to the desktop version to see if this has a similar translation effect there. Are you setting a rotation pivot to the Overlay, btw?

devcat

When i call in the desktop version

overlay.getObject3D().compile();

the overlay don't appear on screen.
And nope, I don't set the rotation pivot in the Overlay.

EgonOlsen

I see...Overlays in the desktop version are obviously not supposed to be compiled. Ok...i've no idea then. I really don't see, where this translation should come from. How large is it? Dso you have a screen shot with and without the shearing?

devcat

Actually it's peaty simple to write an example, then you can see it in motion for your self. Just take your HelloWorld-AE example and add the following lines

public void onSurfaceChanged(GL10 gl, int w, int h) {
// ...
// world.addObject(cube);

// new code
overlay = new Overlay(world, fb, "texture");
overlay.setNewCoordinates(300, 150, 400, 250);
// ...
}

public void onDrawFrame(GL10 gl) {

// new code
com.threed.jpct.Matrix mat = overlay.getObject3D().getRotationMatrix();
mat.set(1, 0, (float) Math.cos(shearX));
shearX += 0.01f;
// ...
}

Hope this helps :).

EgonOlsen

I see...still no idea where this comes from. I'll look at it, but maybe not today...

EgonOlsen

Seems to be an issue with the way in which the position is calculated. If the rotation matrix isn't a proper rotation matrix, this fails and i don't see how to fix this. In desktop jPCT, it works because the pipeline for these Overlays is different and obviously not affected. I found a work-around though. Take these jars

jPCT-AE: http://jpct.de/download/beta/jpct_ae.jar
jPCT: http://jpct.de/download/beta/jpct.jar

They add a new method to the Overlay class called setInitialMatrix(). Just apply your shear operation to that one and leave the rotation matrix alone. At least it works for jPCT-AE, i'm not sure about desktop jPCT though.

devcat

Thanks for the really fast workaround, now both versions support the Overlay shearing perfectly. Just have to make sure to don't call accidentally overlay.compile(), because this will leave to some known side effects ^^.