Author Topic: Stange Overlay shear effect  (Read 1052 times)

Offline devcat

  • byte
  • *
  • Posts: 7
    • View Profile
Stange Overlay shear effect
« on: October 18, 2014, 10:46:34 pm »
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.
Code: [Select]
// 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Stange Overlay shear effect
« Reply #1 on: October 18, 2014, 11:00:14 pm »
I don't see, why it should do that. Can you try to add a call to

Code: [Select]
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?

Offline devcat

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Stange Overlay shear effect
« Reply #2 on: October 18, 2014, 11:32:45 pm »
When i call in the desktop version
Code: [Select]
overlay.getObject3D().compile();
the overlay don't appear on screen.
And nope, I don't set the rotation pivot in the Overlay.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Stange Overlay shear effect
« Reply #3 on: October 18, 2014, 11:48:02 pm »
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?

Offline devcat

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Stange Overlay shear effect
« Reply #4 on: October 19, 2014, 12:02:27 am »
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
Code: [Select]
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 :).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Stange Overlay shear effect
« Reply #5 on: October 19, 2014, 03:03:07 pm »
I see...still no idea where this comes from. I'll look at it, but maybe not today...

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11777
    • View Profile
    • http://www.jpct.net
Re: Stange Overlay shear effect
« Reply #6 on: October 20, 2014, 04:43:08 pm »
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.

Offline devcat

  • byte
  • *
  • Posts: 7
    • View Profile
Re: Stange Overlay shear effect
« Reply #7 on: October 21, 2014, 09:11:15 pm »
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 ^^.