Okay, with some modification to my code and some observations, it appears I've solved the crisis I was having, to some extent at least. I can still move up any gradient, but...
Code: Select all
// Create a node for the loaded model.
scene::IAnimatedMeshSceneNode* _MeshSceneNode = Game::CreateMeshNode(filename);
// Create the Body structure
newton::SBodyFromNode bodyData;
bodyData.Type = newton::EBT_AUTODETECT;
bodyData.Node = _MeshSceneNode;
// Lock the rotation around anything but the Y axis.
// TODO: Check for obsoletion with avoidRotationOnAllAxes()
m_LockRotation = true;
// Create the actual Newton body.
m_Model = Game::s_World->createCharacterController(Game::s_World->createBody(bodyData));
// Set the material to material #1 for testing purposes.
// Properties of Material #1:
// No friction.
// Collides w/ terrain material.
// Zero elasticity and zero softness.
m_Model->setMaterial(Game::s_World->getAllMaterials()[1]);
// Avoid all rotations. Ever. >:(
Game::s_World->getUtils()->avoidRotationOnAllAxes(m_Model);
// No reason for this since we set the variable earlier, but
// just in case I move the option to the XML file I load from...
if(m_LockRotation)
m_Model->setRotationUpdate(false);
// Just for doublechecking's sake, we don't want any magical
// poof-through-the-walls models.
m_Model->setContinuousCollisionMode(true);
That loads the model, sets no rotation update on the Node, avoids rotation...
Next I have my movement code, which is as thus:
Code: Select all
void ObjModel::moveLateral(float multiplier) {
core::vector3df tmp = m_Model->getVelocity();
tmp.X = tmp.Z = 0;
tmp += m_Model->FRIgetDirectionPositionY(core::vector3df(multiplier,0,0));
m_Model->setVelocity(tmp);
}
void ObjModel::turn(float speed) {
m_Model->getNode()->setRotation(core::vector3df(0,m_Model->getNode()->getRotation().Y+speed,0));
}
moveLateral moves my model in a straight line along the arbitrary axis along which it faces, ie moves it in a straight line forward (or back if multiplier is negative).
turn, of course, turns the model's scene node, which in turn (ha, ha) will cause the newton body to turn. (I'm... really not sure how that works. But it does.)
Finally, and it may or may not have an effect, but I have an update function that's called each game loop:
Code: Select all
void ObjModel::__update(const float& dt) {
if(m_LockRotation) {
core::vector3df tmp;
tmp = m_Model->getNode()->getRotation();
tmp.Z = 0;
tmp.X = 0;
m_Model->setRotation(tmp);
}
}
It... probably does absolutely nothing, but I included it for the sake of completeness.
The variables should be pretty self-explanatory in naming, but if there're any questions, I'll answer them. It looks like almost everything is solved at this point - I'll probably finalize this and commit it to my SVN.
Thanks for all the help, guys. I'll leave this thread open and "unsolved" until we know everyone here has their questions and needs resolved. I'm happy to help with anything else, and if I have any more questions within the next day or two, I may post them here as well as long as they relate.