• Create Account

## Rotate flat surface in 3D space

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

5 replies to this topic

### #1Krum110487  Members

110
Like
0Likes
Like

Posted 14 August 2012 - 10:02 AM

Ok, I am new to OpenGL and I am having a bit of trouble:

currently I am rotating a texture by using glRotate on the vertex's

GL.Rotate(45, 1.0, 0.0, 0.0);
GL.Begin(BeginMode.Polygon);
GL.TexCoord2(0, 0);
GL.Vertex2(ULx, ULy);
GL.TexCoord2(1, 0);
GL.Vertex2(URx, URy);
GL.TexCoord2(1, 1);
GL.Vertex2(BRx, BRy);
GL.TexCoord2(0, 1);
GL.Vertex2(BLx, BLy);
GL.End();


This works fine, but since it is just a 2d matrix operation all of the rotations are pretty much squashing the texture (it doesn't look like the far side is far away), in the example, I would expect the top to have a smaller width than the bottom width, because it is visible but further away.

this isn't the case, and I understand why (I've taken Linear Algebra :-P)

I am looking to create a 3D FLAT object, would it be a cube where one side is 0 width?
and I want to rotate it in 3D space where the perspective is correct.

I don't really know how to accomplish this yet, most of the code I find makes 3D cubes (although I am having trouble placing my texture on it).

Any help is appreciated.

thanks.

Edited by Krum110487, 14 August 2012 - 10:07 AM.

2042
Like
1Likes
Like

Posted 14 August 2012 - 12:45 PM

No idea what you are talking about. What is a flat 3D object? a 2d object...?... a 3d plane?
Using 2D instead of 3D in your gl calls means you dont get perspective, and your objects are 2d.

### #3haegarr  Members

7188
Like
1Likes
Like

Posted 14 August 2012 - 01:11 PM

If you use glVertex2(x,y) then it is equivalent to the use of glVertex3(x,y,0) what is itself equivalent to glVertex(x,y,0,1). It has no effect on the dimensionality of the space or what. Whether or not perspective can be seen is a question of the projection matrix. E.g. using glOrtho defines an orthogonal projection, while glFrustum defines a perspective projection. There are perhaps some utility functions for projection, too.

### #4Krum110487  Members

110
Like
0Likes
Like

Posted 14 August 2012 - 01:38 PM

Sorry, I am still getting used to the terminology, by flat 3d object I mean a 3d plane.

since I have posted I just realized the I was using projection (not that it matters, since what I want is perspective, and even in model view it had none).

@haegarr, you have pretty much told me what I needed to know, I am still getting used to this, I will dig around in Frustrum and such for a while see what I figure out.

I also just got a handle on units (sort of), I think you will see less and less of me as things finally click

thanks for the information!

2042
Like
1Likes
Like

Posted 14 August 2012 - 04:49 PM

There are 2 matrices. Projection and Modelview. You set them up separately. glMatrixMode(). A modelview matrix does not have a projection matrix.

### #6Krum110487  Members

110
Like
0Likes
Like

Posted 14 August 2012 - 06:56 PM

That is good to know, Thanks!

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.