Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotate flat surface in 3D space

Started by Krum110487 Aug 14, 2012 at 4:02 PM 4 replies 3k views
Original Post
Krum110487
Krum110487
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.
dpadam450
dpadam450
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.
NBA2K, Madden, Maneater, Killing Floor, Sims 
haegarr
haegarr
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.
Krum110487
Krum110487
@dpadam450
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 smile.png

thanks for the information!
dpadam450
dpadam450
There are 2 matrices. Projection and Modelview. You set them up separately. glMatrixMode(). A modelview matrix does not have a projection matrix.
NBA2K, Madden, Maneater, Killing Floor, Sims 
Krum110487
Krum110487
That is good to know, Thanks!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.