如何解决Lua 鼠标拖动四元数
我正在寻找有关我正在制作的这个 lua 脚本的一些帮助。我想使用四元数根据鼠标移动/拖动来旋转对象。我将这个库用于我的 Quaternion https://github.com/topameng/CsToLua/ 。我已经让物体移动了,但所有的旋转都搞砸了,这里有一个链接,指向我到目前为止所拥有的视频http://img.bcdojrp.net/videos/uploads/2021-03-17%2003-58-07_Trim.mp4 我花了几个小时查看这个,但找不到要改变的内容.. . 任何帮助表示赞赏,谢谢!
function GetCursor()
local sx,sy = GetActiveScreenResolution()
local cx,cy = GetNuiCursorPosition()
local cx,cy = (cx / sx) + 0.008,(cy / sy) + 0.027
return cx,cy
end
if dragging then
-- this is the screen position
local intx,inty = GetCursor()
local deltaMove = {
['x'] = intx-previousMousePosition.x,['y'] = inty-previousMousePosition.y
}
local deltaRotationQuaternion = Quaternion.Euler(deltaMove.y * 40,deltaMove.x * 40,0)
local x,y,z,w = GetEntityQuaternion(curObject)
local quatNew = deltaRotationQuaternion.__mul(Quaternion.New(x,w),deltaRotationQuaternion)
local valX,valY,valZ,valW = quatNew.x,quatNew.y,quatNew.z,quatNew.w
SetEntityQuaternion(curObject,valX,valW)
--cube.quaternion.multiplyQuaternions(deltaRotationQuaternion,cube.quaternion);
previousMousePosition.x = intx
previousMousePosition.y = inty
else
previousMousePosition = {
['x'] = 0,['y'] = 0
}
end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。