Numbering Polygons...

Started by
3 comments, last by bzroom 17 years, 6 months ago
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.
Member of the NeHe team.
Advertisement
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.
___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!
As a side note, DX10 will know this internally.

http://www.gamedev.net/community/forums/mod/journal/journal.asp?jn=316777&reply_id=2521733
Every time you implement a singleton, God kills a kitten. Please, think of the kittens!
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:)
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.

This topic is closed to new replies.

Advertisement