Archived

This topic is now archived and is closed to further replies.

How to make an inventory-like menu...

This topic is 5083 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am trying to implement an inventory menu. I already have a GUI system going on. I am using a vertex structure like this one: typedef struct cTransVertex { // coords cVector3 Point; // texture coords cVector2 Tex; Float rhw; unsigned long color; } cTransVertex; It works fine to draw stuff in the screen... Well, in my inventory I want to be able to draw the items of the inventory in 3D, and if I select one of them, I want to be able to rotate it. This is where I know nothing of how to do this. Any ideas on how I would draw this 3D object in the screen? Thanks! George Faraj, FX Legends SPS, Honduras

Share this post


Link to post
Share on other sites
Yes, with directX, you could create a vertex & index buffer of your vertices and render that. You could also use the ID3DXMESH interface if you wanted to. There are a lot of options you can pick from.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I know how to render using vertex/index buffers. The problem I have is how to place those objects on the screen making them look like they''re in the surface of the screen.

Anyone?

Share this post


Link to post
Share on other sites
you can try the viewport thing. In opengl. That's how people do multiple camera rendering (split screen).

set the viewport to a portion of the screen, and render the object.


// something like : minx = 50, miny = 50, maxx = 100, maxy = 85

void Render3DItem(float minx, float miny, float max, float maxy)
{
//--------------------------------------------

// set viewport

//--------------------------------------------

glViewport(minx, miny, maxx-minx, maxy-miny);

//--------------------------------------------

// set projection matrix

//--------------------------------------------

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
...

//--------------------------------------------

// set modelview matrix

//--------------------------------------------

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
......

//--------------------------------------------

// Render 3D object

//--------------------------------------------

......

glFlush(); // not sure you need that though.

}


note that you don't really need the projection / modelview thing everytime, it's just as an example.

[edited by - oliii on January 7, 2004 8:35:53 PM]

[edited by - oliii on January 7, 2004 8:36:38 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
The problem I have is how to place those objects on the screen making them look like they''re in the surface of the screen.

you want to use an orthographic projection (this mean there is no perspective). this will allow you to just draw quads on the screen without them looking funny or 3Dish...

Share this post


Link to post
Share on other sites
But he wants 3D.

Set a viewport, and setup a camera. I don''t know how the z-buffer is handled though, but what you can try


glDepthTest(GL_ALWAYS);
glFrontFace(GL_CW);
glColor3f(0, 0, 0);
glutSolidCube(1000.0f);
glFrontFace(GL_CCW);
glDepthTest(GL_LESS_OR_EQUAL);
// draw 3D item

Share this post


Link to post
Share on other sites
Well hes not talkin about 2d. In opengl i believe that after you load the identity matrix the camera is facing down the Z axis. So in opengl, I render all my scene, load the identity, translate to the xy where i want my menu objects, and render them.

I know dx uses a 3rd matrix so you might have to set the identity in model and view, i dunno.


edit: Search for how to do a fps shooter, rendering the players arms and gun, its the same effect your looking for.

[edited by - honayboyz on January 11, 2004 3:50:53 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by honayboyz
Well hes not talkin about 2d. In opengl i believe that after you load the identity matrix the camera is facing down the Z axis. So in opengl, I render all my scene, load the identity, translate to the xy where i want my menu objects, and render them.

I know dx uses a 3rd matrix so you might have to set the identity in model and view, i dunno.


edit: Search for how to do a fps shooter, rendering the players arms and gun, its the same effect your looking for.

[edited by - honayboyz on January 11, 2004 3:50:53 PM]


Hmm, interesting.. Thanks for the suggestion. I will look for that.


edit: I've searched through gamedev.net and haven't found anything about rendering the player in a FPS game.. Do you know any article on that? Thanks.



[edited by - gfaraj on January 12, 2004 4:22:06 AM]

[edited by - gfaraj on January 12, 2004 4:23:03 AM]

Share this post


Link to post
Share on other sites
theres not much to do. change to ortho, use something thats independent of your resolution (so dont start using width and height, but values like 1000, that way 500 will always be the center of the screen and all your stuff will be scaled according to the resolution).
disable the z-test (and especially if your menu is transparent, render it after the rest of the scene) and just draw your inventory. either as one big texture to avoid ugly effects of rounding or as single parts (each slot could be a single quad).

i wouldnt worry about not using perspective projection for inventory items. they wont be big and there probably wont be much of a visual difference. even if it is, it might make it stand out which might even be a good thing. else you'll have to do a little math to find out on which vector your object should be to appear in a certain position (really not that hard, w=tan(fov/2) and h=w*aspect are the distance of frustum plane to your line of view at a distance of z=1.. with that its easy to convert between world and screen position).

of course im sure theres an even simpler way including a custom projection matrix ,-)

[edited by - Trienco on January 12, 2004 10:14:03 AM]

Share this post


Link to post
Share on other sites