球在傾斜平面上滾動 java libgdx (Ball rolling on an incline plane java libgdx)


問題描述

球在傾斜平面上滾動 java libgdx (Ball rolling on an incline plane java libgdx)

我正在嘗試編寫自己的物理程序(請不要使用 box2d 的答案),並且我想要一個球在它接觸的任何傾斜平面上滾動。我在物理學方面擁有豐富的經驗,但由於某種原因,我似乎無法在任何地方找到如何在任何地方進行編程。非常感謝任何有關如何解決此問題的幫助!


參考解法

方法 1:

Think geometrically!

First you need to find out if and which plane the ball touches. Create a vector from the balls position that points straight down. Find the nearest plane this vector intersects. This can be done with vector math, e.g. the basics you find in wiki: https://en.wikipedia.org/wiki/Line%E2%80%93plane_intersection

You now know the plane and you can calculate the distance between ball and plane intersection point. If the distance is <= balls radius, it touches. From there, calculate the planes slope and modify the balls movement vector accordingly (to your physics model).

方法 2:

From the very limited information you've given it looks like a duplicate of 3D libgdx rotation, for which you can find an example as well at https://gist.github.com/xoppa/3b841fb52f46e8cdec24

(by PookieDurandalXoppa)

參考文件

  1. Ball rolling on an incline plane java libgdx (CC BY‑SA 2.5/3.0/4.0)

#libgdx #java






相關問題

為什麼原生 libmpg123 在帶有 libgdx 的 android 上花費這麼長時間? (Why is native libmpg123 taking so long on android with libgdx?)

睡眠後重新加載應用程序 (Re-load the app after sleep)

獲取實際觸摸位置 LibGDX (Get actual touch position LibGDX)

LibGDX - 只有可拖動的運動 (LibGDX - only draggable movement)

無法解析符號“android” - 在使用 libgdx 在 Android 應用程序中實現 Google Analytics 時 (Cannot resolve symbol 'android' - While implementing Google Analytics in Android App with libgdx)

如何從矩形數組中刪除隨機矩形? (How to remove random rectangle from rectangle array?)

球在傾斜平面上滾動 java libgdx (Ball rolling on an incline plane java libgdx)

libgdx - Intellij 類未找到異常? (libgdx - Intellij class not found exception?)

GL_COLOR_BUFFER_BIT 再生哪個內存? (GL_COLOR_BUFFER_BIT regenerating which memory?)

libGDX - 更改屏幕後的黑色按鈕和文本 (libGDX - Black buttons and text after changing screen)

帶有 9patch 的 LibGdx 標籤背景 (LibGdx label background with 9patch)

如何從平鋪中刪除對象? (How do I remove an object from tiled?)







留言討論