亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

LibGDX 相機旋轉問題

LibGDX 相機旋轉問題

郎朗坤 2021-07-27 08:31:14
我正在嘗試圍繞我的模型旋轉我的透視相機。模型位于中心 (0,0,0) 點。這是我的旋轉相機方法:private void rotateCameraAroundModel() {    camera.position.set(0,0,0);    camera.position.rotate(Vector3.Y, 5);    camera.position.add(0f, 0f, 200f);    camera.up.set(Vector3.Y);    camera.lookAt(0,0,0);    camera.update();}我試圖去中心,旋轉 5 度,然后返回到相同的距離。但是,旋轉似乎不起作用,我不知道為什么,非常感謝任何幫助。
查看完整描述

1 回答

?
婷婷同學_

TA貢獻1844條經驗 獲得超8個贊

我想到了 :)


private void rotateCameraAroundModel(float angle) {

    camera.position.set(centreX, centerY, centerZ);

    camera.rotate(Vector3.Y, (float) Math.toDegrees(angle)); // Rotate around Y axis by angle in degrees

    float x = (float) (centerX + radius * (Math.sin(totalPhi)));

    float z =  (float) (centerZ + radius * (Math.cos(totalPhi)));

    camera.position.add(x, 0f, z); //Move back out 2m using pythagorean theorem to calculate the position on the circle

    camera.up.set(Vector3.Y);

    camera.lookAt(0, 0, 0);

    camera.update();

}

所以我需要在旋轉時計算圓上的新位置,我使用了一些基本的三角函數


查看完整回答
反對 回復 2021-08-04
  • 1 回答
  • 0 關注
  • 166 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號