Gamestudio Links
Zorro Links
Newest Posts
Respect History setting for Z systems
by AndrewAMD. 10/02/26 15:43
Purchase A8 full licence version
by ukgamer. 10/02/26 01:31
A3 projects
by Yopachi. 09/28/26 17:04
Parent/child object
by rayp. 09/27/26 14:43
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
4 registered members (KRT, julienp, Ayumi, 3run), 7,815 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
julienp, julienper, KelleyAbbey, Yopachi, Knull
19245 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to attach a weapon to my 3d person model? #188339
03/14/08 00:56
03/14/08 00:56
Joined: Mar 2008
Posts: 7
R
Regrin Offline OP
Newbie
Regrin  Offline OP
Newbie
R

Joined: Mar 2008
Posts: 7
I have a full animated model in .MDL format (walk, run, attack, death, ...) without any wepaon in his hands. I have too lots of weapon models like swords, axes, maces... I know how to create new model entities and animate them with Lite-C but I have no idea for how to attach all those non-animated weapons into my model's hands. Does anybody have any hint or idea of how to do this?

Re: how to attach a weapon to my 3d person model? [Re: Regrin] #188340
03/14/08 03:50
03/14/08 03:50
Joined: Oct 2003
Posts: 702
Z
zazang Offline
User
zazang  Offline
User
Z

Joined: Oct 2003
Posts: 702
Hi

Here is a sample code for this :-

Code:
  
//v_little = vertex number of little finger
//v_index = vertex number of index finger
//--------------------------------------------------
function vertex_attach_weapon(v_little,v_index)
{
var vec_little;
var vec_index;
var vec_dir;

//calculate world vectors of the 2 points
vec_for_vertex(vec_little,player_ent,v_little);
vec_for_vertex(vec_index,player_ent,v_index);

//calculate direction vector between the 2 points
vec_diff(vec_dir,vec_index,vec_little);

//calculate angle of the hand vector
vec_to_angle(temp,vec_dir);
temp.roll = 0;

//orient weapon to that angle
vec_set(my.pan,nullvector);
ang_add(my.pan,temp.pan);

//position weapon to half length within grasp
vec_scale(vec_dir,0.5);
my.x = vec_little.x + vec_dir.x;
my.y = vec_little.y + vec_dir.y;
my.z = vec_little.z + vec_dir.z;
}
//-----



You have to call it in the weapons code every frame.
Hope it helps.

zazang


I like good 'views' because they have no 'strings' attached..
Re: how to attach a weapon to my 3d person model? [Re: zazang] #188341
03/14/08 06:19
03/14/08 06:19
Joined: Mar 2008
Posts: 7
R
Regrin Offline OP
Newbie
Regrin  Offline OP
Newbie
R

Joined: Mar 2008
Posts: 7
Wuooooah!

Tested and working. thank you very very much! You saved my life.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1