Chipmunk questions - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Game Programming Fundamentals (/forum-7.html)
+--- Thread: Chipmunk questions (/thread-8057.html)
RE: Chipmunk questions - Skorche - Sep 5, 2010 02:23 PM
Having a moment of inertia of zero is very bad, that might be part of your problem. Either make it be INFINITY if you don't want it to rotate at all, or use the cpMomentForCircle() function to help estimate the moment of inertia.
RE: Chipmunk questions - Miglu - Sep 5, 2010 02:49 PM
Thanks. Putting it to infinity solved the problem.
Why did you name the library Chipmunk? There is a hill outside of Stanford University's campus, which the university owns, that has a long walking route. There is a massive chipmunk density, and I saw one about every 10 meters along the road. I also saw two hawks, which are surely living the good life.
RE: Chipmunk questions - Skorche - Sep 5, 2010 05:15 PM
Because my previous (and not very good) physics library was named Squirrel Physics Kit. Chipmunk was the next logical step.
RE: Chipmunk questions - Miglu - Sep 6, 2010 04:26 AM
The collisions work now, although they are completely inelastic. I added a static segment to the window's left edge. However, it is not rigid, so that the body sinks into it. What is the problem?
RE: Chipmunk questions - Skorche - Sep 6, 2010 08:04 AM
Static shapes must be attached to infinite mass objects, otherwise the collisions will cause them to pick up velocity.
Read the section on static shapes in the docs: http://files.slembcke.net/chipmunk/release/ChipmunkLatest-Docs/#cpSpace
RE: Chipmunk questions - Miglu - Sep 6, 2010 08:13 AM
Thanks. However, is the default elasticity value 0? I can not find any method to change it.
RE: Chipmunk questions - Skorche - Sep 7, 2010 06:08 AM
cpShape.e is the elasticity value. It seems I never wrote getter/setter functions for those. You'd think I would have noticed that when rewriting the docs. Originally Chipmunk never even had getters or setters unless they were really needed for something. All the structs were really just full of public members.
Anyway, have you read the docs? http://files.slembcke.net/chipmunk/release/ChipmunkLatest-Docs/
RE: Chipmunk questions - Miglu - Sep 7, 2010 09:35 AM
I have read most of the docs. Are you going to add elasticity getset methods next time that you update Chipmunk?
Is the reason that the collisions are completely inelastic that cpBodyResetForces is called every time before cpBodyApplyForce in my code? If I remove it, the bodies' acceleration is too large.
RE: Chipmunk questions - Skorche - Sep 7, 2010 10:04 AM
No it's inelastic because the default elasticity (and friction) is 0. I should probably add that to the docs. Most other defaults are doced. Chipmunk never changes the forces applied to a body unless you ask it to.
I'll put the setters on the list of things to do for the next version. In the mean time, it doesn't hurt anything to just set the struct fields directly. As was mentioned, the body accessors are new anyway. Using them is not required except for mass, moment and angle. None of the shape properties have required setters.
RE: Chipmunk questions - Miglu - Sep 7, 2010 12:30 PM
When I add shape->e = 0.9 I get an Error Starting Executable sheet: "Unable to find Mach task port for process-id 504: (os/kern) failure (0x5)." What is the correct way to change the struct's variables?
RE: Chipmunk questions - OneSadCookie - Sep 7, 2010 02:06 PM
allocate the pointer before you dereference it.
you know, C basics.
RE: Chipmunk questions - Miglu - Sep 7, 2010 02:30 PM
It is allocated, cpShape *shape. I did not just add shape->e = 0.9, I also use shape and it works, I just did not feel the need to write the allocation and use lines of code in my previous message, as the problem is not about them.
RE: Chipmunk questions - OneSadCookie - Sep 7, 2010 03:45 PM
You post implies you added one line of code, which contains one pointer dereference, and your program stopped working. Therefore, in all likelihood, the pointer is invalid.
"cpShape *shape" does not allocate the shape.
In any case, if you actually meant that you did allocate the shape, and you know for sure the pointer is valid, you have all the usual memory corruption tools available to you to debug.
RE: Chipmunk questions - Miglu - Sep 8, 2010 08:39 AM
The problem has disappeared. Thanks for answering my Chipmunk questions.