Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? #447409
12/10/14 00:42
12/10/14 00:42
Joined: Dec 2014
Posts: 11
T
Taskmaster065 Offline OP
Newbie
Taskmaster065  Offline OP
Newbie
T

Joined: Dec 2014
Posts: 11
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?


Last edited by Taskmaster065; 12/10/14 03:09.
Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? [Re: Taskmaster065] #447410
12/10/14 04:24
12/10/14 04:24
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
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.

Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? [Re: 3dgs_snake] #447411
12/10/14 05:53
12/10/14 05:53
Joined: Dec 2014
Posts: 11
T
Taskmaster065 Offline OP
Newbie
Taskmaster065  Offline OP
Newbie
T

Joined: Dec 2014
Posts: 11
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?

Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? [Re: Taskmaster065] #447413
12/10/14 07:52
12/10/14 07:52
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
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 ..


Compulsive compiler
Re: How to Set exact values of Moments of Inertia (Ixx,Iyy,Izz) ? [Re: Wjbender] #447430
12/11/14 06:55
12/11/14 06:55
Joined: Dec 2014
Posts: 11
T
Taskmaster065 Offline OP
Newbie
Taskmaster065  Offline OP
Newbie
T

Joined: Dec 2014
Posts: 11
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?

Last edited by Taskmaster065; 12/11/14 07:08.
Re: How to Set exact values of Moments of Inertia [SOLVED] ? [Re: Taskmaster065] #447638
12/23/14 02:13
12/23/14 02:13
Joined: Dec 2014
Posts: 11
T
Taskmaster065 Offline OP
Newbie
Taskmaster065  Offline OP
Newbie
T

Joined: Dec 2014
Posts: 11
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.

Last edited by Taskmaster065; 12/23/14 02:15.

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1