Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (Ayumi), 662 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Help with the roll angle #287873
09/02/09 23:01
09/02/09 23:01
Joined: Mar 2008
Posts: 7
R
Regrin Offline OP
Newbie
Regrin  Offline OP
Newbie
R

Joined: Mar 2008
Posts: 7
I have an animated model of a warrior and a static model of a helmet, and now I'm working on a function to recalculate the position and angles of the helmet every frame. I found only this code:

function addons(ENTITY* entity1, var v1, var v2, var v3)
{
VECTOR hand_pos;
VECTOR hand_pos2;
VECTOR hand_pos3;
VECTOR hand_pos4;
VECTOR vec1;
VECTOR vec2;
VECTOR temp;

vec_for_vertex(entity1.x, Player1,v1); //vertex to place origin at
vec_for_vertex(hand_pos, Player1, v2); //vert to orient pan and tilt
vec_for_vertex(hand_pos2, Player1, v1);
vec_for_vertex(hand_pos3, Player1, v3); //vert to orient roll
vec_for_vertex(hand_pos4, Player1, v2);

vec_sub(hand_pos, entity1.x); //sets our pan and tilt
vec_to_angle(entity1.pan, hand_pos);
entity1.roll = 0;

//all this does the roll, courtesy of Gnometech
vec_sub(hand_pos3, hand_pos4);
vec_set(vec1, nullvector);
vec1.y = 1;
vec_rotate(vec1, entity1.pan);
vec_set(vec2, nullvector);
vec2.z = 1;
vec_rotate(vec2, entity1.pan);
temp.x = vec_dot(vec1, hand_pos4);
temp.y = vec_dot(vec2, hand_pos3);
temp.z = 0;
vec_to_angle(entity1.roll, temp);
}


Angles pan and tilt are working fine so far, but roll isn't right calculated. This problem is getting me mad and I can't find another solution. Can somebody help me??

Thanks!

Re: Help with the roll angle [Re: Regrin] #287917
09/03/09 08:33
09/03/09 08:33
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
There's an attach code in wiki and in AUM resource.
You could always search there...

Re: Help with the roll angle [Re: bart_the_13th] #287923
09/03/09 09:27
09/03/09 09:27
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
It should work. Do you give to the function 3 vertexes? They should positioned like a "L"

Re: Help with the roll angle [Re: Widi] #288023
09/03/09 17:10
09/03/09 17:10
Joined: Sep 2003
Posts: 208
Michael_McCrickard Offline
Member
Michael_McCrickard  Offline
Member

Joined: Sep 2003
Posts: 208
Yeah, the three vertices you pick on your parent model are important. They should form an "L" shape as Widi mentioned. If they are in a straight line (or close to it), then the roll part goes all crazy.


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

Gamestudio download | chip programmers | 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