First question was orignally asked in comp.programming with no response.
Second question was orignally asked in comp.lang.c++ with no response.
I'm trying here, these questions, if you read them, are closely related.
If
someone knows a better way to do what I want I'm willing to listen.
I am working on a model animator, and currently I am working on
identifying
which triangles are in which body part.
Body parts would be like:
Body (all), Torso, right leg, right upper leg, right lower leg, right foot
foot, left leg, left upper leg, left lower leg, left foot, head, right
arm,
right bicept, right forearm, right hand, right thumb, right pointer,
etc...
So if I wanted the right leg, I would want all points in the leg (upper,
lower, foot). Same with arm (bicept, forearm, hand, fingers), etc...
I'm trying to decide on a good model for this, and also the complication
may
come in that some models may have more than 2 legs (animal) but no arm,
etc...
I'm thinking iterators would be the way to go, with usage something like:
Model.bodyparts[leg].begin()
or
Model.bodyparts.leg.begin()
or soemthing, however could be implemented best in whatever solution is
found.
Anyone have any thoughts on this? It seems almost like a tree structure,
except that some branches of the tree would return some other branches as
well. I could think of a vector of set for one part, but how to store
them.
Maybe a class or something that parts could be added to a map
class BodyParts
{
std::map<std::string, std::set> Triangles;
}
where usage could be something like (ignoring encapsulation of now)
BodyParts.Triangles["right leg"].second.begin()
but then how to link them?
Any thoughts?
====================
I am working on a class design to contain the indices of triangle lists
for
body parts. This is for 3d modeling. As as start I have:
class PartTriangles
{
public:
PartTriangels( const std::string& Name ): Name( Name ) {}
private:
std::string Name;
std::set<size_t> Triangles;
std::vector<PartTriangles> Connections;
};
which may (probably will) change and a lot of things added. Anyway... the
reason I am designing this class is I need to keep a list of the indices
for
a model for each body part so I can animate them, meaning I need to get
some
type of list of what triangles are in, for instance, the right leg. My
thought was that this ... three type list... would start with the torso
"torso". Whoulc would have in it's vector 5 connections, head, right
bicept, left bicept, right upper leg, left upper leg. So in this way
every
triangle would be list listed somewhere to contain the entire body, but
only
once. Now, the situation is, I need to be able to get a list of things
that
are in, say, the right leg, which would contain the upper leg, lower leg
and
foot. So interators came to mind. So this is what I am planning on
developing:
someinteratortype it = MyBody("right upper leg");
It should be fairly easy for PartTriangles to return an iterator pointing
to
it's std::set for the beginning of the upper leg. However, it would not
actually be in the instance of MyBody, which would have the set for Torso,
but in MyBody's vector of PartTriangles where the name is "right upper
leg".
Also is the complication of .end() There are 5 end()'s, one for head, one
for right hand pinky (if I go as far as fingers), left hand pinkie, right
foot, etc..
In addition, looking at an implementation of a custom iterator, it's
increment is simply:
custom_iterator& operator++()
{
// preincrement
++m_Ptr;
return (*this);
}
custom_iterator operator++(int)
{
// postincrement
custom_iterator _Tmp = *this;
++*this;
return (_Tmp);
}
m_Ptr is
_Ty *m_Ptr;
in a template.
It seems to me that my iterator would have to store more information than
a
single pointer especially for increment. Consider the case where I am
iteratiing over the right upper leg and get to the end of PartTriangle's
set, I would then want an increment to step into Connection's into it's
entries sets, etc... Of course, after it went through the first set, it
may
have to back out to do the next part of the vector, looking like I have
some
type of recursion taking place.
Anyone have familiarity with these types of iterators, or am I trying to
make an iterator do something it's not designed for?
I'm open to any and all suggestions.


|