点击打开链接Irrlicht中的摄像有一个函数 setUpVector()
if (m_device != 0 ) { core::vector3df rotation(y,x,0.f); m_camera->setRotation(rotation); f32 viewlength = m_camera->getTarget().getLength(); f32 angle = z*2*Pi/360.0; m_camera->setUpVector(vector3df(viewlength*cos(angle),viewlength*sin(angle),0.0f)); }
具体用法参考上面
还有一个方法旋转摄像机
是控制另一轴的旋转
void Scene_3D::slotUSBENGINE(f32 x, f32 y, f32 z) { core::vector3df pos = m_camera->getPosition(); core::vector3df target = (m_camera->getTarget() - m_camera->getAbsolutePosition()); core::vector3df relativeRotation = target.getHorizontalAngle(); target.set(0,0, core::max_(1.f, pos.getLength())); core::vector3df movedir = target; core::matrix4 mat; mat.setRotationDegrees(core::vector3df(relativeRotation.X, relativeRotation.Y, 0)); mat.transformVect(target); movedir = target; movedir.normalize(); pos += movedir*0.5f*(x/5); core::vector3df strafevect = target; strafevect = strafevect.crossProduct(m_camera->getUpVector()); m_camera->setPosition(pos); target += pos; m_camera->setTarget(target); // qDebug()<<"hjsdfjhkgsdfgjhksdfajhgksadfjhklsdfahjklsdfakhjlsakjhlsdfhkjsdfajhklsafkjhlsfajhklsfdahjklfsdahjklfsdahjklsfjkhlsd"; }