A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by bluegg » Mon Jul 06, 2009 2:22 am
Hi .everyone, I use newton physical engineer.
But now I can't find the method to destroy a CustomGearJoint.
I used new to build a joint:
OgreNewt::PrebuiltCustomJoints::CustomGearJoint* mgj=new OgreNewt::PrebuiltCustomJoints::CustomGearJoint(rel,(*itr)->getBody(),(*iitr)->getBody(),ParentPin,ChildPin);
But who can tell me how to destroy this CustomGearJoint? (Don't destroy the body)
-
bluegg
-
- Posts: 4
- Joined: Mon Jul 06, 2009 2:05 am
by Julio Jerez » Mon Jul 06, 2009 7:45 am
if you have the pointer to the Joint,
delete mgj
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by JernejL » Mon Jul 06, 2009 7:58 am
you are using ogre wrapper, im not familiar with it but i assume the joint class has some destroy function.
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by bluegg » Mon Jul 06, 2009 10:07 pm
Thanks Julio Jerez and Delfi.
I had done like that to delete the pointer: delete mgj
but it doesn't work.The two body still join with CustomGearJoint.
And I found the class method,Post here:
//! CustomGearJoint
/*!
This class works like 2 gears that mesh, retaining a specific ration between the rotational velocity of the bodies.
The gears don't have to rotate around the same axis, that is why 2 pins are supplied.
*/
class _OgreNewtExport CustomGearJoint : public OgreNewt::CustomJoint
{
public:
/*!
\param gearRatio float value representing the ratio of movement between parent and child.
\param parent pointer to OgreNewt::Body to be the parent body.
\param child pointer to the OgreNewt::Body to be the child body.
\param parentPin pin around which the parent's rotation should be tracked.
\param childPin pin around which the child's rotation should be tracked.
*/
CustomGearJoint( Ogre::Real gearRatio, const Body* parent, const Body* child, const Ogre::Vector3& parentPin, const Ogre::Vector3& childPin );
~CustomGearJoint() {}
//! overloaded function to submit the constraint.
void submitConstraint();
private:
Ogre::Real mGearRatio;
Ogre::Vector3 mLocalPos0, mLocalPos1;
Ogre::Quaternion mLocalOrient0, mLocalOrient1;
};
This is a Export class.
How can I delete the gear joint?
-
bluegg
-
- Posts: 4
- Joined: Mon Jul 06, 2009 2:05 am
by Julio Jerez » Mon Jul 06, 2009 11:06 pm
- Code: Select all
class _OgreNewtExport CustomGearJoint : public OgreNewt::CustomJoint
{
public:
CustomGearJoint( Ogre::Real gearRatio, const Body* parent, const Body* child, const Ogre::Vector3& parentPin, const Ogre::Vector3& childPin );
~CustomGearJoint() {}
};
The class has a destructor,. an dit is derivec from OgreNewt::CustomJoint
Can you showu ne the implemenation of OgreNewt::CustomJoint?
There sould be a function ehr to destroy the Joint.
I thonk it world be teh destrurtor of OgreNewt::CustomJoint
But it could be some oteh function.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by bluegg » Mon Jul 06, 2009 11:30 pm
I found it derive from Joint:
class _OgreNewtExport CustomJoint : public Joint
And I found the ~joint() method running well.(I debug it with puting a break point there,and ~joint() is runing.)
So.I think the code : delete mgj is right.
But in my scene.The two gear still run like with Gearjoint.So strange.
I thinks something wrong else I missed.
-
bluegg
-
- Posts: 4
- Joined: Mon Jul 06, 2009 2:05 am
by bluegg » Mon Jul 06, 2009 11:45 pm
Ok.At last.I found my eyes made me a mistake.
In fact.It's done.As Julio Jerez said,just delete the pointer: delete mgj.
but because of inertia. my gear is running though I delete the Gearjoint pointer.
When I force it.It stoped.
Thanks Julio Jerez and Delfi.
I am sorry for my mistake.Hope teach others.

-
bluegg
-
- Posts: 4
- Joined: Mon Jul 06, 2009 2:05 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest