Inertia problems

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: Inertia problems

Postby Stucuk » Tue Aug 03, 2010 9:08 pm

Aldeminor wrote:Julio, can you post link on fullsize logo of Newton? We want to place it in the bootscreen of our project :)

- Click Here
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Re: Inertia problems

Postby Julio Jerez » Wed Aug 04, 2010 12:43 am

Ok there are few things wrongs, the first I found is in the function that create the body for the ship, the mass is 100, but the inertia is 1,
and the make the body acts like a little black hole, meaning the mass distribution is concentrated at the origin.
Went that happens the auto sleep code is dominated by the linear momentum since there is very lithe change in angular momentum in the motion. Therefore when the linear momentum falls below the threshold the body stops moving.

This is a case when the laws of physics act very strange when the input data is different that the common sense is familiar to.
The reason the body spins a little is because you are setting the angular velocity directly but the body should be even more unrealistic than what you see with that data.

if you set the inertia according to the Mass distribution, it do not even have to be exact just close enough, the it will be fine.

Plus if you do no want the auto slepp code to kick in , the you need to set the autosleep on the body to zero. But for that you need to expose those functions of newton in your wrapper.

Do that and I believe you will be fine.

Bellow is teh funtion tah I beleiev need to be modified to do whe I say.

Code: Select all
        public static int AddBodyConvHull(int physic_World , TVMesh Mesh, double mass, double lin_damp, Vector3 ang_damp)
        {
            int count = Mesh.GetVertexCount();
            double[] points = new double[count * 3];
            int number;

            for (number = 0; number < count; number++)
            {
                float X=0, Y=0, Z=0, temp=0;
                int temp2 = 0;
                Mesh.GetVertex(number, ref X, ref Y, ref Z, ref temp, ref temp, ref temp, ref temp, ref temp, ref temp, ref temp, ref temp2);
                points[number * 3] = X;
                points[number * 3 + 1] = Y;
                points[number * 3 + 2] = Z;
            }
            Matrix mat = new Matrix();
            mat = MatrixTV2Matrix(Mesh.GetMatrix());

            Matrix mat2 = new Matrix();
            mat2.M11 = 1;
            mat2.M12 = 0;
            mat2.M13 = 0;
            mat2.M14 = 0;

            mat2.M21 = 0;
            mat2.M22 = 1;
            mat2.M23 = 0;
            mat2.M24 = 0;

            mat2.M31 = 0;
            mat2.M32 = 0;
            mat2.M33 = 1;
            mat2.M34 = 0;

            mat2.M41 = 0;
            mat2.M42 = 0;
            mat2.M43 = 0;
            mat2.M44 = 1;

            int shapeID = 0;
            int colis = NewtonWrapper.CreateConvexHull(physic_World, count, points, 24, 0.1f, shapeID, ref mat2);
           
            int body = NewtonWrapper.CreateBody(physic_World, colis);


            NewtonWrapper.BodySetMatrix(body, ref mat);
            NewtonWrapper.ReleaseCollision(physic_World, colis);

            NewtonWrapper.BodySetLinearDamping(body, lin_damp);
            Vector3 AngDamp = new Vector3(0.1, 0.1, 0.1);

            NewtonWrapper.BodySetAngularDamping(body, ref ang_damp);

            // I do no find the function to set auto sleep off yo unee to implmenet function
            void NewtonBodySetAutoSleep (const NewtonBody* body, int state);

            // you need to set the inertia matrix by using funxtion,
            // NewtonConvexCollisionCalculateInertialMatrix (const NewtonCollision* convexCollision, dFloat* inertia, dFloat* origin);   

            // setting the inertia to 1.0 causes the body to move in a very unrealistic way,
            // and because auto step was on then the auto frezze code kicks in and the bodis stop when eth lina moment reach zero, sicne the angual momentum is very, very small.
            NewtonWrapper.BodySetMassMatrix(body, mass, 1, 1, 1);

            NewtonWrapper.BodySetMaterialGroupID(body, 1);

            return body;

        }
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Inertia problems

Postby Aldeminor » Wed Aug 04, 2010 5:55 am

Thank you very much, Julio! You saved loads of nerves and time for us! :)
It's realy great!
Aldeminor
 
Posts: 31
Joined: Tue Jun 29, 2010 6:37 am

Re: Inertia problems

Postby martinw » Fri Aug 06, 2010 12:05 pm

I might be wrong but is the Newton dll not contained within the TV3D dll? I'm using TV3D6.5 without a Newton dll I think.

The reaosn I ask is we might be stuck with an old version of the Newton dll until the TV3D6.5 dll is updated?

Just a thought .............. :)
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Re: Inertia problems

Postby Julio Jerez » Fri Aug 06, 2010 1:55 pm

I do not know how they got the wraper but Aldeminor Team is using the latest version of newton in double presistion, :D
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Inertia problems

Postby martinw » Fri Aug 06, 2010 2:48 pm

It looks pretty impressive :)
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 55 guests