Page 4 of 6

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Mon Aug 29, 2011 9:48 pm
by AndyLy
I had a couple of questions:
1. When the output wrapper to version 6?
2. In this version of the wrapper is missing a lot of commands, and in some procedures do not match the number of parameters. The author has no plans to add a brief description of the structures and commands?
3. What exactly does this function: cpSpaceHashEach (*space\activeShapes,@DrawShape(),#Null) ?

Little things will not ask, I will try to understand them myself.

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Mon Aug 29, 2011 11:37 pm
by IceSoft
AndyLy wrote:I had a couple of questions:
1. When the output wrapper to version 6?
2. In this version of the wrapper is missing a lot of commands, and in some procedures do not match the number of parameters. The author has no plans to add a brief description of the structures and commands?
3. What exactly does this function: cpSpaceHashEach (*space\activeShapes,@DrawShape(),#Null) ?

Little things will not ask, I will try to understand them myself.
1) When it is done and not before the 4.60 is released. Sorry.
2) Tell me what you are missing and I will add it to the wrapper. Some function have to wrap a little bit more. That's the reason for different parameter. In most cases it is the return value of a structure which PureBasic can not handle correct.
3) Read the docu here: http://chipmunk-physics.net/release/Chi ... test-Docs/ or ask in this forum:http://chipmunk-physics.net/forum/

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 12:32 am
by AndyLy
I do not hurry you, just want to know: I continue to write under the current version of the procedure, or should wait for a new one.
"Tell me what you are missing..."
Without some procedures you can do if you know the description of the structures .But when some have additional parameters, it is not clear that there sent. I wanted to try a code, taken from the forum and could not implement it for lack of commands and mismatches.

Code: Select all

// velocity of the two surfaces in relation to the collision normal at the collision point
static inline cpFloat
hit_velocity(cpBody *a, cpBody *b, cpVect p, cpVect n){
   cpVect r1 = cpvsub(p, a->p);
   cpVect r2 = cpvsub(p, b->p);
   cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w));
   cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w));
   
   return cpvdot(cpvsub(v2_sum, v1_sum), n);
}

// This is a pre-solve callback
static bool
bumpSoundCallback(cpArbiter *arb, cpSpace *space, void *unused)
{
   cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b);
   cpContact *contacts = arb->contacts;
   
   const cpFloat min = 10.0f;
   const cpFloat max = 300.0f;
   cpFloat nspeed = cpfabs(hit_velocity(a->body, b->body, contacts[0].p, contacts[0].n));

   if(nspeed > min){
      ALfloat volume = fmax(fminf((nspeed - min)/(max - min), 1.0f), 0.0f);
      playSound(bumpSound, volume, 1.0f);
   }
   return TRUE;
}
Here
cpvsub, cpvmult - need 3 parameters instead of 2. What are they?

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 9:15 am
by IceSoft
AndyLy wrote: 1) I continue to write under the current version of the procedure, or should wait for a new one.
2) Without some procedures you can do if you know the description of the structures .But when some have additional parameters, it is not clear that there sent. I wanted to try a code, taken from the forum and could not implement it for lack of commands and mismatches.

Code: Select all

// velocity of the two surfaces in relation to the collision normal at the collision point
static inline cpFloat
hit_velocity(cpBody *a, cpBody *b, cpVect p, cpVect n){
   cpVect r1 = cpvsub(p, a->p);
   cpVect r2 = cpvsub(p, b->p);
   cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w));
   cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w));
   
   return cpvdot(cpvsub(v2_sum, v1_sum), n);
}

// This is a pre-solve callback
static bool
bumpSoundCallback(cpArbiter *arb, cpSpace *space, void *unused)
{
   cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b);
   cpContact *contacts = arb->contacts;
   
   const cpFloat min = 10.0f;
   const cpFloat max = 300.0f;
   cpFloat nspeed = cpfabs(hit_velocity(a->body, b->body, contacts[0].p, contacts[0].n));

   if(nspeed > min){
      ALfloat volume = fmax(fminf((nspeed - min)/(max - min), 1.0f), 0.0f);
      playSound(bumpSound, volume, 1.0f);
   }
   return TRUE;
}
Here
3) cpvsub, cpvmult - need 3 parameters instead of 2. What are they?
1) PLease continue with your work. The Chimunk 6.x wrapper will not be free like the 5.x wrapper version.
Only 5.x will be still free. I will make a update to ther latest 5x version (5.3.5) after release of PureBasic 4.60.
2) Only cp* functions are public functions. Were you have this example source?
3) cpvsub, cpvmult, ... returning a structure of cpVect. As long PureBasic cannot handle structures as return value as long such kind of functions have to be wrapped. The first parameter is the return value.

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 5:20 pm
by AndyLy
Were you have this example source?
This code is taken from the chipmunk-physics forum. Posted some guy with a nick slembcke. :)

