Moderators: Sascha Willems, walaber







void Character::checkObjectsBelow(void)
{
Ogre::Vector3 charPoint = Ogre::Vector3(this->getPosition().x, this->getPosition().y + 0.4f, this->getPosition().z);
OgreNewt::BasicRaycast ray(this->pOgreNewt, charPoint, charPoint + Ogre::Vector3::NEGATIVE_UNIT_Y * 500.0f, true);
OgreNewt::BasicRaycast::BasicRaycastInfo contact = ray.getFirstHit();
//AdvancedOgreFramework::getSingletonPtr()->pDebugLabel3->setCaption("no contact:");
if (contact.getBody())
{
//AdvancedOgreFramework::getSingletonPtr()->pDebugLabel3->setCaption("contact with: " + contact.getBody()->getOgreNode()->getName());
this->height = contact.mDistance * 500.0f;
if (contact.mBody->getType() == AdvancedOgreFramework::getSingletonPtr()->TERRAINTYPE)
{
Ogre::Vector3 vec = Ogre::Vector3::UNIT_Y;
Ogre::Vector3 normal = contact.mNormal;
this->rise = Ogre::Math::ACos(vec.dotProduct(normal) / (vec.length() * normal.length())).valueDegrees();
//AdvancedOgreFramework::getSingletonPtr()->pDebugLabel3->setCaption("rise: " + Ogre::StringConverter::toString(rise));
}
}
}





Lax wrote:here: http://www.megaupload.com/?d=T7M6CBNT I've uploaded a test.
Go to the folder release and delete the file ogre.cfg, then start the OgreBaseArchitecture.exe. I've an error should appear, It could be that you need to install OpenAL.
You can move the player with the wasd keys and jump with space. You see in the right-bottom corner debuglabels which shows the raydistance from the player and an object. The error is, that the height is zero, because there is no rayhit with the terrain and therefore if you hold the jump button to long you get catapultated in the air, but If you jump on a box or other object, then everything works.
Here is the function which calculates the ray:


Users browsing this forum: No registered users and 167 guests