How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ?

Posted By: Taskmaster065

How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? - 12/10/14 00:42

Hi

I have been evaluating 3DGS for developing a project that will use PhysX.

I want to be able to set the exact mass and moments of inertia (Ixx,Iyy and Izz) of each entity (NxActor).

I can check what the values are being use by PhysX by using PhysX Visual Debugger (PVD).

The function pXent_setmass(...) works and sets the mass to the correct value.

However, when I use pXent_setmasssoffset(...) to set Ixx,Iyy and Izz using my exact values, the values set in PhysX (examined using PVD) are differnt (ie have different numerical values).

How can I set the my exact values for Ixx,Iyy and Izz in PhysX?

Posted By: 3dgs_snake

Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? - 12/10/14 04:24

Hi,

I think those values are different because 3DGS doesn't have the same unit as physX so the values passed to the physics engine are scaled.
Posted By: Taskmaster065

Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? - 12/10/14 05:53

Yes they can be scaled by pX_setunit(scale) function. I have tried this but cannot work out the correlation between the scale and the Ixx, Iyy and Izz values. I have tried an iterative process of manually setting the scale parameter then checking what values PhysX has, then adjusting the scale value again and then repeating this process in an attempt to get the correct values. With this method I could not get the correct Ixx etc values. Also this is not a practical solution.

Can anybody help please?
Posted By: Wjbender

Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? - 12/10/14 07:52

I cannot really give advice on this but what I can comment on is , that , I have been working on a simple helicopter flight model , and to tell you the truth I have never been so confused with a physics engine when it comes to the forces masses and scaling , it doesn't really keep itself to specific units which would have helped out a lot .

basicly I learned that setting the mass directly can be a problem especially when the size of an object is to small for the mass setting , the best I found is to model the object according to a realistic scale in units then work according to that units per quant , what I do is I define the units such that I only multiply by a factor for my input values and just leave the physx scale as it was .

I had to come up with a factor for distance and mass to finally get something more or less acceptable for the lift and wing area and air density etc to all work together in some acceptable way ,before my values I displayed on screen were more or less acceptable .

I still don't get how to really get it as it should be ,so I am with you here ,kinda lost and not certain how to approach realistic values ..
Posted By: Taskmaster065

Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? - 12/11/14 06:55

Yes I had troubles at first as well. I made 1 quant = 1 centimeter. What I did was calculate everything in SI units (ie. meters, kilograms etc). Then just before I applied my forces I converted them to my units (eg centimeters for length). For example: for a force in Newtons (ie kg.m/s^2) I multiplied the value by 100 to give a value in kg.cm/s^2. This gave the correct velocities of my entity in cm/s.

You have to be very careful with rounding errors when using "var" variable. To solve this I used "float" for all variables and only converted them to var's when required by the 3DGS engine.

To set the mass to the correct value I called the pX_setmass(myEnt,myMass) AFTER I called phent_settype(myEnt,PH_RIGID,PH_CONVEX). This set the correct value in PhysX.

Still hoping someone can help?
Posted By: Taskmaster065

Re: How to Set exact values of Moments of Inertia [SOLVED] ? - 12/23/14 02:13

This issue was solved by downloading and using 3dgs_snake's PhysX3 DLL's (thread "AckphysX3 development thread:).

More specifically I found that my problem was related to the PhysX code that came with 3DGS. I downloaded the PhysX_Plugin source code from the 3DGS download page: PhysX Plugin Source (40 KB - VC++ 2010 - October 2011).

In the file main.cpp it contains the the following function I use to set the interia:

=========source code beg
DLLFUNC var pXent_setmassoffset(ENTITY * entity, VECTOR* vOffsetPos, VECTOR* vInertia)
{
NxActor* actor = PhX.GetActorFromEnt(entity);
if(!actor)return _VAR(0);
actor->updateMassFromShapes(1.0f,actor->getMass());
if (vOffsetPos)
actor->setCMassOffsetLocalPosition(NxVec3(_FLOAT(vOffsetPos->x),_FLOAT(vOffsetPos->z),_FLOAT(vOffsetPos->y))*PhX.NXSize);

if (vInertia) {
NxReal ValNew = _FLOAT(vec_length(vInertia));
if (ValNew) {
NxVec3 NxInertia = actor->getMassSpaceInertiaTensor();
NxReal ValOld = NxInertia.magnitude();
NxInertia.x = _FLOAT(vInertia->x) * ValOld/ValNew;
NxInertia.y = _FLOAT(vInertia->z) * ValOld/ValNew;
NxInertia.z = _FLOAT(vInertia->y) * ValOld/ValNew;
actor->setMassSpaceInertiaTensor(NxInertia);
}
}
return _VAR(1);
}
=========source code end

It appears that the NxInertia values are scale by ValOld/ValNew. This is why the values are changing when I use this function.

3dgs_snake's PhysX3 DLL's do not alter the values you input.

Also 3dgs_snake was a great help and is the guy to ask if you have any PhysX issues in 3DGS.
© 2024 lite-C Forums