No Custom2DJoint and UpVector?

vitefalcon

27-01-2010 15:55:28

Hi,

I was using OgreNewt in my project. I upgraded my OgreNewt and found that Custom2DJoint and UpVector joint classes are commented out. Are 2D joints no longer supported? Thanks in advance.

kallaspriit

27-01-2010 19:13:23

They are supported, but the interface changed to use the JointLibrary and all the joints have not been converted. See how for example hinge has been implemented and do the same for those and submit the code here, I will add it to OgreNewt.

vitefalcon

28-01-2010 16:37:05

I've done a rough implementation of UpVector. I still have to figure it out for Custom2DJoint. So I'm pasting the code for the UpVector here. Hope it helps someone.

OgreNewt_BasicJoint.h
//! UpVector joint.
/*!
simple upvector joint. upvectors remove all rotation except for a single pin. useful for character controllers, etc.
*/
class _OgreNewtExport UpVector : public Joint
{

public:
//! constructor
/*
\param world pointer to the OgreNewt::World.
\param body pointer to the body to apply the upvector to.
\param pin direction of the upvector in global space.
*/
UpVector( const Body* body, const Ogre::Vector3& pin );

//! destructor
~UpVector();

//! set the pin direction.
/*
by calling this function in realtime, you can effectively "animate" the pin.
*/
void setPin( const Ogre::Vector3& pin );

//! get the current pin direction.
const Ogre::Vector3& getPin() const;

private:
Ogre::Vector3 m_pin;
};


OgreNewt_BasicJoint.cpp
UpVector::UpVector( const Body* body, const Ogre::Vector3& pin )
:Joint()
,m_pin(pin.normalisedCopy())
{
dVector dPin(m_pin.x, m_pin.y, m_pin.z, 1.0f);
CustomUpVector* support_joint = new CustomUpVector(dPin, body->getNewtonBody());
SetSupportJoint(support_joint);
}

UpVector::~UpVector()
{
}

void UpVector::setPin( const Ogre::Vector3& pin )
{
CustomUpVector* up_vector = static_cast<CustomUpVector*>(m_joint);
m_pin = pin.normalisedCopy();
dVector dPin(m_pin.x, m_pin.y, m_pin.z, 1.0f);
up_vector->SetPinDir(dPin);
}

const Ogre::Vector3& UpVector::getPin() const
{
return m_pin;
}

kallaspriit

28-01-2010 20:28:37

Good, I'll try to include it in the next version of OgreNewt :P

vitefalcon

28-01-2010 23:19:11

Glad I could be of help :)