


GL_MODELVIEW stack which should contain View*Model (or View*Model1*Model2.*ModelN),.Old OpenGL (2.x and earlier) required you to put the matrices on two "matrix stacks": Model and view matrices usually contain translation, rotation and/or scaling, while projection matrix usually contains a perspective transformation, which makes the objects further from the screen appear smaller. Then you transform the coordinates to eye space by multiplying by a view matrix (usually connected to a "camera" object).Īfter that, using a projection matrix you transform those coords to the screen space, so that OpenGL would map these coords to actual screen pixels (depending on the viewport setting). If you have a scene hierarchy, there can be many "stacked" model matrices for an object (placement of the sword relative to an arm, arm relative to a knight, knight relative to the scene). You transform coordinates from model space to scene space by multiplying (in OpenGL conventions usually left-multiplying) by a model matrix (which contains the information on where the model is on the scene). Screen space (= window coordinates) is the same as above, except that the coordinates are rescaled from -1.1 to pixel-based values matching the range of the current viewport and depth range. Scene space (= world space) is the coordinate space relative to an arbitrary point of your sceneĮye space (= view space) is the space where the camera is at point (0,0,0), x faces right, y faces up and z faces out of the screen ( -z = deeper)Ĭlip space is where (-1,-1,*) is the bottom left corner of the viewport, (1,1,*) is the top right corner of the viewport, and the Z coordinate in (-1,1) indicates just the depth (again smaller Z = deeper). it's geometrical center, its base, anything actually). If you have a file with a model, the coordinates are centered around some point of it (e.g. Model space (= local space) is the coordinate space of a specific model, relative to its "center". This is mostly a matter of convention, but: glPushMatrix() Īlso what are the differences between the different coordinate spaces e.g.
Opengl coords how to#
I've got some code below it's a circle in the middle of a square, how would i detect when the circle touches one of the edges, i can move it round using the up,down,left, right keys it just changes the x or y coordinates, but i just want to be able to do some basic collision detection and I don't know how to do it. Also what are the differences between the different coordinate spaces e.g. I think I might have to use gluProject but not sure. triangle) after it's been translated and rotated, the reason i want to do this is so that later i can do collision detection and calculate the distance between objects using the coordinates. I want to be able to get the coordinates of an object (e.g.
