Trying to implement physics!

Hi

Today I have tried to implement physics but I am only getting a strange errormessage about some unresolved external symbol when I am trying to include the physics headers:

1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: virtual void __cdecl LinearEulerIntegrator::child_integrate(class Physical *,class pvector<class PointerTo<class LinearForce> > &,float)" (__imp_?child_integrate@LinearEulerIntegrator@@EEAAXPEAVPhysical@@AEAV?$pvector@V?$PointerTo@VLinearForce@@@@@@M@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl LinearEulerIntegrator::write(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write@LinearEulerIntegrator@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>  Hint on symbols that are defined and could potentially match:
1>    "__declspec(dllimport) public: virtual void __cdecl CollisionSolid::write(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write@CollisionSolid@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl Lens::write(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write@Lens@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl PandaNode::write(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write@PandaNode@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl TextNode::write(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write@TextNode@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl LinearEulerIntegrator::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@LinearEulerIntegrator@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>  Hint on symbols that are defined and could potentially match:
1>    "__declspec(dllimport) public: virtual void __cdecl CollisionBox::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@CollisionBox@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl CollisionNode::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@CollisionNode@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl CollisionRay::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@CollisionRay@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl CollisionSphere::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@CollisionSphere@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: void __cdecl LVecBase3f::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@LVecBase3f@@QEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl Lens::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@Lens@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: void __cdecl NodePath::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@NodePath@@QEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl PandaNode::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@PandaNode@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>    "__declspec(dllimport) public: virtual void __cdecl TextNode::output(class std::basic_ostream<char,struct std::char_traits<char> > &)const " (__imp_?output@TextNode@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl LinearEulerIntegrator::~LinearEulerIntegrator(void)" (__imp_??1LinearEulerIntegrator@@UEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl LinearEulerIntegrator::LinearEulerIntegrator(void)" (__imp_??0LinearEulerIntegrator@@QEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl PhysicsManager::do_physics(float)" (__imp_?do_physics@PhysicsManager@@QEAAXM@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl PhysicsManager::~PhysicsManager(void)" (__imp_??1PhysicsManager@@UEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl PhysicsManager::PhysicsManager(void)" (__imp_??0PhysicsManager@@QEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl BaseIntegrator::write_precomputed_angular_matrices(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write_precomputed_angular_matrices@BaseIntegrator@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual void __cdecl BaseIntegrator::write_precomputed_linear_matrices(class std::basic_ostream<char,struct std::char_traits<char> > &,int)const " (__imp_?write_precomputed_linear_matrices@BaseIntegrator@@UEBAXAEAV?$basic_ostream@DU?$char_traits@D@std@@@std@@H@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: virtual __cdecl PhysicsCollisionHandler::~PhysicsCollisionHandler(void)" (__imp_??1PhysicsCollisionHandler@@UEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __cdecl PhysicsCollisionHandler::PhysicsCollisionHandler(void)" (__imp_??0PhysicsCollisionHandler@@QEAA@XZ)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl PhysicsManager::attach_linear_integrator(class LinearIntegrator *)" (__imp_?attach_linear_integrator@PhysicsManager@@QEAAXPEAVLinearIntegrator@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: void __cdecl PhysicsManager::attach_physical_node(class PhysicalNode *)" (__imp_?attach_physical_node@PhysicsManager@@QEAAXPEAVPhysicalNode@@@Z)
1>C:\dev\Panda project\bin\x64\Release\Panda Project Source.exe : fatal error LNK1120: 14 unresolved externals

Okay, I solved it! You need to add libpandaphysics.lib to the additional dependencies for the linker! But now my question is how to use the PhysicsCollisionHandler and how to implement basic gravity!

If you notice that you are in the C++ section, there are code snippets that demonstrate how to do this.

Hi!

Thanks for the answer. I guess it is good to tell everyone what I am trying to accomplish with this. I am making a block-building game similar to Minecraft and I want the player/camera to have some basic physics, like gravity. I have already implemented a collisionRay and some basic collision but my question is more how to add gravity for the camera and still have the collison system working. I thought the PhysicsCollisionHandler was a combined handler for physics and collision. Is that what it is? If so, how do I set it up with basic collision and gravity?

/Isak

You can use the approach from example roaming-ralph. Just detect the surface with the beam and apply the Earth’s gravity formula to calculate the fall.

To clarify, what @serega-kkz is suggesting is not using the built-in physics system, but just using the built-in collision system, which will suit many games just fine that just need to have basic movement and jumping. No physics engine is required in this situation.

Many games that do need a physics engine tend to gravitate towards Bullet, so the built-in physics system ends up a little underused.

If you wanted to use the built-in physics system, I think you would need a LinearVectorForce and add it to your Physical.

Thanks for your answers. For now I will stick with the built-in collision system because that seems to be the easiest and most efficient alternative!

/Isak