Go Back   AC3D Forums > Technical > AC3D Developers
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 15th June 2005, 04:30 AM   #1
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default Getting vertex index

Hiya!

Is there an easy way to get/display the index of a selected vertex?

By index I mean what I'd get if I'd do something like

Code:
Vertex* selVertex = getSelectedVertex();
if (selVertex!=NULL)
{
  ACObject* ob = getObjectThatOwnsVertex(selVertex);
  int index=0;
  List * vertices = ac_object_get_vertexlist(ob);
  for (List *vp = vertices; vp != NULL; vp = vp->next;++index)
  {
    if (vp == selVertex)
      break;
  }

  // Should always be true, else something 
  // is wrong in getObjectThatOwnsVertex
  if (vp!=NULL) 
  {
    // index holds the "vertex index"
    display(index);
  }
}
Is there some nifty tcl hack that can accomplish this?

Or would I have to write a complete plugin?
If so, would getObjectThatOwnsVertex actually require traversing every object and their vertices until a match is found or is there some more efficient way?


Thanks
__________________
/Per

www.perfnurt.se
PerFnurt is offline   Reply With Quote
Old 15th June 2005, 05:08 AM   #2
Andy
Administrator
Professional user
 
Andy's Avatar
 
Join Date: Jun 2003
Posts: 4,381
Default

Code:
Prototype ACObject *object_of_vertex(Vertex *pt);
will give the object that owns the vertex.

Vertices are stored in a linked list but do actually have an index property but it it not maintained. This means that you must call one function before you can then read them back. AFAIK this is internal at the moment but should work if you add the prototypes to the plugin header.

This is used to speed things up internally sometimes. e.g. file exporters.
call this:

Code:
Prototype int ac_object_vertexlist_set_indexes(ACObject *ob)
Then immediately after, you can call this to find what position in the list a vertex lies.

Code:
Prototype int ac_vertex_get_index(Vertex *v)
Note that any changes to the vertex list WILL affect these indexes and you will need to call the set indexes function again.

Andy
Andy is offline   Reply With Quote
Old 15th June 2005, 05:21 AM   #3
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default

Great, thanks!
__________________
/Per

www.perfnurt.se
PerFnurt is offline   Reply With Quote
Old 15th June 2005, 02:21 PM   #4
PerFnurt
Member
Expert member
 
Join Date: Aug 2003
Location: Eslöv, Sweden
Posts: 93
Default

Works like a charm.

Btw, all mentioned functions are already present in the header.

Thanks
__________________
/Per

www.perfnurt.se
PerFnurt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -4. The time now is 01:42 PM.


AC3D Forum
(C) Inivis Limited 2020