www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: Minigame on November 21, 2012, 09:46:36 pm

Title: Noobest Question Ever?
Post by: Minigame on November 21, 2012, 09:46:36 pm
What is the best approach for adding a weapon to a player's hand? Or attaching items such as hats, etc. I've never tried this, and I'm very unsure of where to start. I would need to animate it with the parent model as well.
Title: Re: Noobest Question Ever?
Post by: KittenKoder on November 21, 2012, 10:13:15 pm
If the weapon is only used for the same model, or all the animations for the models using it are the same, you could just animate the model and then parent it, matching the animation of the parent to the weapon. That's the old school method, and it tends to work in most situations. However, if that won't work then you'll have to actually find out where to position the weapon a complex way.

The complex method is to locate the polygon of the model you want the weapon to follow, then using the polygon manager of the object update the weapon to match that polygon's position from the rest of the model, and move the weapon to match. The problem with this method is you have to know the index of the polygon you are going to follow.

If you are using skeletal animations I believe there is a much easier method, but I have no experience with such.
Title: Re: Noobest Question Ever?
Post by: Minigame on November 29, 2012, 10:51:01 am
If the weapon is only used for the same model, or all the animations for the models using it are the same, you could just animate the model and then parent it, matching the animation of the parent to the weapon. That's the old school method, and it tends to work in most situations. However, if that won't work then you'll have to actually find out where to position the weapon a complex way.

The complex method is to locate the polygon of the model you want the weapon to follow, then using the polygon manager of the object update the weapon to match that polygon's position from the rest of the model, and move the weapon to match. The problem with this method is you have to know the index of the polygon you are going to follow.

If you are using skeletal animations I believe there is a much easier method, but I have no experience with such.

Thanks for taking the time to reply, the old school method worked perfectly..