Questions in topic: "tensor"
http://answers.unity.com/questions/topics/single/950.html
The latest questions for the topic "tensor"How to calculate inertia tensor and tensor rotation manually
http://answers.unity.com/questions/1484654/how-to-calculate-inertia-tensor-and-tensor-rotatio.html
I'm trying to set the moment of inertia of a compound object (one object with a Rigidbody and multiple child objects with simple colliders). I need to set the `Rigidbody.inertiaTensor` and `Rigidbody.inertiaTensorRotation` manually because the child objects have different material densities.
<br>
I have calculated the inertia tensors for each child object around its center of mass as well as the center of mass of the parent object. I believe I can calculate the moment of inertia around the parent center of mass by adding all the individual moments of inertia of the child objects and then adding the moments of inertia of the children as point masses around the parent center of mass (might be wrong on this?).
<br>
What I don't understand is how to translate this into this Vector3 inertia tensor and Quaternion tensor rotation that Unity uses; the tensor rotation in particular I don't really understand what it represents. If I had the final moment of inertia of the compound object as a Matrix4x4, could I turn it into this Vector3 + Quaternion system? Is it possible to do these calculations while staying in the Vector3 + Quaternion space?
<br>
If nothing else, I want to know how the Rigidbody.inertiaTensorRotation is calculated and what it actually represents. The documentation says that "the inertia tensor is rotated by the `inertiaTensorRotation`", but I can't seem to find a relationship between the child transform rotation and it's effect on the `inertiaTensorRotation`. I've tried visualizing it by making a parent object with a Rigidbody with one child 1x1x1m cube and drawing the `inertiaTensor` vector rotated by the `inertiaTensorRotation`, but it just seems to jump around wildly as I slowly rotate the different axes of the box. The only pattern I've noticed is that if I only rotate 1 axis and all the others are 0, then the `inertiaTensorRotation == Quaternion.identity`
![alt text][1]
[1]: /storage/temp/113586-tensor.jpg
Appreciate any help with this.physicsrigidbody physicsinertiatensorSat, 24 Mar 2018 07:25:22 GMTPedroCoriAGHow do i create a SVM in unity using tensorflow?
http://answers.unity.com/questions/1454196/how-do-i-create-a-svm-in-unity-using-tensorflow.html
I created an AI car in unity and I want my car to be able to avoid obstacles.
To do this i recorded some data which stores information about the scenario my car faced and my reaction to that (steering, brake and throttle input).
Then i am trying to feed this data to train a SVM model and generate a prediction for the AI car so that it can avoid obstacles, just like I did.
In fact my friend created a SVM in python for this, and the predictions were quite accurate. But, I don't have any idea of doing this in Unity and generate real time predictions.
Any ideas on how i can achieve this in Unity?
I have Tensorflow Sharp library and Unity ML agents integrated in Unity.
However I have no idea where do I start?
Is it possible to create an entire SVM, train it and generate predictions in one or more C# scripts using the Tensorflow sharp library?
Please Help.carlearningmachinebotstensorSat, 13 Jan 2018 19:31:03 GMTAnupamSahuGet inertiaTensor of point masses
http://answers.unity.com/questions/1447715/get-inertiatensor-of-point-masses.html
How do you get the inertialTensor and inertialRotation for a bunch of point masses in unity. The point masses are rigid bodies connected by fixed joints. The entire object rotates.
I had a physicist friend help me figure out the basic formula.
He said to take the angularVelocity vector for the main object and the vector from the center of mass of the main object to each point mass.
Then find the sin projection of the point mass vector onto the angularVelocity vector which will give me a vector R. The magnitude of R will be r in the formula
iterate through all point masses and add them together
Inertia += .5* point mass*r^2;
But this gives me a scalar and unity wants a Vector3 for the inertiaTensor so I'm confused because he says now the problem is non-trivial and would require computing the projections on all axis and we don't know if unity already does those calculations. The reason I want the inertiaTensor and inertialRotation is to use the answer here to rotate an object with physics.
[https://answers.unity.com/questions/48836/determining-the-torque-needed-to-rotate-an-object.html?page=1&pageSize=5&sort=votes][1]
[1]: https://answers.unity.com/questions/48836/determining-the-torque-needed-to-rotate-an-object.html?page=1&pageSize=5&sort=votesrotation axisinertiatensorThu, 28 Dec 2017 19:57:26 GMTdansavCompute the torque needed to rotate an object at a constant rate
http://answers.unity.com/questions/1413778/compute-the-torque-needed-to-rotate-an-object-at-a.html
I want to rotate an object around an axe at a constant rate without caring about its mass.
I want to use physics to do it.
Unity allow me to apply a torque which will be considered as a *velocity changement* (so the mass won't be taken into account) though the [function][1] :
AddTorque(myTorque, ForceMode.VelocityChange);
It appears that my questions already has an answer in this [post][2], but I don't fully understand the answer. Because the post is pretty old, nobody answer anymore to any question.
Here are my questions about the post:
- Why unity multiply the inertia tensor by the InertiaTensorRotation (what physics meaning the InertiaTensorRotation has) ?
- Why does he speak about a *diagonal space* ?
- May you explain me in plain english the two lines where he computes the torque ?
[1]: https://docs.unity3d.com/ScriptReference/Rigidbody.AddTorque.html
[2]: http://answers.unity3d.com/questions/48836/determining-the-torque-needed-to-rotate-an-object.html?childToView=1413341#comment-1413341rotationphysicstorqueinertiatensorFri, 29 Sep 2017 13:44:46 GMTzuraneurinertiaTensor stopping automatic rotation
http://answers.unity.com/questions/999751/inertiatensor-stopping-automatic-rotation.html
I'm developing a top down racing game, and the collisions were all weird and un-natural ([vid here][1]), it was suggested to me that I use inertiaTensor to fix this issue, so now I'm setting the following in Start():
goRigidbody.inertiaTensor = new Vector3(1e5f, 1e5f, 1e5f);
This makes the collisions work perfectly, I couldn't be happier with how a car now acts when colliding with anything else, however, the car no longer rotates when going up/down an incline.
![alt text][2]
The car still rotates on the Y-axis, when I press a/d to turn the car, but won't automatically rotate on the X or Z-axis when going up/ down an incline.
I've been googling around to try and find a solution, but have so far come up with nothing. The rigidbody doesn't have any rotations or positions frozen, is anyone able to help solve this little problem?
[1]: https://youtu.be/75jLBQgOmfA
[2]: /storage/temp/49425-carnorotate.pngrotationcarracinginertiatensorFri, 03 Jul 2015 14:11:54 GMTCarwashhRotational energy formula
http://answers.unity.com/questions/963909/rotational-energy-formula.html
Need to calculate a kinetic rotational energy of game object (for a physics educational demonstration).
As known, kinetic calculation formula is:
![Energy][1]
The question concern only realization of rotational part:
We have rigid body angular velocity (*w* in formula), inertia tensor (*Jc*). But also we have quaternion of [inertia tensor rotation][2].
So the question: is the code to calculate rotational kinetic energy correct?
float rigidbodyEnergy(Vector3 linVel, Vector3 angVel, Rigidbody rb)
{
Quaternion itr = rb.inertiaTensorRotation;
return Vector3.Dot(angVel,
itr * Vector3.Scale(rb.inertiaTensor, Quaternion.Inverse(itr) * angVel))/2f
+linVel.sqrMagnitude*rb.mass/2f;
}
[1]: /storage/temp/46149-energy1.jpg
[2]: http://docs.unity3d.com/ScriptReference/Rigidbody-inertiaTensorRotation.htmlrotationmovementenergydynamicstensorMon, 11 May 2015 06:16:09 GMTSortestCalculating the rotational acceleration from torque
http://answers.unity.com/questions/821833/calculating-the-rotational-acceleration-from-torqu.html
I'm trying to write a function that takes a Vector3 of torque and calculates the resulting radial acceleration in radians per second per second. I understand that I'll need to use the `rigidbody.inertiaTensor` and `rigidbody.inertiaTensorRotation` to do this, but I don't know how they work. Does anybody know how to do this? I would like it to be as accurate as possible. I imagine the signature of the function would be something like the below.
public static Vector3 TorqueToAcceleration(Vector3 torque, Vector3 inertialTensor, Quaternion inertialTensorRotation, float rigidbodyMass) {
// Magic happens here
}rotationaccelerationtorquecalculatetensorSat, 01 Nov 2014 03:33:15 GMTPeterReevesWhy am I being asked to change the mesh geometry or supply a tensor manually?
http://answers.unity.com/questions/780168/why-am-i-being-asked-to-change-the-mesh-geometry-o.html
I purchased the shopping mall scene from the asset store and used it in my game.
Next I added the cartoon nerd from the asset store to the same scene.
At first the character fell through the shopping mall.
So I added a RigidBody component to the shopping mall game object.
When I try to preview my game in the Unity3D editor, I get the following:
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
Why?inertiatensorThu, 28 Aug 2014 03:41:53 GMTDerrickLauDisable inertia tensor calculations on rigidbody?
http://answers.unity.com/questions/754244/disable-inertia-tensor-calculations-on-rigidbody.html
I have a scene containing a lot of quads with mesh colliders. I need to apply a rigidbody to each of them to avoid glitchy physics behaviour if the player collides with them. All of the rigidbodys are set as kinematic. However, it still sends the error message "Compute mesh inertia tensor failed [...] Please change mesh geometry or supply a tensor manually!"
Setting the rigidbody.inertiaTensor manually doesn't change anything, and changing all mesh colliders in the game to box colliders would take a lot of time. Do I just have to live with the error messages?collisionphysicsrigidbodyinertiatensorTue, 22 Jul 2014 18:35:03 GMTTheAsurohow to get two script edited mesh colliders to collide.
http://answers.unity.com/questions/734214/how-to-get-two-script-edited-mesh-colliders-to-col.html
I know this is asked a lot, but none of the other answers fixed my problem.
this is the script of the terrain:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class PolygonGenerator : MonoBehaviour {
public List<Vector3> newVertices = new List<Vector3>();
public List<int> newTriangles = new List<int>();
public List<Vector2> newUV = new List<Vector2>();
public List<Vector3> colVertices = new List<Vector3>();
public List<int> colTriangles = new List<int>();
private int colCount;
private Mesh mesh;
private MeshCollider col;
private float tUnit = 0.25f;
public Vector2 tStone = new Vector2 (0f,0f);
public Vector2 tGrass = new Vector2 (0f,.5f);
public byte[,] blocks;
private int squareCount;
public bool update=false;
// Use this for initialization
void Start () {
mesh = GetComponent<MeshFilter> ().mesh;
col = GetComponent<MeshCollider> ();
GenTerrain();
BuildMesh();
UpdateMesh();
}
void Update(){
if(update){
BuildMesh();
UpdateMesh();
update=false;
}
}
int NoiseInt (int x, int y, float scale, float mag, float exp){
return (int) (Mathf.Pow ((Mathf.PerlinNoise(x/scale,y/scale)*mag),(exp) ));
}
void GenTerrain(){
blocks=new byte[96,128];
for(int px=0;px<blocks.GetLength(0);px++){
int stone= NoiseInt(px,0, 80,15,1);
stone+= NoiseInt(px,0, 50,30,1);
stone+= NoiseInt(px,0, 10,10,1);
stone+=75;
int dirt = NoiseInt(px,0, 100f,35,1);
dirt+= NoiseInt(px,100, 50,30,1);
dirt+=75;
for(int py=0;py<blocks.GetLength(1);py++){
if(py<stone){
blocks[px, py]=1;
if(NoiseInt(px,py,12,16,1)>10){ //dirt spots
blocks[px,py]=2;
}
if(NoiseInt(px,py*2,16,14,1)>10){ //Caves
blocks[px,py]=0;
}
} else if(py<dirt) {
blocks[px,py]=2;
}
}
}
}
void BuildMesh(){
for(int px=0;px<blocks.GetLength(0);px++){
for(int py=0;py<blocks.GetLength(1);py++){
if(blocks[px,py]!=0){
GenCollider(px,py);
if(blocks[px,py]==1){
GenSquare(px,py,tStone);
} else if(blocks[px,py]==2){
GenSquare(px,py,tGrass);
}
}
}
}
}
byte Block (int x, int y){
if(x==-1 || x==blocks.GetLength(0) || y==-1 || y==blocks.GetLength(1)){
return (byte)1;
}
return blocks[x,y];
}
void GenCollider(int x, int y){
//Top
if(Block(x,y+1)==0){
colVertices.Add( new Vector3 (x , y , 1));
colVertices.Add( new Vector3 (x + 1 , y , 1));
colVertices.Add( new Vector3 (x + 1 , y , 0 ));
colVertices.Add( new Vector3 (x , y , 0 ));
ColliderTriangles();
colCount++;
}
//bot
if(Block(x,y-1)==0){
colVertices.Add( new Vector3 (x , y -1 , 0));
colVertices.Add( new Vector3 (x + 1 , y -1 , 0));
colVertices.Add( new Vector3 (x + 1 , y -1 , 1 ));
colVertices.Add( new Vector3 (x , y -1 , 1 ));
ColliderTriangles();
colCount++;
}
//left
if(Block(x-1,y)==0){
colVertices.Add( new Vector3 (x , y -1 , 1));
colVertices.Add( new Vector3 (x , y , 1));
colVertices.Add( new Vector3 (x , y , 0 ));
colVertices.Add( new Vector3 (x , y -1 , 0 ));
ColliderTriangles();
colCount++;
}
//right
if(Block(x+1,y)==0){
colVertices.Add( new Vector3 (x +1 , y , 1));
colVertices.Add( new Vector3 (x +1 , y -1 , 1));
colVertices.Add( new Vector3 (x +1 , y -1 , 0 ));
colVertices.Add( new Vector3 (x +1 , y , 0 ));
ColliderTriangles();
colCount++;
}
}
void ColliderTriangles(){
colTriangles.Add(colCount*4);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+3);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+2);
colTriangles.Add((colCount*4)+3);
}
void GenSquare(int x, int y, Vector2 texture){
newVertices.Add( new Vector3 (x , y , 0 ));
newVertices.Add( new Vector3 (x + 1 , y , 0 ));
newVertices.Add( new Vector3 (x + 1 , y-1 , 0 ));
newVertices.Add( new Vector3 (x , y-1 , 0 ));
newTriangles.Add(squareCount*4);
newTriangles.Add((squareCount*4)+1);
newTriangles.Add((squareCount*4)+3);
newTriangles.Add((squareCount*4)+1);
newTriangles.Add((squareCount*4)+2);
newTriangles.Add((squareCount*4)+3);
newUV.Add(new Vector2 (tUnit * texture.x, tUnit * texture.y + tUnit));
newUV.Add(new Vector2 (tUnit * texture.x + tUnit, tUnit * texture.y + tUnit));
newUV.Add(new Vector2 (tUnit * texture.x + tUnit, tUnit * texture.y));
newUV.Add(new Vector2 (tUnit * texture.x, tUnit * texture.y));
squareCount++;
}
void UpdateMesh () {
mesh.Clear ();
mesh.vertices = newVertices.ToArray();
mesh.triangles = newTriangles.ToArray();
mesh.uv = newUV.ToArray();
mesh.Optimize ();
mesh.RecalculateNormals ();
newVertices.Clear();
newTriangles.Clear();
newUV.Clear();
squareCount=0;
Mesh newMesh = new Mesh();
newMesh.vertices = colVertices.ToArray();
newMesh.triangles = colTriangles.ToArray();
col.sharedMesh= newMesh;
colVertices.Clear();
colTriangles.Clear();
colCount=0;
}
}
and this is the script for the object that needs to collide with the terrain:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class vehicle : MonoBehaviour {
public List<Vector3> newVertices = new List<Vector3>();
public List<int> newTriangles = new List<int>();
public List<Vector2> newUV = new List<Vector2>();
public List<Vector3> colVertices = new List<Vector3>();
public List<int> colTriangles = new List<int>();
private int colCount;
private Mesh mesh;
private MeshCollider col;
private float tUnit = 0.25f;
public Vector2 tStone = new Vector2 (0f,0f);
public Vector2 tGrass = new Vector2 (0f,.5f);
public byte[,] blocks;
private int squareCount;
public bool update=false;
// Use this for initialization
void Start () {
mesh = GetComponent<MeshFilter> ().mesh;
col = GetComponent<MeshCollider> ();
GenTerrain();
BuildMesh();
UpdateMesh();
rigidbody.inertiaTensor = Vector3.one;
rigidbody.inertiaTensorRotation = Quaternion.identity;
}
void Update(){
if(update){
BuildMesh();
UpdateMesh();
update=false;
}
}
int NoiseInt (int x, int y, float scale, float mag, float exp){
return (int) (Mathf.Pow ((Mathf.PerlinNoise(x/scale,y/scale)*mag),(exp) ));
}
void GenTerrain(){
blocks=new byte[1,1];
for(int px=0;px<blocks.GetLength(0);px++){
int stone= NoiseInt(px,0, 80,15,1);
stone+= NoiseInt(px,0, 50,30,1);
stone+= NoiseInt(px,0, 10,10,1);
stone+=75;
int dirt = NoiseInt(px,0, 100f,35,1);
dirt+= NoiseInt(px,100, 50,30,1);
dirt+=75;
for(int py=0;py<blocks.GetLength(1);py++){
if(py<stone){
blocks[px, py]=1;
if(NoiseInt(px,py,12,16,1)>10){ //dirt spots
blocks[px,py]=2;
}
if(NoiseInt(px,py*2,16,14,1)>10){ //Caves
blocks[px,py]=0;
}
} else if(py<dirt) {
blocks[px,py]=2;
}
}
}
}
void BuildMesh(){
for(int px=0;px<blocks.GetLength(0);px++){
for(int py=0;py<blocks.GetLength(1);py++){
if(blocks[px,py]!=0){
GenCollider(px,py);
if(blocks[px,py]==1){
GenSquare(px,py,tStone);
} else if(blocks[px,py]==2){
GenSquare(px,py,tGrass);
}
}
}
}
}
byte Block (int x, int y){
if(x==-1 || x==blocks.GetLength(0) || y==-1 || y==blocks.GetLength(1)){
return (byte)1;
}
return blocks[x,y];
}
void GenCollider(int x, int y){
//Top
if(Block(x,y+1) ==1){
colVertices.Add( new Vector3 (x , y , 1));
colVertices.Add( new Vector3 (x + 1 , y , 1));
colVertices.Add( new Vector3 (x + 1 , y , 0 ));
colVertices.Add( new Vector3 (x , y , 0 ));
colVertices.Add( new Vector3 (x , y-1 , 1));
colVertices.Add( new Vector3 (x + 1 , y-1 , 1));
colVertices.Add( new Vector3 (x + 1 , y-1 , 0 ));
colVertices.Add( new Vector3 (x , y-1 , 0 ));
ColliderTriangles();
colCount++;
}
//bot
if(Block(x,y-1)==0){
colVertices.Add( new Vector3 (x , y -1 , 0));
colVertices.Add( new Vector3 (x + 1 , y -1 , 0));
colVertices.Add( new Vector3 (x + 1 , y -1 , 1 ));
colVertices.Add( new Vector3 (x , y -1 , 1 ));
ColliderTriangles();
colCount++;
}
//left
if(Block(x-1,y)==0){
colVertices.Add( new Vector3 (x , y -1 , 1));
colVertices.Add( new Vector3 (x , y , 1));
colVertices.Add( new Vector3 (x , y , 0 ));
colVertices.Add( new Vector3 (x , y -1 , 0 ));
ColliderTriangles();
colCount++;
}
//right
if(Block(x+1,y)==0){
colVertices.Add( new Vector3 (x +1 , y , 1));
colVertices.Add( new Vector3 (x +1 , y -1 , 1));
colVertices.Add( new Vector3 (x +1 , y -1 , 0 ));
colVertices.Add( new Vector3 (x +1 , y , 0 ));
ColliderTriangles();
colCount++;
}
}
void ColliderTriangles(){
colTriangles.Add(colCount*4);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+3);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+2);
colTriangles.Add((colCount*4)+3);
colTriangles.Add((colCount*4)+0);
colTriangles.Add((colCount*4)+3);
colTriangles.Add((colCount*4)+7);
colTriangles.Add((colCount*4)+0);
colTriangles.Add((colCount*4)+4);
colTriangles.Add((colCount*4)+7);
colTriangles.Add((colCount*4)+4);
colTriangles.Add((colCount*4)+6);
colTriangles.Add((colCount*4)+7);
colTriangles.Add((colCount*4)+4);
colTriangles.Add((colCount*4)+5);
colTriangles.Add((colCount*4)+6);
colTriangles.Add((colCount*4)+0);
colTriangles.Add((colCount*4)+4);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+4);
colTriangles.Add((colCount*4)+5);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+5);
colTriangles.Add((colCount*4)+6);
colTriangles.Add((colCount*4)+2);
colTriangles.Add((colCount*4)+5);
colTriangles.Add((colCount*4)+1);
colTriangles.Add((colCount*4)+2);
colTriangles.Add((colCount*4)+6);
colTriangles.Add((colCount*4)+3);
colTriangles.Add((colCount*4)+2);
colTriangles.Add((colCount*4)+6);
colTriangles.Add((colCount*4)+3);
colTriangles.Add((colCount*4)+7);
}
void GenSquare(int x, int y, Vector2 texture){
newVertices.Add( new Vector3 (x , y , 0 ));
newVertices.Add( new Vector3 (x + 1 , y , 0 ));
newVertices.Add( new Vector3 (x + 1 , y-1 , 0 ));
newVertices.Add( new Vector3 (x , y-1 , 0 ));
newTriangles.Add(squareCount*4);
newTriangles.Add((squareCount*4)+1);
newTriangles.Add((squareCount*4)+3);
newTriangles.Add((squareCount*4)+1);
newTriangles.Add((squareCount*4)+2);
newTriangles.Add((squareCount*4)+3);
newUV.Add(new Vector2 (tUnit * texture.x, tUnit * texture.y + tUnit));
newUV.Add(new Vector2 (tUnit * texture.x + tUnit, tUnit * texture.y + tUnit));
newUV.Add(new Vector2 (tUnit * texture.x + tUnit, tUnit * texture.y));
newUV.Add(new Vector2 (tUnit * texture.x, tUnit * texture.y));
squareCount++;
}
void UpdateMesh () {
mesh.Clear ();
mesh.vertices = newVertices.ToArray();
mesh.triangles = newTriangles.ToArray();
mesh.uv = newUV.ToArray();
mesh.Optimize ();
mesh.RecalculateNormals ();
newVertices.Clear();
newTriangles.Clear();
newUV.Clear();
squareCount=0;
Mesh newMesh = new Mesh();
newMesh.vertices = colVertices.ToArray();
newMesh.triangles = colTriangles.ToArray();
col.sharedMesh= newMesh;
colVertices.Clear();
colTriangles.Clear();
colCount=0;
}
}
Every time i run the game, it gives me the error:
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
and:
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
UnityEngine.MeshCollider:set_sharedMesh(Mesh)
vehicle:UpdateMesh() (at Assets/scripts/vehicle.cs:269)
vehicle:Start() (at Assets/scripts/vehicle.cs:35)
this is important since its the core feature of the game.
edit: I did try making the colliders for each box a rectangular prism, but it didn't fix the error:(meshcolliderinertiatensorTue, 24 Jun 2014 17:50:27 GMTcowcatchererExcluding a collider from tensor calculations?
http://answers.unity.com/questions/630089/excluding-a-collider-from-tensor-calculations.html
I have a rigidbody with several child objects which have box and mesh colliders. Is it possible to exclude one object (collider) from the inertia tensor calculations?
Also, when are tensor calculations done? On initialization? When child objects are added/removed/edited?rigidbodycolliderinertiatensorSun, 02 Feb 2014 00:56:19 GMTTol'SathaHow can I detect Actors which will cause the "Compute mesh inertia tensor failed!" error?
http://answers.unity.com/questions/419079/how-can-i-detect-actors-which-will-cause-the-compu.html
Our project has a few of these: Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
I've read various threads, like this one: http://forum.unity3d.com/threads/8342-Error-unknown-from-quot-Actor-updateMassFromShapes-quot
Or this: http://answers.unity3d.com/questions/7841/what-does-the-compute-mesh-inertia-tensor-failed-e.html
...which discuss how to fix the problem. However, I can't even locate the objects generating the error (we have thousands of objects in our scene).
I'm trying to write an Editor script which will detect objects with the properties that trigger this, but no matter what I try I still get the error.
I've tried: MeshColliders with a mesh where extents are 0 in one dimension, MeshColliders lacking a mesh, non-convex MeshColliders with a RigidBody attached, MeshColliders with RigidBodies that have an inertia tensor of magnitude 0, and RigidBodies that have inertia tensors of 1.0 in all dimensions (it seemed like MeshColliders with missing meshes generated (1, 1, 1) inertia tensors, so I thought that might be the default).
Anyone have any more suggestions for me?
Thanks!rigidbodyinertiatensorMon, 18 Mar 2013 04:27:10 GMTJohnnemannSetting the tensor manually
http://answers.unity.com/questions/402411/setting-the-tensor-manually.html
This error has been annoying me for a very long time, and I can not find a proper answer to it. It is the really annoying error:
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
UnityEngine.MeshCollider:set_sharedMesh(Mesh)
A lot of people are saying to turn the mesh collider into a box collider, but that is not a possibility here. So, I try and do what it suggests right before the line that is throwing this error.
//This updates the collisionMesh based on the animations and what not
UpdateMesh();
// not sure why this is necessary, but it is
meshCollider.sharedMesh = null;
//The meshRigidBody is the meshCollider.rigidBody
meshRigidBody.inertiaTensor = Vector3.zero;
meshRigidBody.inertiaTensorRotation = Quaternion.identity;
// set the collider mesh.
// THIS is the line that is throwing the error.
meshCollider.sharedMesh = Instantiate(collisionMesh) as Mesh;
Yet that does absolutely nothing. How am I suppose to set the tensor manually?????????? (Note: I don't even need the physics that is going on with the tensor stuff, but we need a RigidBody)tensorTue, 19 Feb 2013 17:47:34 GMTDoctorWhyHow do I programmatically Combine Inertia Tensors?
http://answers.unity.com/questions/398353/how-do-i-programmatically-combine-inertia-tensors.html
Hello!
I'm making a complex compound "ship" that I'm trying to simulate with a certain level of accuracy. The ship maneuvers in an atmospheric zero-G environment and is maneuvered through thrusters and aerodynamic control surfaces.
Ultimately I want the ship to handle as if it were the sum of its parts. In other words, the overall center of gravity and moment of inertia should be relative to the placement, size, and mass of each of the individual parts of the ship. Generator, engine, cockpit, fuel tanks, frame parts, etc.
Now, in Unity, I realize you can have multiple colliders as children of a rigidbody and Unity automatically calculates the COG and InertiaTensor for the rigidbody based on all the colliders, but with one major drawback. It assumes that all the colliders have exactly the same density. It spreads all the mass of the rigidbody out evenly across the combined volumes of all the colliders. As a result, something like an empty carbon fiber cockpit would way as much as an engine of the same size, made entirely of metal.
One solution that I'm using right now is to have a bunch of rigidbodies connected by fixed joints, but this is less than optimal in many ways (especially when you figure networking into the mix)
The only solution I can think of is to manually figure the inertia tensor myself, but I'm having one major problem:
All of the textbooks and documents and, well, everything that I can find online everywhere speaks of inertia tensors as a 3x3 array, but Unity describes them as a combination of a vector and a Quaternion rotation! Waugh!
Anyone have a clue on this? Either on how to translate the vector+rotation format into a matrix and then back again, or how to do the math using the existing structure?rigidbodyinertiatensorWed, 13 Feb 2013 04:15:20 GMTTreschWierd Internal Physics problem
http://answers.unity.com/questions/329434/wierd-internal-physics-problem.html
i have a project which was working fine until i did something i don't even know what, and it started giving me this annoying error:
Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!
it still works fine with the error but i would like to know what's wrong with it because it's referring me one of the engines scripts called 'NpActor.cpp at line:134' so it seems like something i shouldn't dismiss. can someone please tell me whats going onphysicsrigidbodyinertiatensorMon, 08 Oct 2012 16:03:02 GMTvzdaemonUnderstanding an error message.
http://answers.unity.com/questions/56013/understanding-an-error-message.html
<p>Hello, I'm getting an error message every time I hit play. It still allows me to run my game but I'd like to fix it. </p>
<blockquote>
<p>Error Message : Actor::updateMassFromShapes: Compute mesh inertia tensor failed for one of the actor's mesh shapes! Please change mesh geometry or supply a tensor manually!</p>
</blockquote>
<p>any ideas would be great, Thanks</p>errormeshtensorSat, 02 Apr 2011 13:53:11 GMTThumbStormWhat does the "compute mesh inertia tensor failed" error mean?
http://answers.unity.com/questions/7841/what-does-the-compute-mesh-inertia-tensor-failed-e.html
<p>I have a simple "third person cam" space shooter using a GameObject which contains a valid 3D ship mesh, and various planes used for effects (engine glow and crosshair).</p>
<p>I would like the position of this object to be defined by an invisible rigidbody sphere. However, when I place the rigidbody sphere at the top of the GameObject, I get compile errors:</p>
<blockquote>
<p>Actor::updateMassFromShapes: Compute
mesh inertia tensor failed for one of
the actor's mesh shapes! Please change
mesh geometry or supply a tensor
manually!</p>
</blockquote>
<p>Apparently this is caused by the auto-tensor-assignment process, which trips up on zero mass meshes (ie. the planes). I don't want these hackily put in seperate game objects and positioned each frame. Is there any way I can get this to behave? I'm sure the Tutorial has rigidbody objects containing sprites but I can't seem to figure out what part I'm doing differently. I tried adding a line on Awake() to set up a default tensor manually, as such: </p>
<pre><code>rigidbody.inertiaTensor = Vector3(1, 1, 1);
</code></pre>
<p>But that didn't fix it either. Anyone got any suggestions?</p>errorphysicsinertiatensorTue, 17 Nov 2009 12:12:37 GMTNovodantis