Sign in to follow this  
Kazade

Numbering Polygons...

Recommended Posts

Hey, In my 3D map editor I have a list of objects, each object contains a list of polygons. Each object has a unique ID which is just the order in which they are created (e.g. Object 1's ID is 0, Object 2's is 1 etc.) Now I want to give every polygon a unique ID as an integer, which somehow stores its parent objects ID within it, but remains unique among all polygons. For example: Object 1 has an ID of 0 and has 6 polygons indexed in the list from 0-5. Basically I want to give an ID to polygon 3 that will allow me to know: 1. The index of the polygon in the list (3) 2. The ID of the parent polygon (0) Is this possible? Any ideas? Cheers Luke.

Share this post


Link to post
Share on other sites

union PolyID
{
int id;
struct
{
short parent;
short poly;
};
};


This only allows 65536 objects each with a max of 65536 polygons. And is not very portable. And is probably just generally a bad idea.

An alternitave would be to give each polygon a unique id, to make use of the fact that some objects have more polygons than others. Then just associate each object with a range of poly id's. Giving you a max of 2^32 polys.

I really don't see why you need it.

Share this post


Link to post
Share on other sites
Instead of your setting you could have the vertices in a separate list. Then for the polygons you have an index list. The first three indices constitute the first polygon the next three the second and so forth. That way you save space, just a suggestion:)

Share this post


Link to post
Share on other sites
If this is for picking in OGL, you can push multiple values onto the name stack.

for instance:

glPushName(objectid)

for each face
glPushName(faceid)
drawface
glPopName()

glPopName()

Then when you pick that object all the name's you pushed will be returned as an array.

If I remember correctly haha. As said above, I assume DX will do the same.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this