You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since there's no forum for Ammo.js I'm posting a help question here.
I'm creating yet another dice roller app using many different shaped dice. After a die has stopped rolling, meaning its Linear Velocity and Angular Velocity have dropped below a certain threshold, I'm trying to calculate which face is up. I've attempted to do this with raycasting, but it does not work on the backfaces of my convexHulls. I don't want to rely on assuming the dice are laying flat either, because sometimes they are tilted when they finish.
I've seen a few tutorials for six sided dice, but I have use cases for D&D game dice which makes things more complicated.
What I think I need is the underlying geometry of the convexHull (or collisionShape). Then I could calculate which face has the greatest "Y" value. I have no idea how to do this.
Alternatively, I've looked into setting a vector for each face of a die, then calculating the dot value based on the rigidBody transform, but I was not able to get this working well.
Please help me find a simple way to calculate the top most face of a collider. This is not just for six sided dice, and sometimes the dice are tilted or stacked up when they finish.
The text was updated successfully, but these errors were encountered:
"Alternatively, I've looked into setting a vector for each face of a die, then calculating the dot value based on the rigidBody transform, but I was not able to get this working well."
Why are you relying on the physics sim info for this? Use face normals from the mesh data and calculate which face is the "most up" based on the dot with the up vector.
Since there's no forum for Ammo.js I'm posting a help question here.
There is an option to hang a ray on each face, which will check the point with whom it collided. The length of the ray can be adjusted. The ray allows you to get both the object with whom it intersected, the normal, the face. https://jsfiddle.net/suddenly4/xp9kc056/1/
There is an option to get the point of contact of two objects using
new Ammo.ConcreteContactResultCallback()
You can also get the normal, the position of the point
There is an option to hang a ghost object on each face and query it through a callback about whether it is in contact with the plane
There is an option to measure the angle of the cube itself, like an internal gyroscope of its local / world angle in relation to the coordinate grid. Thus, get the face geometrically - You don't even need physics for this
Since there's no forum for Ammo.js I'm posting a help question here.
I'm creating yet another dice roller app using many different shaped dice. After a die has stopped rolling, meaning its Linear Velocity and Angular Velocity have dropped below a certain threshold, I'm trying to calculate which face is up. I've attempted to do this with raycasting, but it does not work on the backfaces of my convexHulls. I don't want to rely on assuming the dice are laying flat either, because sometimes they are tilted when they finish.
I've seen a few tutorials for six sided dice, but I have use cases for D&D game dice which makes things more complicated.
What I think I need is the underlying geometry of the convexHull (or collisionShape). Then I could calculate which face has the greatest "Y" value. I have no idea how to do this.
Alternatively, I've looked into setting a vector for each face of a die, then calculating the dot value based on the rigidBody transform, but I was not able to get this working well.
Please help me find a simple way to calculate the top most face of a collider. This is not just for six sided dice, and sometimes the dice are tilted or stacked up when they finish.
The text was updated successfully, but these errors were encountered: