Box2D Forums

It is currently Wed May 22, 2013 5:05 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Mon Aug 18, 2008 11:33 am 
Offline

Joined: Sat Jun 07, 2008 11:10 am
Posts: 65
A great game and a great article to go with it. Very informative. I hope you don't mind, but I added a link to your article to the 'List of useful articles' Wiki:

http://www.box2d.org/wiki/index.php?title=List_of_useful_articles


Top
 Profile  
 
PostPosted: Tue Aug 19, 2008 5:03 am 
Offline

Joined: Sat Aug 02, 2008 11:37 am
Posts: 7
@Maroxe

if you have the collission manifold, all you do is:
var normal:b2Vec2 = manifold.normal;
var angle:Number = ( Math.asin ( normal.x / normal.Length () ) / Math.PI * 180);

(Note: this is Actionscript 3 using box2d 1.4)

@Boris: thanks, yes it is a shame, perhaps in a future release of the game I'll try to fix this. I'm a bit short on time atm.

@Pault: No I don't mind at all. Thanks for linking.


Top
 Profile  
 
PostPosted: Tue Aug 19, 2008 7:23 am 
Offline

Joined: Thu Jul 17, 2008 11:24 am
Posts: 54
thanks huesforalice, but before i read your answer, i proced like that(in c++):
Code:
b2Vec2 n = point->normal;//normal vector
b2Vec2 v(0, 1);   //up vector
float cosAngle = (v.x*n.x+v.y*n.y) / (v.Length() * n.Length());
angle = acosf(cosAngle);


Top
 Profile  
 
PostPosted: Tue Aug 19, 2008 7:43 am 
Offline

Joined: Fri May 16, 2008 10:09 am
Posts: 337
Can't you just take the contact normal and extract the angle from it? The normal points from shape1 to shape2. Just do atan2(normal.y,normal.x).

For multiple contacts i suppose you can just average the angle (average the normals then take angle).


Top
 Profile  
 
PostPosted: Wed Aug 20, 2008 4:09 pm 
Offline

Joined: Thu Jul 17, 2008 11:24 am
Posts: 54
huesforalice wrote:
@Boris: I'd have to check the code again, but I'm pretty sure that I'm only setting the velocity. I also aply a counterforce to gravity as long as he is not moving and touching the ground, so that he doesn't slip down the slopes. About your bug report, the angle that tinger stands in is defined by the normalvector of his collission with ground. So if he stands on the edge of a collissionbox, he'll stand at an angle. I don't really consider this to be a serious bug, but thanks for pointing it out!

i had the same problem, the solution is to update the angle when collision persist, not when it's added(in C++ do it in ContactListener::Persist() not ContactListener::Add() )


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group