Thank you. Somehow I figured out that code. There were link errors due to cpfabs, cpfmax, cpfmin - had to throw them away. :)
In general, it seems I am close to completing a wrapper for your wrapper. :)

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 6:08 pm
by IceSoft
AndyLy wrote:
Were you have this example source?
1)This code is taken from the chipmunk-physics forum. Posted some guy with a nick slembcke. :)

Thank you. Somehow I figured out that code.
2) There were link errors due to cpfabs, cpfmax, cpfmin - had to throw them away. :)
3)In general, it seems I am close to completing a wrapper for your wrapper. :)
1) There is a lot of such examples on the Chipmunk forum. I do not knowing all.
2) Polink errors?
3) Fine. You are not alone ;-)

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 6:45 pm
by AndyLy
Fine. You are not alone
And who else mpz?
I'm writing it for my little game, so it will not be universal.
Polink errors?
POLINK: error Unresolved external symbol 'cpfabs@@YANN@Z'
POLINK: error Unresolved external symbol 'cpfmax@@YANN@Z'
POLINK: error Unresolved external symbol 'cpfmin@@YANN@Z'

Add
Test program today, changed all the settings. The slowdown started after 1000 (small) objects, that I was not happy. Hoped for more. In connection with the question: cpSpaceResizeActiveHash shure works? I tried different settings, even removed it, no effect.

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 11:31 pm
by IceSoft
AndyLy wrote:
Fine. You are not alone
And who else mpz?
I'm writing it for my little game, so it will not be universal.
Polink errors?
POLINK: error Unresolved external symbol 'cpfabs@@YANN@Z'
POLINK: error Unresolved external symbol 'cpfmax@@YANN@Z'
POLINK: error Unresolved external symbol 'cpfmin@@YANN@Z'

Add
Test program today, changed all the settings. The slowdown started after 1000 (small) objects, that I was not happy. Hoped for more. In connection with the question: cpSpaceResizeActiveHash shure works? I tried different settings, even removed it, no effect.

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Tue Aug 30, 2011 11:32 pm
by IceSoft
AndyLy wrote:
Fine. You are not alone
And who else mpz?
I'm writing it for my little game, so it will not be universal.
Polink errors?
POLINK: error Unresolved external symbol 'cpfabs@@YANN@Z'
POLINK: error Unresolved external symbol 'cpfmax@@YANN@Z'
POLINK: error Unresolved external symbol 'cpfmin@@YANN@Z'

Add
Test program today, changed all the settings. The slowdown started after 1000 (small) objects, that I was not happy. Hoped for more. In connection with the question: cpSpaceResizeActiveHash shure works? I tried different settings, even removed it, no effect.
Post your code and I can say more

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Wed Aug 31, 2011 1:33 am
by AndyLy
Post your code and I can say more
It will be difficult. But I tried the example that you put a wrapper, Chipmunk4PB_Demo.pb- there exact same situation.
I do not see any difference with or without cpSpaceResizeActiveHash.

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Wed Aug 31, 2011 9:46 am
by IceSoft
Maybe this answer is the right for you:
http://chipmunk-physics.net/forum/viewt ... Hash#p6887

Question about Chipmunk functions should be be better ask on the Chipmunk board ;-)

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Wed Aug 31, 2011 2:44 pm
by AndyLy
The point is that I first looked at the forum and judging by the posts it works for them. Change the settings have a visible effect, but I do not have any effect, even if I delete the hash command.

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Thu Oct 06, 2011 7:37 am
by AndyLy
After a long break, I returned to Сhipmunk:

http://www.youtube.com/watch?v=Xr-CicRCmKs

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Thu Oct 06, 2011 2:49 pm
by IceSoft
AndyLy wrote:After a long break, I returned to Сhipmunk:

http://www.youtube.com/watch?v=Xr-CicRCmKs
Sweet. But I think it is not using PureBasic. Right?

Re: Who is also working on a Chipmunk wrapper (2D physic eng

Posted: Thu Oct 06, 2011 3:50 pm
by AndyLy
Sweet. But I think it is not using PureBasic. Right?
Why have you decided so? Of course this is PureBasic! Pure PureBasic.