Qt irrlicht(鬼火)3D引擎 摄像机旋转问题
【摘要】
点击打开链接Irrlicht中的摄像有一个函数 setUpVector()
if (m_device != 0 ) { core::vector3df rotation(y,x,0.f); m_camera->setRotation(rotation); f32 v...
点击打开链接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";
}
文章来源: dreamlife.blog.csdn.net,作者:DreamLife.,版权归原作者所有,如需转载,请联系作者。
原文链接:dreamlife.blog.csdn.net/article/details/51863179
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)