First post, and first things first - great library Scott, thanks, much appreciated.
Now a question. As discussed somewhere on this forum, boxes bouncing around inside a rotating box can be accomplished by using a static body comprising segments as the outer box, giving it an angular velocity, and updating the static hash. Works fine, but is this the correct approach for the following:
Imagine a hamster running around the inside of a wheel. I want the wheel to move, plus I want to estimate the power and torque generated by the little critter. So I spin a couple of (dynamic) shapes inside the stationary wheel and it doesn't turn, no matter how sticky or heavy I make the 'feet'. I'm guessing that I will need to make the wheel a dynamic body, but then gravity affects it. Pin it at the centre of rotation? Or is there something I've missed with the static body approach?
StaticBody question
-
- Posts: 2
- Joined: Sun Oct 26, 2008 2:53 am
- Contact:
Re: StaticBody question
I have a terrible awesome suggestion for you. You should be able to model a concave shape by putting lots of convex shapes in the same body. Try creating your hamster wheel as a ring of small trapezoids. This is similar to the clockwork gears demo.
-
- Posts: 56
- Joined: Tue Jul 15, 2008 4:13 am
- Contact:
Re: StaticBody question
First off: why are you updating the static hash manually? Just add the shapes to the active hash and you get what you want, you still don't have to add the body.
Second: you probably set your wheel's body's inertia to INFINITY to get a static body, this will prevent your wheel from ever using any force to make it rotate. Only set your mass to INFINITY and use the inertia calculating functions to get a correct inertia.
I'm somewhat confused, why do you use segments as the outer box. Are you sure you didn't mean polygon for the outer shape (or in case of a wheel a circle) and line segments for the inner shape, and anything that is supposed to be inside gets added to the outer circle/polygons group?
Second: you probably set your wheel's body's inertia to INFINITY to get a static body, this will prevent your wheel from ever using any force to make it rotate. Only set your mass to INFINITY and use the inertia calculating functions to get a correct inertia.
I'm somewhat confused, why do you use segments as the outer box. Are you sure you didn't mean polygon for the outer shape (or in case of a wheel a circle) and line segments for the inner shape, and anything that is supposed to be inside gets added to the outer circle/polygons group?
- slembcke
- Site Admin
- Posts: 4166
- Joined: Tue Aug 14, 2007 7:13 pm
- Contact:
Re: StaticBody question
I think you are thinking of Demo4 from the 4.1.0 release. (http://code.google.com/p/chipmunk-physi ... mo/Demo4.c) You'll want to note the comment in the source:
For your hamster wheel, you'll want to use a normal dynamic body and use a pivot joint to pin it onto something else.
Code: Select all
// NOTE: Normally you would want to add the segments as normal and not static shapes.
// I'm just doing it to demonstrate the cpSpaceRehashStatic() function.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
-
- Posts: 6
- Joined: Thu Dec 04, 2008 1:47 pm
- Contact:
Re: StaticBody question
That's correct, I was thinking of Demo 4 - I got to it from a comment on the forum. I guess I should read the comments in the code a little more carefully I'll pin it to a frame.
ker: thanks for the tip on INFINITY inertia, one to remember. I thought of using segments instead of a polygon so that I can set e and u to different values in different parts of the wheel - plastic body and a few rubber treads for example.
tiglionabbit: good idea regarding multiple shapes in the same body - might be more realistic than using segments. Where do I find the clockwork gears demo code?
ker: thanks for the tip on INFINITY inertia, one to remember. I thought of using segments instead of a polygon so that I can set e and u to different values in different parts of the wheel - plastic body and a few rubber treads for example.
tiglionabbit: good idea regarding multiple shapes in the same body - might be more realistic than using segments. Where do I find the clockwork gears demo code?
Who is online
Users browsing this forum: No registered users and 38 guests