[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/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/bbcode.php on line 112: 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 112: 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 112: 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 112: 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 - [Solved]ChipmunkPro - Sync Sprites with Joints

[Solved]ChipmunkPro - Sync Sprites with Joints

Official forum for the .

[Solved]ChipmunkPro - Sync Sprites with Joints

Postby Nexus2911 » Mon Feb 27, 2012 1:39 pm

Attachments
truck.png
truck.png (11.38 KiB) Viewed 5005 times
Last edited by Nexus2911 on Sun Jun 10, 2012 4:28 pm, edited 1 time in total.
Nexus2911
 
Posts: 65
Joined: Wed Feb 15, 2012 12:28 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby slembcke » Mon Feb 27, 2012 3:05 pm

If you are using groove joints, there is no rotation though is there? Just translation along the groove.

You can get the anchor points from most joints using anchr1/anchr2, then convert those to world coordinates using the local2World: method on bodies. ex: cpVect anchrPos = [joint.bodyA local2World:joint.anchr1]

In this case it looks like you could just fix the sprite for the top part of the shock to the chassis (make it a sub sprite), and sync the bottom part to the wheel's center (change the anchor point of the sprite and it becomes trivial). Set the bottom shock's angle to match the chassis.
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: ChipmunkPro - Sync Sprites with Joints

Postby Nexus2911 » Mon Feb 27, 2012 4:58 pm

Nexus2911
 
Posts: 65
Joined: Wed Feb 15, 2012 12:28 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby jcmeyer5 » Sun Mar 04, 2012 11:45 am

I may be way out in left field, but couldn't you constrain the top of the piston to the top of the sleeve, and the bottom of the piston to the bottom of the sleeve? And then also anchor the top of the sleeve to the chassis, and the bottom of the piston to the wheel? If it retains the shortest distances between each point, then they should always be in line. I wouldn't try to link them to the constraints that are actually controlling the suspension... since this is a visual issue only, they need just enough constraint to keep them in line.

My 5th post... I might be crazy. :)
Chipmunk Pro and cocos2D 2.x branch for iOS development
jcmeyer5
 
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby slembcke » Sun Mar 04, 2012 1:23 pm

Oh, I totally missed this post. :-\

ChipmunkCocosBody isn't part of Chipmunk Pro, it's just a utility class I made to help it work better with Cocos2D. I've actually modified it slightly for the current project that I'm working on to provide both a list of synced nodes, and a list of position only nodes. It was really just a bit of copy pasting.
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: ChipmunkPro - Sync Sprites with Joints

Postby Nexus2911 » Sun Mar 04, 2012 5:51 pm

Actually, the shock absorbers are upside down.

The shock pistons and chassis are now one image - so now I only have to be concerned with syncing the shock sleeve with the compression of the spring or the X and Y position of the center of the wheel.

In fact, the sleeve doesn't really need to be a physics node, although it my be nice for it to be part of the physics in case I have the truck parts interact with other nodes.
Nexus2911
 
Posts: 65
Joined: Wed Feb 15, 2012 12:28 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby jcmeyer5 » Mon Mar 05, 2012 5:44 pm

Chipmunk Pro and cocos2D 2.x branch for iOS development
jcmeyer5
 
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby jcmeyer5 » Mon Mar 05, 2012 6:35 pm

I see it now. You are using coordinates from the file to select a space in the file. Okay. so you are explicitly assigning them to shapes. I got it now. So the syncNode is to update the sprite positions only... not to associate them with shapes.

Awesome.
Chipmunk Pro and cocos2D 2.x branch for iOS development
jcmeyer5
 
Posts: 89
Joined: Thu Dec 15, 2011 9:18 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby Nexus2911 » Sun Jun 10, 2012 12:41 pm

Last edited by Nexus2911 on Sun Jun 10, 2012 1:14 pm, edited 1 time in total.
Nexus2911
 
Posts: 65
Joined: Wed Feb 15, 2012 12:28 am

Re: ChipmunkPro - Sync Sprites with Joints

Postby slembcke » Sun Jun 10, 2012 1:06 pm

Oooh. Took me a minute to figure out what you were asking. Fortunately I made an example just a day or two ago that explains what you want to do: https://github.com/slembcke/SpacePatrol ... ggy.m#L299

It's using the Cocos2D 2.0 beta, but you should get the idea.

This is the best way that I know how to do this as it ensures that the graphics for a complex mechanical system always look correct without requiring that the underlying physical model be complex. It does require you to manually sync the sprites though and to understand how exactly to do it. Alternatively, you could make a CCSprite subclass that references the wheel and chassis bodies and schedules it's own update method. That seems like it would be more work to me though.
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

Next

Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 0 guests

cron