Sign in to follow this  
lucky7456969

Object Attachment

Recommended Posts

lucky7456969    122
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

Share this post


Link to post
Share on other sites
Tibre    175
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.

Share this post


Link to post
Share on other sites
squicklid    132
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.

Share this post


Link to post
Share on other sites
nmi    978
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).

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