setCustomForceAndTorqueCallback question

mangoo

23-05-2006 19:17:39

Hi,

i am relatively new to OgreNewt, but i have some experience with other physics engines. Until now everything worked well, but now i wanted to use the setCustomForceAndTorqueCallback function, but somehow i cant figure out how to declare it. I read through the tutorials and there it works fine, with this syntax:

info.mBody->setCustomForceAndTorqueCallback<OgreNewtonFrameListener>( &OgreNewtonFrameListener::dragCallback, this );

so i also tried something like this...

obj->mNewtonBody->setCustomForceAndTorqueCallback<World>( &World::standardForceCallback, PlayState::getInstance()->mWorld );


But somehow the compiler doesnt like it ,-)


My World has this function

void standardForceCallback( OgreNewt::Body* me );


and the compiler always says:

c:\....\src\InGame\ObjectFactory.cpp(53): error C2275: 'World' : illegal use of this type as an expression

It has something to do with the template brackets, its because of <World> and i dont know what i am doing wrong.

Does anybody have an idea what it could be?

walaber

24-05-2006 00:56:13

probably because there is already a class in OgreNewt called World, and it's getting confused..

mangoo

25-05-2006 11:42:02

i also tried it now with other classes like Object and ObjectFactory
but its still the same, always

c:\...\InGame\ObjectFactory.cpp(53): error C2275: 'ObjectFactory' : illegal use of this type as an expression

obj->mNewtonBody->setCustomForceAndTorqueCallback<ObjectFactory>( &ObjectFactory::standardForceCallback, this );


Is there any other way to make it? i would also use a static function, no problem, because i dont see a solution here :-(

Or does the class need some special properties?

walaber

26-05-2006 07:37:38

are you calling that function from inside a member function of that class?

for example in the ObjectFactory example, you are passing the "this" pointer. are you sure that "this" is a pointer to an ObjectFactory class instance?

mangoo

26-05-2006 14:32:19

yes when i called it with "this", it was inside a member function of this specific class....
until now i could not make it working
i am sure its only because of the template <>
the rest seems to be ok.
does my class have to include something?



another question, why is there no debugger::deinit() in wich the debugger scenenode is deleted?

walaber

26-05-2006 16:20:14

what compiler and platform?

e04margu

26-05-2006 18:42:27

I don't know what your error might be but try this instead if the templates are giving you grief:
obj->mNewtonBody->setCustomForceAndTorqueCallback( boost::bind( World::standardForceCallback, PlayState::getInstance()->mWorld, _1 ) );

Really shouldn't make any difference though so that might not work either.

Like walaber said it might be name ambiguity so use namespace names too to resolve it. Compiler should report it as an ambigous symbol but it gets confused sometimes.

mangoo

27-05-2006 14:12:24

compiler: vs 2003

ok i tried now the second variant

obj->mNewtonBody->setCustomForceAndTorqueCallback( boost::bind( World::standardForceCallback, PlayState::getInstance()->mWorld, 1 )


c:\..\InGame\ObjectFactory.cpp(127): error C2653: 'boost' : is not a class or namespace name

boost is not known somehow, i thought it is included in ogrenewt?

i ll try to put my world in a namespace


EDIT:

i put it in a namespace, didnt help, then i renamed the class to FWorld, also didnt help... i get crazy :-)
do i maybe have to include the boost lib?
i am using ogrenewt as DLL, so i only have the ogrenewt include directory plus ogrenewt_main_d.dll

walaber

27-05-2006 19:02:02

the demos compile fine, right?

mangoo

27-05-2006 19:57:37

yep, demo works, thats the strange thing,
tomorrow i ll download ogrenewt and compile everything again, maybe it helps

mangoo

29-05-2006 22:02:43

yeah :-) it works now..

i downloaded and recompiled ogrenewt again, and now it works, jippie, i think there was a boost file or so missing, but now it works....

great great ;-)
thx a lot for your support