Hi,
I have a class Bumping Ball that inherit from a class GameEntity, which have the body of my object as a data member.
roughly, i have this :
class GameEntity
{
public:
// some methods
protected:
Ogre::Mesh* mMesh;
Ogre::Entity* mEntity;
Ogre::SceneManager* mSceneMgr;
Ogre::SceneNode* mSceneNode;
OgreNewt::Body* mBody;
OgreNewt::World* mWorld;
OgreNewt::MaterialID* mMaterial;
};
and here is the (interessant) part of code inside my BumpingBall class :
void BumpingBall::createBBall(Ogre::String name, const Ogre::Real mass = 10, const Ogre::Real radius = 2)
{
// creation of the SceneNode, Entity, Body and other stuff
mBody->setCustomForceAndTorqueCallback(&BumpingBall::ApplyTorqueCallback);
}
here is the callback, almost empty for now
void BumpingBall::ApplyTorqueCallback(OgreNewt::Body* me)
{
me->addTorque(mSpeed);
}
And whien i try to compile this stuff, Visual Studio tells me:
error C2064: term does not evaluate to a function taking 1 arguments
on the file function_template.hpp, line 136, which is this one
struct BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
{
static BOOST_FUNCTION_VOID_RETURN_TYPE
invoke(any_pointer function_obj_ptr BOOST_FUNCTION_COMMA
BOOST_FUNCTION_PARMS)
{
FunctionObj* f = (FunctionObj*)(function_obj_ptr.obj_ptr);
BOOST_FUNCTION_RETURN((*f)(BOOST_FUNCTION_ARGS)); /// < line 136 \\\
}
};
Any help will be very welcomed !
Thanks
Zero23
21-03-2009 19:52:14
Hi
Try
mBody->setCustomForceAndTorqueCallback(&BumpingBall::ApplyTorqueCallback, this);
Zero
Already tried :
error C2660: 'OgreNewt::Body::setCustomForceAndTorqueCallback' : function does not take 2 arguments :/
Zero23
21-03-2009 21:38:19
Ohh sry, a mistake from me^^ I dont looked at the source
mBody->setCustomForceAndTorqueCallback<BumpingBall>(&BumpingBall::ApplyTorqueCallback, this);
This should work
Zero
It was so easy...shame on me..
well, many thanks Zero ^^
Hi, i have probably similiar problem that i cannot solve. Im just trying to see what works in new ogrenewt, and in first tutorial i changed standardCallback to custom
body->setCustomForceAndTorqueCallback<OgreNewtonFrameListener>(&OgreNewtonFrameListener::move_callback, this);
void move_callback(OgreNewt::Body* me)
{
me->addForce(Vector3(0,-10,0));
}
but i cant compile,it gives me this error
------ Build started: Project: pro, Configuration: Release Win32 ------
1>Compiling...
1>OgreNewtonApplication.cpp
1>E:\boost_1_38_0\boost/function/function_template.hpp(224) : error C2064: term does not evaluate to a function taking 4 arguments
1> class does not define an 'operator()' or a user defined conversion operator to a pointer-to-function or reference-to-function that takes appropriate number of arguments
1> E:\boost_1_38_0\boost/function/function_template.hpp(221) : while compiling class template member function 'void boost::detail::function::function_void_mem_invoker4<MemberPtr,R,T0,T1,T2,T3>::invoke(boost::detail::function::function_buffer &,T0,T1,T2,T3)'
1> with
1> [
1> MemberPtr=void (__thiscall OgreNewtonFrameListener::* )(OgreNewt::Body *),
1> R=void,
1> T0=OgreNewtonFrameListener *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int
1> ]
1> E:\boost_1_38_0\boost/function/function_template.hpp(904) : see reference to class template instantiation 'boost::detail::function::function_void_mem_invoker4<MemberPtr,R,T0,T1,T2,T3>' being compiled
1> with
1> [
1> MemberPtr=void (__thiscall OgreNewtonFrameListener::* )(OgreNewt::Body *),
1> R=void,
1> T0=OgreNewtonFrameListener *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int
1> ]
1> E:\boost_1_38_0\boost/function/function_template.hpp(720) : see reference to function template instantiation 'void boost::function4<R,T0,T1,T2,T3>::assign_to<Functor>(Functor)' being compiled
1> with
1> [
1> R=void,
1> T0=OgreNewtonFrameListener *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int,
1> Functor=void (__thiscall OgreNewtonFrameListener::* )(OgreNewt::Body *)
1> ]
1> E:\boost_1_38_0\boost/function/function_template.hpp(1041) : see reference to function template instantiation 'boost::function4<R,T0,T1,T2,T3>::function4<Functor>(Functor,int)' being compiled
1> with
1> [
1> R=void,
1> T0=OgreNewtonFrameListener *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int,
1> Functor=void (__thiscall OgreNewtonFrameListener::* )(OgreNewt::Body *)
1> ]
1> e:\ogrenewt\demos\demo01_thebasics\OgreNewtonFrameListener.h(156) : see reference to function template instantiation 'boost::function<Signature>::function<void(__thiscall OgreNewtonFrameListener::* )(OgreNewt::Body *)>(Functor,int)' being compiled
1> with
1> [
1> Signature=void (OgreNewtonFrameListener *,OgreNewt::Body *,float,int),
1> Functor=void (__thiscall OgreNewtonFrameListener::* )(OgreNewt::Body *)
1> ]
1>Build log was saved at "file://e:\pro\obj\Release\BuildLog.htm"
1>pro - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
Do you have any idea what is the problem? Thank you.
Zero23
27-05-2009 22:45:45
Your function move_callback, miss some parameters
void move_callback( Body* me, float timeStep, int threadIndex )
{}
Try this!
Zero
Hmm, I tried the same thing yesterday and it didnt work, but as you suggested the same, i tried to do it today too with few modifications to the rest of code and it works

