Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 10/15/25 20:44
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (TipmyPip, AndrewAMD), 7,000 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
rotation through 3 vertexes problem( Gimbal Lock?) #392852
01/28/12 19:15
01/28/12 19:15
Joined: Sep 2007
Posts: 101
Luxembourg
K
krial057 Offline OP
Member
krial057  Offline OP
Member
K

Joined: Sep 2007
Posts: 101
Luxembourg
Hey,
I tried to implement a new feature into my patheditor. It should give the possibilty to "export" paths from modeling programs into gamestudio. The idea is the following:
- In the modeling software render a path with triangles:
http://dl.dropbox.com/u/6859456/3dgs/Bild_2.bmp
- Load it in gamestudio and run my script:
Php Code:
for(int i;i<vertexcount;i+=3)
{
	you=nodeCreate();
	vec_set(you.x,	vec_for_vertex(ver1,ent,i+2));
	vec_for_vertex(ver3,ent,i);	
	vec_for_vertex(ver1,ent,i+1);
	vec_for_vertex(ver2,ent,i+2);
	vec_set(tmpVec,ver1.x);	
	vec_add(tmpVec,ver2.x);
	vec_scale(tmpVec,0.5);
	
	vec_set(panDir,ver1.x);
	vec_sub(panDir,ver2.x);
	
	vec_to_angle(tmpAng,panDir);
	you.pan=tmpAng.pan;
	you.tilt=tmpAng.tilt;
	
	vec_sub(tmpVec,ver3);
	vec_cross(panDir,panDir,tmpVec);
	vec_to_angle(tmpAng,panDir);
	you.roll=tmpAng.tilt;
} 




Everything works fine, but when the tilt value comes nearer to -90, the pan value plays crazy(it gets from 180 to 0) and the tilt value goes back instead of continuing (so it is in inverse roation). It is difficult to explain, but I think this guy here had the same problem:
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=166452

regards Alain


Last edited by krial057; 01/29/12 12:42.
Re: rotation through 3 vertexes problem( Gimbal Lock?) [Re: krial057] #392854
01/28/12 21:09
01/28/12 21:09
Joined: Dec 2008
Posts: 1,218
Germany
Rackscha Offline
Serious User
Rackscha  Offline
Serious User

Joined: Dec 2008
Posts: 1,218
Germany
Iam not shure about it, but maybe you do not handle the roll value correctly?

For example why do you use

you.rool = tmpAng.tilt


int the last line?

PS: iam totally bad at this rotation stuff, when it comes to reading it grin

Last edited by Rackscha; 01/28/12 21:09.

MY Website with news of my projects:
(for example my current
Muliplayer Bomberman,
GenesisPrecompiler for LiteC
and TileMaster, an easy to use Tile editor)
Sparetime-Development

Re: rotation through 3 vertexes problem( Gimbal Lock?) [Re: Rackscha] #392896
01/29/12 12:41
01/29/12 12:41
Joined: Sep 2007
Posts: 101
Luxembourg
K
krial057 Offline OP
Member
krial057  Offline OP
Member
K

Joined: Sep 2007
Posts: 101
Luxembourg
It's difficult to explain my idea to rotate it... Here is a picture of a triangle with the vectors:


before the second vec_to_angle, panDir gets crossed (the violet vector). Because of this, the roll and tilt values somehow get "switched". Further more, the vec_to_angle function does not modify the roll value. I'm not the best at rotation stuff too, but this was the only way I got it tow work... I believe there is a better way to do this.


Last edited by krial057; 01/29/12 12:43.

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