Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (AndrewAMD, TipmyPip, NewbieZorro, Grant), 14,196 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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