Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

NGD Wrapper

7 views
Skip to first unread message

Fede

unread,
Jun 26, 2008, 7:23:28 AM6/26/08
to
Hi people!

I'm wrapping a C physics library called Newton Game Dynamics (http://
www.newtondynamics.com/) and I'm having trouble with a callback that I
must set.
The callback is being called, but it gpfaults after returning.
I'm sure about the calling conventions and parameters it receives,
it's really driving me crazy...
I know that a few people here use this library, so, if you can take a
look, it would be great ;-)

This is the workspace code I'm trying:

world := NewtonWorld new.
collision := NewtonCollision box: 1 @ 1 @ 1 on: world.
location := MATRIX identity _42: 10. "set the Y position at 10 meters"
box := NewtonBody newOn: world withCollision: collision.
box onForceAndTorqueCallbackDo:
[:newtonBody |
newtonBody force: 0 @ (newtonBody mass * 9.81) @ 0.
Transcript
show: 'Callback called!';
cr].
box mass: 1 inertia: 1 @ 1 @ 1.
box matrix: location.
world update: 0.01

And you can download my NGD package from: http://omoto.com.ar/NGD.zip


Thank you in advance,

Federico Omoto

zenchess

unread,
Jul 3, 2008, 1:04:53 AM7/3/08
to
What game engine or 3d renderer are you using to display 3d
graphics? I have successfully gotten Tv3d to work with Dolphin and am
playing around with that, but also Unstdio has openGl support in it
although it wasn't designed for 3d yet (though maybe it's an easy leap
to make if you know what you are doing).

Thanks for making your package available, I'll definitely check it
out.
-Jacob

Fede

unread,
Jul 3, 2008, 7:38:51 AM7/3/08
to
Hi Jacob!

Like Unstdio I'm actually working in 2D, I'm wrapping a game engine
called HGE: http://hge.relishgames.com
I started wrapping NGD as I wanted to add physics to it, but I'm
afraid that my NGD wrapper is stalled because of the ExternalCallback
gpfault =(
The problem seems to be random, but when it doesn't gpfaults I can
assure you that it's really impressive to see NGD working together
with HGE!
Anyway, if you want to check my HGE wrapper it's hosted at Google
code: http://code.google.com/p/hgetalk (you've to check out the
project using svn as I didn't made any download files yet). I've
ported the first 7 tutorials as workspace code so you can clearly see
the differences between the C and the Smalltalk versions.

I never heard of Tv3D, I'll take a look to it; but a 3D rendering
engine I was looking at is Horde3D (http://www.horde3d.org). It has a
plain C API accessible through a DLL, so making the bindings for
Dolphin shouldn´t be a problem.

Thank you for your kind words and best regards,

Federico Omoto

zenchess

unread,
Jul 24, 2008, 4:01:19 PM7/24/08
to
On Jul 3, 6:38 am, Fede <Federico.Om...@gmail.com> wrote:
> Hi Jacob!
>
> Like Unstdio I'm actually working in 2D, I'm wrapping a game engine
> called HGE:http://hge.relishgames.com
> I started wrapping NGD as I wanted to add physics to it, but I'm
> afraid that my NGD wrapper is stalled because of the ExternalCallback
> gpfault =(
> The problem seems to be random, but when it doesn't gpfaults I can
> assure you that it's really impressive to see NGD working together
> with HGE!
> Anyway, if you want to check my HGE wrapper it's hosted at Google
> code:http://code.google.com/p/hgetalk(you've to check out the

> project using svn as I didn't made any download files yet). I've
> ported the first 7 tutorials as workspace code so you can clearly see
> the differences between the C and the Smalltalk versions.
>
> I never heard of Tv3D, I'll take a look to it; but a 3D rendering
> engine I was looking at is Horde3D (http://www.horde3d.org). It has a
> plain C API accessible through a DLL, so making the bindings for
> Dolphin shouldn´t be a problem.
>
> Thank you for your kind words and best regards,
>
> Federico Omoto

Hi Federico, I have emailed your federico.omoto email which is hosting
the HGE/dolphin project in google code.
I had I think the exact same problem, maybe this will help:
If you are running the callback code and for some reason you hit a
debug error (like a bug in your code), I need
to completely shut down Dolphin Smalltalk and then re-start it again
before I can reload the callback code. This is
what I need to do with Tv3d, but other than that it works perfectly.
I will be moving to a 2d engine soon,
however, preferably in Dolphin so I am quite interested in your
project =)

Fede

unread,
Aug 5, 2008, 11:12:17 PM8/5/08
to
Hi again! :)

Sorry for the delay in the answer and thank you for your interest in
my project!
I'm afraid I'm not investing my time as I did before trying to release
a NGD wrapper for Dolphin, it's really difficult to say what's going
on, where the problem is and what IS the problem when NGD calls my
ExternalCallbacks. It's frustrating not having the source code so I
can solve this problem (being it at the NGD side, or at the Dolphin
side if it ends up being my fault...).
I had some inconvenients when I started with my HGE wrapper,
particullary when I tried to make the C++ objects finalizable; but as
the HGE source code is available it just was a matter of hacking the
HGE code to make it Smalltalk friendly ;)
Said that, I continue to adding functionality to my accelerated 2D
Smalltalk game engine, but whithout physics support :(

I've also sent you an email with my thoughts on why you're able to run
just the first tutorial of the HGE wapper, hope it helped you, but if
not just tell me!


Regards,

Fede

Andy Bower

unread,
Jan 12, 2009, 5:21:50 AM1/12/09
to
Fede, all,

Did any one take a look at this problem? I notice that the link for the
Dolphin wrapper is now broken, so is the package available elsewhere?

Best regards

Andy Bower

Andy Bower

unread,
Jan 13, 2009, 11:05:02 AM1/13/09
to
Fede,

Frank Lesser had a copy of the NGD package and forwarded it to me. It
seem that the problem is caused by returning nil from the callback block
in NewtonBody>>onForceAndTorqueCallbackDo:. Removing the nil (so the
block returns self) fixes the problem - at least for the example
workspace you provided - and your box seems to fall with increasing
velocity according to gravity as might be expected.

Best regards

Andy Bower

Patched code below:

====================

!NewtonBody methodsFor!

onForceAndTorqueCallbackDo: aMonadicValuable
"Evaluate the monadic valuable argument on a force and torque callback
event, passing
the receiver as the argument."

forceAndTorqueCallback := ExternalCallback
block: [:newtonBody | aMonadicValuable value: newtonBody]
descriptor: (ExternalDescriptor
callingConvention: 'cdecl:'
returnType: 'void'
argumentTypes: 'NewtonBody*').
NewtonLibrary default newtonBodySetForceAndTorqueCallback: self
callback: forceAndTorqueCallback asParameter! !
!NewtonBody categoriesFor: #onForceAndTorqueCallbackDo:!public! !

0 new messages