. Thank you.
Anyway, do you have any idea why is it that I need float and int parameters and Zep above dont?
prchakal
23-11-2009 21:37:32
I have the same problem:
_body->setCustomForceAndTorqueCallback<EnginePlayer>(&EnginePlayer::forceCallback, this);
and:
void EnginePlayer::forceCallback(OgreNewt::Body *body, float timeStep, int threadIndex) {
/*
//obtém o player do callback
EnginePlayer* player = Ogre::any_cast<EnginePlayer*>(body->getUserData());
*/
//obtém massa e inércia
Ogre::Real mass;
Ogre::Vector3 inertia;
body->getMassMatrix(mass, inertia);
//adiciona gravidade
Ogre::Vector3 gravity = Ogre::Vector3(0, -9.8,0) * mass;
body->addForce(gravity);
}
the error:
1>------ Build started: Project: PR3DEngine, Configuration: Release Win32 ------
1>Compiling...
1>EnginePlayer.cpp
1>D:\Downloads\Cpp\LIB\boost\boost/function/function_template.hpp(112) : error C2197: 'void (__cdecl *)(OgreNewt::Body *,float,int)' : too many arguments for call
1> D:\Downloads\Cpp\LIB\boost\boost/function/function_template.hpp(110) : while compiling class template member function 'void boost::detail::function::void_function_invoker4<FunctionPtr,R,T0,T1,T2,T3>::invoke(boost::detail::function::function_buffer &,T0,T1,T2,T3)'
1> with
1> [
1> FunctionPtr=void (__cdecl *)(OgreNewt::Body *,float,int),
1> R=void,
1> T0=EnginePlayer *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int
1> ]
1> D:\Downloads\Cpp\LIB\boost\boost/function/function_template.hpp(913) : see reference to class template instantiation 'boost::detail::function::void_function_invoker4<FunctionPtr,R,T0,T1,T2,T3>' being compiled
1> with
1> [
1> FunctionPtr=void (__cdecl *)(OgreNewt::Body *,float,int),
1> R=void,
1> T0=EnginePlayer *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int
1> ]
1> D:\Downloads\Cpp\LIB\boost\boost/function/function_template.hpp(722) : see reference to function template instantiation 'void boost::function4<R,T0,T1,T2,T3>::assign_to<void(__cdecl *)(OgreNewt::Body *,float,int)>(Functor)' being compiled
1> with
1> [
1> R=void,
1> T0=EnginePlayer *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int,
1> Functor=void (__cdecl *)(OgreNewt::Body *,float,int)
1> ]
1> D:\Downloads\Cpp\LIB\boost\boost/function/function_template.hpp(1065) : see reference to function template instantiation 'boost::function4<R,T0,T1,T2,T3>::function4<void(__cdecl *)(OgreNewt::Body *,float,int)>(Functor,int)' being compiled
1> with
1> [
1> R=void,
1> T0=EnginePlayer *,
1> T1=OgreNewt::Body *,
1> T2=float,
1> T3=int,
1> Functor=void (__cdecl *)(OgreNewt::Body *,float,int)
1> ]
1> .\src\engine\EnginePlayer.cpp(127) : see reference to function template instantiation 'boost::function<Signature>::function<void(__cdecl *)(OgreNewt::Body *,float,int)>(Functor,int)' being compiled
1> with
1> [
1> Signature=void (EnginePlayer *,OgreNewt::Body *,float,int),
1> Functor=void (__cdecl *)(OgreNewt::Body *,float,int)
1> ]
1>Build log was saved at "file://d:\PRSoluções\Softwares\PR3DEngine\PR3DEngine\Release\BuildLog.htm"
1>PR3DEngine - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
prchakal
23-11-2009 21:47:45
NO MORE!!
Solved. The problem was that i put my function as static, but dont need.
Thx.