[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - Joints Start

Joints Start

Official forum for the .

Joints Start

Postby Xcode » Sat Apr 24, 2010 11:21 am

Hey,

1- I have been googling a lot about joints but couldnt find much tutorials. Does anybody has any nice tutorial on joints and constraints.

2- i want to create a rod hanging from a nail. (Pendulum sort effect) and when rod is hit , i should vibrate. Which joint do i have to apply b/w the nail center and the rod upper point ( I guess it should be pivotJoint)

Thanks,
Xcode
 
Posts: 8
Joined: Sat Apr 24, 2010 9:30 am

Re: Joints Start

Postby Xcode » Sat Apr 24, 2010 11:29 am

Well i have created a pivot point using
cpSpaceAddConstraint(space, cpPivotJointNew2(hookBody,pendulumBody,cpv(0,0),cpv(0,48))); // hookBody is static and pendulumBody is the Rod

and pivot is created as expected. But when something hits rod it does not rotate so definitely i am not getting the pivot points concept correctly. Secondly pivot is only created if i define pendulumBody as

pendulumBody=cpBodyNew(10.0f,INFINITY);

and changing the INFINITY to any value breaks the pivot point.. i even tried using cpMomentForPoly() function but it doesnt help either. Please Help
Xcode
 
Posts: 8
Joined: Sat Apr 24, 2010 9:30 am

Re: Joints Start

Postby Xcode » Sat Apr 24, 2010 9:01 pm

Hey,,,i have fixed the pivot point ,,but now i have gotten into another issue,,,i will paste full code here

/* Create a body with inifite mass and moment,,i am not adding any shape for this body bcoz that mite collide with the pendulum rod */
cpBody *hookBody=cpBodyNew(INFINITY, INFINITY);
hookBody->p=cpv(100,330);

/* Create the pendulum rod */

cpVect pendulumVerts []={cpv(96,0),cpv(104,0),cpv(104,-96),cpv(96,-96)};
pendulumBody=cpBodyNew(10.0f,cpMomentForPoly(10.0f, 4, pendulumVerts, cpv(0,0)));
pendulumBody->p=cpv(100,330);
cpSpaceAddBody(space, pendulumBody);
cpShape * pendulumShape=cpPolyShapeNew(pendulumBody, 4 , pendulumVerts, cpv(-100,48));
pendulumShape->e=0.5;pendulumShape->u=3;pendulumShape->collision_type=45;
pendulumShape->data=pendulum;
cpSpaceAddShape(space, pendulumShape);
cpSpaceAddConstraint(space, cpPivotJointNew2(hookBody,pendulumBody,cpv(0,0),cpv(0,0)));

and thats all,,, Now i hit the rod with some other object ( ball in my case) but the rod does not rotate.,,, Infact the shape of rotating rod is not updated,,,i keep colliding the ball and it does show that the rod body (pendulumBody) is rotating but shape is not updated. Please help ,,,Thanx
Xcode
 
Posts: 8
Joined: Sat Apr 24, 2010 9:30 am

Re: Joints Start

Postby Xcode » Sat Apr 24, 2010 10:35 pm

hmmm...i guess i have to change something here in this line

if([shape->data isKindOfClass:[UIView class]]) {

[(UIView *)shape->data setCenter:CGPointMake(shape->body->p.x, 480-shape->body->p.y)]; //I guess i have to apply transformation to view here depending on body's angle;


}
Well lemme try that and i will post the result
Xcode
 
Posts: 8
Joined: Sat Apr 24, 2010 9:30 am

Re: Joints Start

Postby Xcode » Sat Apr 24, 2010 10:46 pm

Huhhh Yes that does it :)


So i have implemented my first joint successfully :) Thanks slembcke for chimpunk like great stuff :)
Xcode
 
Posts: 8
Joined: Sat Apr 24, 2010 9:30 am

Re: Joints Start

Postby Xcode » Sat Apr 24, 2010 11:10 pm

Lol now it wont stop rotating,,, is there any kind of joint friction stuff?

I can anticipate that since hookBody got no shape of its own (meaning no friction) , the pendulum body does not meet any frictional force to stop it...Am i right in saying that?
Xcode
 
Posts: 8
Joined: Sat Apr 24, 2010 9:30 am

Re: Joints Start

Postby mobilebros » Sun Apr 25, 2010 10:45 am

Wow.... I'm going to post this, but I fear by the time I do you might have already found the answer :) I don't think there is any easy way to apply some kind of rotational friction to a pivot without creating your own type of constraint... I could be wrong tho.
mobilebros
 
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am

Re: Joints Start

Postby slembcke » Sun Apr 25, 2010 12:10 pm

Actually there is an easy way to apply rotational friction. Use a cpSimplMotor with a target speed of 0 (the motor wants to stop any relative rotation) and set the maxForce of it to be the amount of friction that you want to apply.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Joints Start

Postby mobilebros » Sun Apr 25, 2010 1:56 pm

Thats awesome! Never would have thought to use the motor like that.
mobilebros
 
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron