Object Attachment

Started by
5 comments, last by lucky7456969 19 years, 6 months ago
For instance, when a player picks up a weapon, how do you attach the two objects (man and gun, or grouping in other sense) and move them together as one. (Using DX9c) Thanks Jack
Advertisement
One idea is to use a Scene Graph. The general idea is that you have a tree structure. Underneath a node are all of the items that that node is holding/containing/supporting/attached to, etc... The root node represents a general point in the world, that any unattached objects would come off of.

In your example, you would start off with two children coming off of the root node, a man, and a gun. If either moves, rotates, or changes in other ways, it only affects itself. To attach the gun to the man, you would move the gun node underneath the man node. From now on, whenever the man moves or rotates, it tells all of it's children (in this case the gun), that it needs to move or rotate also, based off of where the man is. There are a complete different ways to actually implement this or use this, but I believe that that is the general principle.

I don't think there are any native structures or anything in DX9x that implement this, I'm pretty sure it's something the programmer implements themselves. I'm not an expert on Scene Graphs, so hopefully somebody else will come along and provide a more detailed description if you want it.

You may also found this topic more fitting under graphics programming, since I'm not sure if there are any DirectX specific issues with how you would handle this.
You could also have every person have a list of objects.

struct Object{    int type;};struct Gun : public object{    int ammo;    //etc};class Being{private:    List<object> objects;};


I dont really know too much about inheritance, but I think that will work.
Quote:Original post by Tibre
I don't think there are any native structures or anything in DX9x that implement this, I'm pretty sure it's something the programmer implements themselves. I'm not an expert on Scene Graphs, so hopefully somebody else will come along and provide a more detailed description if you want it.


Implementing scene graphs is just as easy as multiplying two matrices.
Since matrices are used to transform one coordinate system to another (e.g. local to world), they can be concatenated by multiplication to go through different coordinate systems (e.g. hand to man, then man to world).
just combine the weapon's matrix with the chrachter's hand martix together...

Game Programming is the process of converting dead pictures to live ones .
Some source code?
Thanks
Jack
How about alignment? How do you specify the gun is on top of the palm or being gripped by the palm? Any clue?
Thanks
Jack

This topic is closed to new replies.

Advertisement