How to use AutoGeometry

Official forum for the Chipmunk2D Physics Library.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to use AutoGeometry

Post by slembcke »

Oh shoot. That's right. There was an annoying rescale step in there that I wanted to fix in the next version... There is a thread where I answered exactly that question and I can't find it now.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to use AutoGeometry

Post by slembcke »

Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
csoul
Posts: 56
Joined: Mon Mar 25, 2013 11:57 pm
Contact:

Re: How to use AutoGeometry

Post by csoul »

Sorry, but I read through that whole thread and did not see an answer to the problem.

What I'm asking is this. I can create a convex shape like this:

Code: Select all

ChipmunkPolyline *hull = [[line simplifyCurves:1.0] toConvexHull:1.0];
self.shape = [hull asChipmunkPolyShapeWithBody:self.physicsBody offset:cpvneg(sprite.anchorPointInPoints)];
To create a shape that may have concave areas, I have to do this apparently

Code: Select all

ChipmunkPolylineSet *hull = [[line simplifyCurves:1.0] toConvexHulls_BETA:1.0];
self.shape = ________ ??
I need to know what goes in the blank. There is no asChipmunkPolyShapeWithBody method for ChipmunkPolylineSet.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to use AutoGeometry

Post by slembcke »

Did you see the github branch in the post with the screenshot? It implements exactly what you are looking for in the GeometryNode.m file. I posted a link specifically to the diff of those changes as well.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
csoul
Posts: 56
Joined: Mon Mar 25, 2013 11:57 pm
Contact:

Re: How to use AutoGeometry

Post by csoul »

Those links just lead to more frustration for me unfortunately. Going to send an email.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to use AutoGeometry

Post by slembcke »

Ok. So I made a brand new example that modifies the code from Gemeralds to do I think exactly what you are looking for:
https://github.com/slembcke/ConcaveSprite

It sets up the physics stuff in the CCSprite designated initializer so it basically "just works".

Code: Select all

	ConcaveSprite *sprite = [ConcaveSprite spriteWithFile:image];
	sprite.position = point;
	sprite.elasticity = 1.0;
	[self addChild:sprite];
	[_space add:sprite];
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
csoul
Posts: 56
Joined: Mon Mar 25, 2013 11:57 pm
Contact:

Re: How to use AutoGeometry

Post by csoul »

ConcaveSprite is working well, but how should I go about setting collisionType on an instance or subclass? Typically I would do this in the initializer:

self.shape.collisionType = [MyClass class];

But I'm not sure where that would fit in the ConcaveSprite workflow.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to use AutoGeometry

Post by slembcke »

Well, I threw that example together pretty quickly when you asked for it. The only property it exposed was elasticity and had a note in it about how to expose more of them.

I went ahead and added more of them though if you pull.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
csoul
Posts: 56
Joined: Mon Mar 25, 2013 11:57 pm
Contact:

Re: How to use AutoGeometry

Post by csoul »

Thanks, but I'm not seeing any new commits in the repo. The last commit I see is 0b3463c on 4/22.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: How to use AutoGeometry

Post by slembcke »

Hmm. It shows up on Github as of an hour ago: https://github.com/slembcke/ConcaveSprite
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 10 guests