mattmgl

08-29-2012, 06:21 PM

Hey folks,

Anyone know of a good example of a start to finish 3d transformation? The platform I'm running on uses gles 2 so I don't have the use of the old gl functions that allowed me to avoid the math I've been terrible with my whole life. I've been reading everything I can find but for some reason I just can't seem to get it.

What I'm mostly stuck at is perspective (and I guess view), object transformation is easy. For example, if we look at this page:

http://www.opengl.org/wiki/Vertex_Transformation

There's an example at the start:

glLoadIdentity();

glFrustum(-0.1, 0.1, -0.1, 1.0, 1.0, 1000.0);

They then have the result as:

[1.81, 0.00, -0.81, 0.00]

[0.00, 10.0, 0.00, 0.00]

[0.00, 0.00, -1.002, -2.002]

[0.00, 0.00, -1.00, 0.00]

But how do they get that? According to this:

http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml

The top left equation in the perspective matrix is:

(2*znear)/(right - left) = (2.0 * 1.0)/(0.1 - (-0.1)) = (2/0.2) = 10;

I can't see how they got 1.81. However, at 2,2 in the perspective matrix we have:

(2*znear)/(top - bottom) = (2.0 * 1.0)/(1.0 -(-0.1)) = (2/1.1) = 1.81

basically, if I apply the input values as in the example, I get:

10.0, 0.0, 0.0, 0.0

0.0, 1.81, 0.81, 0.0

0.0, 0.0, -1.002, -2.002

0.0, 0.0, -1.0, 0.0

My bottom right 2x2 is good but the rest is seemingly in the wrong position and some the wrong sign.

I must be missing something in between. Any help would be much appreciated. Please don't be negative. I have a hard time with math, including algebra. This is not school homework assignment, I'm trying to build a little concept so I really only need to get a cube on the screen for now that I can rotate around (later I'll move up to using generated models). I used OpenGL in the past but back then this stuff was done in the background. Now I had to learn about shaders and some other new stuff but it's the math that's stumping me.

What would be the best would be a step by step example in which there is a set of vertices that are put through the basic transformations (scale, rotate, translate), have their coordinates modified, calculate view and perspective, etc. All with examples worked through using actual values, start to finish through the basic pipeline.

Context:

All I need is a cube on the screen and the ability to transform it locally as well as move the camera around it. The project is more of functionality with other aspects of the platform in that I'm going to create a bluetooth interface to change the various parameters (short form: I'm gonna make a bluetooth keyboard/joystick for the platform) and then incorporate other hardware aspects of the platform. Since it's also running OpenGL ES 2 and since this a more of a proof of concept thing, the idea is to have a 3d model as that which is manipulated (I could do text on a debug console, for example, but that's boring). I got excited because in days past I've used GL for this type of thing lots of times but they did the matrix and other math in the background for me. Given that this is the case, I just don't have time to do things like read the Red Book or go back and re-learn algebra, etc. This has all been done, I just need a concrete example (so please, I ask in kindness, if you cannot help me other than to suggest that I need a basic understanding of algebra, I understand this and yes, if I was going to be a graphics programmer, that's true, but that's not the case).

Thanks,

Matt M

Anyone know of a good example of a start to finish 3d transformation? The platform I'm running on uses gles 2 so I don't have the use of the old gl functions that allowed me to avoid the math I've been terrible with my whole life. I've been reading everything I can find but for some reason I just can't seem to get it.

What I'm mostly stuck at is perspective (and I guess view), object transformation is easy. For example, if we look at this page:

http://www.opengl.org/wiki/Vertex_Transformation

There's an example at the start:

glLoadIdentity();

glFrustum(-0.1, 0.1, -0.1, 1.0, 1.0, 1000.0);

They then have the result as:

[1.81, 0.00, -0.81, 0.00]

[0.00, 10.0, 0.00, 0.00]

[0.00, 0.00, -1.002, -2.002]

[0.00, 0.00, -1.00, 0.00]

But how do they get that? According to this:

http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml

The top left equation in the perspective matrix is:

(2*znear)/(right - left) = (2.0 * 1.0)/(0.1 - (-0.1)) = (2/0.2) = 10;

I can't see how they got 1.81. However, at 2,2 in the perspective matrix we have:

(2*znear)/(top - bottom) = (2.0 * 1.0)/(1.0 -(-0.1)) = (2/1.1) = 1.81

basically, if I apply the input values as in the example, I get:

10.0, 0.0, 0.0, 0.0

0.0, 1.81, 0.81, 0.0

0.0, 0.0, -1.002, -2.002

0.0, 0.0, -1.0, 0.0

My bottom right 2x2 is good but the rest is seemingly in the wrong position and some the wrong sign.

I must be missing something in between. Any help would be much appreciated. Please don't be negative. I have a hard time with math, including algebra. This is not school homework assignment, I'm trying to build a little concept so I really only need to get a cube on the screen for now that I can rotate around (later I'll move up to using generated models). I used OpenGL in the past but back then this stuff was done in the background. Now I had to learn about shaders and some other new stuff but it's the math that's stumping me.

What would be the best would be a step by step example in which there is a set of vertices that are put through the basic transformations (scale, rotate, translate), have their coordinates modified, calculate view and perspective, etc. All with examples worked through using actual values, start to finish through the basic pipeline.

Context:

All I need is a cube on the screen and the ability to transform it locally as well as move the camera around it. The project is more of functionality with other aspects of the platform in that I'm going to create a bluetooth interface to change the various parameters (short form: I'm gonna make a bluetooth keyboard/joystick for the platform) and then incorporate other hardware aspects of the platform. Since it's also running OpenGL ES 2 and since this a more of a proof of concept thing, the idea is to have a 3d model as that which is manipulated (I could do text on a debug console, for example, but that's boring). I got excited because in days past I've used GL for this type of thing lots of times but they did the matrix and other math in the background for me. Given that this is the case, I just don't have time to do things like read the Red Book or go back and re-learn algebra, etc. This has all been done, I just need a concrete example (so please, I ask in kindness, if you cannot help me other than to suggest that I need a basic understanding of algebra, I understand this and yes, if I was going to be a graphics programmer, that's true, but that's not the case).

Thanks,

Matt M