SKewing Sprites

Discussion about everything. New games, 3d math, development tips...
Post Reply
Aare
Posts: 3
Joined: Mon Feb 06, 2012 9:55 am

SKewing Sprites

Post by Aare »

Hi,

Im writing a game in OpenGL, and stumbled upon simple, yet irritating problem. I want to have a square (I`m using ortographic camera), where I can set any position to each of the four corners, even if that would mean to make a diamond, or trapezium from that square. I created a basic square using two triangles, but the problem is texture mapping, it does not show properly. I found the description, and solution to the problem at this website http://www.xyzw.us/~cass/qcoord/ but it only work when moving the top(bottom) two corners to each othwer, I want more complex solution that would allow me to imitate perspective in any direction based on the corners position. Any common solutions to that?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: SKewing Sprites

Post by hybrid »

Are you sure that this does not work for other combinations and transformations?
Aare
Posts: 3
Joined: Mon Feb 06, 2012 9:55 am

Re: SKewing Sprites

Post by Aare »

What do you mean by that? If I move the corners and leave texture position alone it look like described in that article. Rotating and transforming it in 3D space is not a solution, as I need the corners to be in specific position, and the texture to look consistent.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: SKewing Sprites

Post by hybrid »

Well, I asked if you tried to use that code and a different layout of the sprite, e.g. small bottom part. I think it should work that way as well.
Aare
Posts: 3
Joined: Mon Feb 06, 2012 9:55 am

Re: SKewing Sprites

Post by Aare »

Well, it doesn`t. The solution from the article work only for the case when the top two corners are moved horizontally. If I move one of them vertically it again look bad. Small bottom/side parts also didn`t work with that solution.

//EDIT: I found this post: http://www.gamedev.net/topic/419296-ske ... in-opengl/ this is exactly the same problem as I have. I tried to render it in 3D, but there are few problems connected with that:
1. I don`t know how to map the "on screen" vertex positions to the rotate/translate/scale translations of the quad
2. When I move it around the screen, the perspective changes the appernance of the quad, also I have no idea how to eliminate that.

//EDIT2: Fortunatelly I found the solution :) here it is: http://stackoverflow.com/questions/5892 ... -in-opengl in case anyoune would look for the solution in the future...
Post Reply