Attaching one body to another

kenny.bsp

21-08-2007 16:46:28

I'm creating a tank that is based on vehicle physics. I want it's cannon(or whatever is it's name ;D) to be a Body that is rotating and moving with tank. The problem is I don't know how to attach one body to another so they would move together. The only solution I found is to make a static body and move it to the position of the tank every frame. This is not exactly what I want, but still would do the job it should. It's all fine exept that it sometimes lags when my tank moves. I can record a video if needed. Is there a different way to attach one body to another and how to deal with that bug I'm having?
Thanks in advance.

betajaen

21-08-2007 16:54:35

You should look at the Joints system, read the PhysX documentation on this then have a look at the NxOgre version.

kenny.bsp

21-08-2007 17:30:03

Thanks. Tried to create a fixed joint
FixedJoint* testjoint = mScene->createFixedJoint(jpart1,jpart2);

and got this :
1>Linking...
1>Cake.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class NxOgre::FixedJoint * __thiscall NxOgre::Scene::createFixedJoint(class NxOgre::Actor *,class NxOgre::Actor *)" (__imp_?createFixedJoint@Scene@NxOgre@@QAEPAVFixedJoint@2@PAVActor@2@0@Z) referenced in function "public: virtual void __thiscall Sponge_Cake::start(void)" (?start@Sponge_Cake@@UAEXXZ)
1>D:\dev\NxOgre\/tutorials/compiler/release/Cakebox.exe : fatal error LNK1120: 1 unresolved externals

betajaen

21-08-2007 17:34:07

Do "new FixedJoint" until I complete the factory methods..Remember to delete them on shutdown.

kenny.bsp

21-08-2007 17:57:19

Thanks again :DD

Caphalor

21-08-2007 18:26:10

Or add this to NxOgreScene.cpp:

SphericalJoint* Scene::createSphericalJoint(NxOgre::Actor *a, NxOgre::Actor *b, const Ogre::Vector3 &anchor)
{
SphericalJoint* j = new SphericalJoint(a, b, anchor);
NxString jid = NxCreateID(mJoints.count(), "Joint");
mJoints.insert(jid, j);
mJoints.lock(jid, true);
return j;
};

FixedJoint* Scene::createFixedJoint(NxOgre::Actor *a, NxOgre::Actor *b)
{
FixedJoint* j = new FixedJoint(a, b);
NxString jid = NxCreateID(mJoints.count(), "Joint");
mJoints.insert(jid, j);
mJoints.lock(jid, true);
return j;
};


I implemented (more copy and pasted) it a few weeks ago.