how would one go about aligning 3d shapes onto a hidden grid?
what do you mean?
Positioning them in the world?
You can easily do that with glTranslatef in conjuction with glPushMatrix/glPopMatrix when rendering.
Well i need it too keep aligning it self and when there is already a 3d shape in the orginal location keep moving to the right till the end of row and then go down one colum and keep adding shapes till the end of the row
like an items list like this
Surely you have an internal array to represent each ‘slot’ in the inventory display.
You don’t need to detect the 3d shape because you know what’s in the internal array and thus know which slot is available. As the grid it a fixed size foe each cell moving an object to row x and column y is trivial.
you mean glvertex?
glbegin(GL_QUAD)
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glVertex3f(0.0,0.0,0.0);
glEnd();
Eh?
You don’t need any OpenGL to do this as you don’t need to detect anything.
Let me ask you a question. How do you know what’s in the inventory?
Are you going to crawl the glWindow and read back pixel data to attempt to figure out what’s there? Or, you would have an array of 3x3 or whatever to record what’s in the inventory? The latter I think.
So detecting an empty space in the inventory means looking at your internal array not issuing OpenGL commands.
i just want a hidden grid that knows when theres texture mapped vertex in a specific area then move the next textured mapped vertex to the right by about 5milimeter i have no inventory that picture was an example of what i wanted but not exactly what it is im doing
im using sdl for the opengl context and opengl for 3d rendering
I think you are completely missing the point.
Let’s say you have drawn a textured quad in your ‘intentory’. It that it. Are you going to ‘forget’ you have drawn it?
No, you will have set a flag somewhere in your code to say you have done so.
For the next inventory item, you will do the same. So eventually you will realise you’ll need an array of flags to represent each cell of the inventory. Working out whether you have an empty cell and where is as simple as navigating the array of flags - not reading back OpenGL window pixels, or navigating around your 3dmodel positions.