Well I give up trying to get all those dependencies, I wrote a simple joint that I hope you guys undertand,
I did this in the Basic Joint demo of the SDK so that I can test it, and it worked.
It is a base Class, and an example of a Hinge class derived from that base class.
What is different from what you have, is that it reuses the functionality of all of the joints classes that I wrote in the Joint Library, instead of re creating them by interpreting the code.
Here is the Base Class
- Code: Select all
// Header file
class Joint
{
public:
Joint ();
virtual ~Joint();
protected:
void SetUp (NewtonCustomJoint* joint);
virtual void SubmitConstraints (dFloat timestep, int threadIndex) {};
static void Destructor (const NewtonUserJoint* me);
static void SubmitConstraints (const NewtonUserJoint* me, dFloat timestep, int threadIndex);
NewtonCustomJoint* m_supportJoint;
};
- Code: Select all
//cpp file
Joint::Joint ()
{
m_supportJoint = NULL;
}
Joint::~Joint()
{
if (m_supportJoint) {
m_supportJoint->SetUserData (NULL);
m_supportJoint->SetUserDestructorCallBack (NULL);
delete m_supportJoint;
}
}
void Joint::Destructor (const NewtonUserJoint* baseClassJoint)
{
Joint* me;
me = (Joint*)(((NewtonCustomJoint*) baseClassJoint)->GetUserData ());
if (me->m_supportJoint) {
me->m_supportJoint = NULL;
delete me;
}
}
void Joint::SubmitConstraints (const NewtonUserJoint* baseClassJoint, dFloat timestep, int threadIndex)
{
Joint* me;
me = (Joint*)(((NewtonCustomJoint*) baseClassJoint)->GetUserData ());
me->SubmitConstraints(timestep, threadIndex);
}
void Joint::SetUp (NewtonCustomJoint* joint)
{
m_supportJoint = joint;
// set the destructor call back
m_supportJoint->SetUserData (this);
m_supportJoint->SetUserDestructorCallBack (Destructor);
// Set the user submitconstraing for when the end app want to customizize existing joint behavior
m_supportJoint->SetUserSubmintConstraintCallBack (SubmitConstraints);
}
Here is an example code of a Hinge that reuses the existing Custom Hinge of teh Joint Library Newton
- Code: Select all
// Header
class Hinge: public Joint
{
public:
Hinge (const dMatrix& pinAndPivotFrame, const NewtonBody* child, const NewtonBody* parent);
~Hinge();
void EnableLimits(bool state);
void SetLimis(dFloat minAngle, dFloat maxAngle);
// optional if the app want to do more stuff, lfor example motorizing the joint
// virtual void SubmitConstraints (dFloat timestep, int threadIndex)
// {
// }
};
- Code: Select all
// code
Hinge::Hinge(const dMatrix& pinAndPivotFrame, const NewtonBody* child, const NewtonBody* parent)
:Joint ()
{
SetUp (new CustomHinge (pinAndPivotFrame, child, parent));
}
Hinge::~Hinge()
{
}
void Hinge::EnableLimits(bool state)
{
((CustomHinge*)m_supportJoint)->EnableLimits(state);
}
void Hinge::SetLimis(dFloat minAngle, dFloat maxAngle)
{
((CustomHinge*)m_supportJoint)->SetLimis(minAngle, maxAngle);
}
here is how you can use it
- Code: Select all
Hinge* hinge = new Hinge (pinAndPivot, link1, NULL);
hinge->EnableLimits (true);
hinge->SetLimis (-30.0f * 3.141592f/180.0f, 30.0f * 3.141592f/180.0f);
As you can see it is very easy to make all of the Joint in the Newton Joint Library without having to imitate them, Just derive form base and write few wraper funtion to redirect to teh base call joint.
I hope you understand this, if you have do not have problem with some of the porting I can help, but basically all you need to do is to make use the Ogre Classes instead of the Object that I am using.
Who is the maintainer of the Wraper you, kallaspriit or Melven?
If we agree on this and you can get it integrated into OgreNewt, there are still some things missing like GetInfo but those are minor thing consmetic funtionality tha can be added on demand,
the important thing is that this base class allows true code reusing, and You can get the complete full pawaaaaa of the Joint Library and then some more,
For exampel I see you guys have a 2d Joint,
This Base call joint also supports the Creation us Custom joint by End User Joint like your 2d joint, but we can worrie about that later.
Ah one last thing, I do not think you need two classes: Joint and CustomJoint since te eCustom joints contain all of the Joints and many more, plus they are all open source.
I know this can be seene as big rewrite but I believe it is worth trying, because I really beleive is will be more beneficial to many users to get all the funtionality, plsu egiven then teh avility to add on featire tah has not being
implemeneted.
There are some soficaticated joint in Netwon like he Player controller, polley, Keneamtic controller (very handy)
Later I will put this anwer in the FAQ, maybe it can give soem release to some poeple.