Esempio n. 1
0
//New matrix is made out of -1 * position and -1 * rotation to make it seem like
//the camera is actully moving rather than the scene moving around the camera.
void Camera::update(const float deltatime) 
{
  glm::mat4 newtrans(1.0);
  
  newtrans = glm::rotate(newtrans, -m_rotation[0], glm::vec3(1.0, 0.0, 0.0));
  newtrans = glm::rotate(newtrans, -m_rotation[1], glm::vec3(0.0, 1.0, 0.0));
  newtrans = glm::rotate(newtrans, -m_rotation[2], glm::vec3(0.0, 0.0, 1.0));
  newtrans = glm::translate(newtrans, -m_position);
  m_transformation = newtrans;
  glLoadMatrixf(glm::value_ptr(m_transformation));
}
Esempio n. 2
0
void BulletObject::MoveAction::step(float dt) {
    if (done()) return;
    stepTime(dt);
    const float a = fracElapsed();

    // linear interpolation of pos
    btVector3 newpos = (1-a)*start.getOrigin() + a*end.getOrigin();
    btQuaternion newrot = start.getRotation().slerp(end.getRotation(), a);
    btTransform newtrans(newrot, newpos);
    obj->motionState->setWorldTransform(newtrans);
}