Density ans other things

Official forum for the Chipmunk2D Physics Library.
Post Reply
Dark
Posts: 2
Joined: Sun Dec 07, 2008 3:51 pm
Contact:

Density ans other things

Post by Dark »

Hi,

I have to do a school project, and i decided to use Chipmunk.
I did manage to do some things but, for the moment:
- I don't know how we represent density in chipmunk
- i have to do a sort of balance that I use as a catapult(composed a triangle(static object) and 3 lines(object) to project balls) . I want that my object to be on the top of the triangle. Do i have to do like that:

Code: Select all

static cpBody* make_support(cpFloat x, cpFloat y){
  int num=4;
  cpVect* test=transforme_ligne(-170,0,100,0,10);
  cpVect* test2=transforme_ligne(-170,0,-170,60,3);
  cpVect* test3=transforme_ligne(100,0,130,60,3);
  cpBody* body=cpBodyNew(10.0,cpMomentForPoly(0.2,num,test,cpvzero));
  body->p=cpv(x,y);
  cpSpaceAddBody(space,body);
  shape=cpPolyShapeNew(body,num,test,cpvzero);
  shape->e=0.8;shape->u=0.8;
  cpSpaceAddShape(space,shape);
  shape=cpPolyShapeNew(body,num,test2,cpvzero);
  shape->e=0.8;shape->u=0.8;
  cpSpaceAddShape(space,shape);

  shape=cpPolyShapeNew(body,num,test3,cpvzero);
  cpSpaceAddShape(space,shape);
  
  return body;
}
I hope you will understand my "english"
Thx for your help.
Dark
Dark
Posts: 2
Joined: Sun Dec 07, 2008 3:51 pm
Contact:

Re: Density ans other things

Post by Dark »

up ?
Sorry but i have no answers, anyone know how setting the density when you have moment of inertia ?
Dark
spiderman
Posts: 2
Joined: Thu Dec 11, 2008 5:15 am
Contact:

Re: Density ans other things

Post by spiderman »

Good Morning,

I have to do the same project than dark and I think the moment of inertia is linked with the density but on chipmunk, I don't know how to use the density too.

We have to finish the project the next monday morning and we need help to solve this problem.

Sorry for my bad english thanks for your future help.
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Density ans other things

Post by maximile »

In Chipmunk you set the mass of a body rather than the density. You set it with body->m. If you only know the density you'll have to work out the mass from the size of the shape.
spiderman
Posts: 2
Joined: Thu Dec 11, 2008 5:15 am
Contact:

Re: Density ans other things

Post by spiderman »

If I understood, the density is useful to obtain the mass when whe don't know it.

thank you for your help.
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests