Documentation about NewtonCreateBody

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Documentation about NewtonCreateBody

Postby carli2 » Wed Sep 26, 2012 6:31 pm

Hi,

I saw that NewtonCreateBody was replaced by two other functions. Where can I find more documentation (Wiki or such) that I know how to port my code to core301?
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Documentation about NewtonCreateBody

Postby pr0t0z » Wed Dec 12, 2012 12:44 pm

Bump

I have the very same problem :(
pr0t0z
 
Posts: 15
Joined: Wed May 30, 2012 11:57 am

Re: Documentation about NewtonCreateBody

Postby PJani » Wed Dec 12, 2012 1:00 pm

Now you have two types of bodies...Kinematic which can be controlled only by your code and dont get affected by other dynamic bodies...Dynamic which are affected by collisions of other objects. That is.
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Documentation about NewtonCreateBody

Postby carli2 » Sat Feb 16, 2013 9:43 am

@Julio can you please change your workflow such that:
- for each commit you write a commit message
- for each interface change you update the wiki

I know, that would make your work slower, but it would help us a lot such that we don't have to figure out what you actually changed.
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Documentation about NewtonCreateBody

Postby rvangaal » Thu Jul 18, 2013 11:44 am

Is there a Newton3 wiki at all?
I'm testing 3.10, found the NewtonCreateDynamicBody() function and am now looking at buoyancy that doesn't seem to work anymore. Or well, it has changed somewhere.
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Documentation about NewtonCreateBody

Postby Julio Jerez » Thu Jul 18, 2013 6:18 pm

are you using boyancy?
yes I have not updated that piece of code.
The reason was that newton 3.00 has the listeners, whe people can add that kind of funtionality.
stuff like the simple bouyancy, tonado forces, and force field in general will be moved to the triger manager.

the trigger manager are object that you can place in the world, and they they can be used as game variable that the game logic can use for controlling objects.

for example in the case of bouyancy, if coudl work like this
-Place a body of water trigget volume in teh world
-The body of watter have a funtion callback tah apply the boyancy force to any bopdy the enet that volume.
that's all.

The cool thing is that the bouyance force will be move outsid eteh newton core engine.
what thsi mean is that a trigget with a diffrent update funtion can do difrent thong to the body, and if trhgger overlapthey can do diffrent stuff
othe ussage is eviromment effects, say you play a trigger and when some one enter, an animation start playing so effect.

I can re-enable the bouyancy force stuff this weekend.
I will add it usin teh trigget funtionality, because it really belong there.
that way people can add customization, which now is very hard in core 200.
when I refactory this weekend I will also add friction, whi was lacking in core 200.

what are you doing with bouancy?

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

Re: Documentation about NewtonCreateBody

Postby rvangaal » Fri Jul 19, 2013 8:22 am

Ok, if you can post a small example of how it works with the callbacks once you've integrated it, I can test that.

I'm actually working on a more generic game engine inside my regular simulator (which is racing-targeted), so I can now add scripted entities (in my own C++-like scripting language). One of the first things is a boat.
I've tried buoyancy, which gives a nice floating motion for a boat that is still in the water. When going fast (and I'm only using 1 plane that I get out of 3 raycasts), the buoyancy method does filter out any harsh motion though. In other words, I don't 'slam' into waves, but rather they are very smooth.

I tried another method, based on raycasted height samples and attached a simple spring+damper force there (F=submersedDepth*k+kd*v) which is better at this type of thing (I get spikes in vertical acceleration). So a fast boat I'm developing is using the spring method, another NPC boat is using buoyancy. Although now that I think of it, this might be much heavier on the physics than using simple springs.
Anyway, would still be good to have working again.
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Documentation about NewtonCreateBody

Postby rvangaal » Wed Jul 24, 2013 4:56 am

Any news on buoyancy through triggers?
rvangaal
 
Posts: 61
Joined: Mon Jun 08, 2009 1:11 pm

Re: Documentation about NewtonCreateBody

Postby Julio Jerez » Wed Jul 24, 2013 9:29 am

Yes I am working on getting that back on. I was just completing what I was doing at the moment, in a day or tow I will check that in.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Documentation about NewtonCreateBody

Postby Julio Jerez » Tue Jul 30, 2013 10:46 am

Ok I just check in the refactored buoyancy demo
please see if you can set it up.

It is not completed yet, because it only calculates the buoyancy, late I will add a realistic calculation of viscosity friction force.
This will be much better that the hack that was in core 2.xx where viscosity was emulate by drag.
Now it will be simulated by calculate the surface area and velocity of the face under the fluid
for that the interface will change to take the velocity and angular velocity of the shape.

for now see if this is what you wanted.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Documentation about NewtonCreateBody

Postby sova » Wed Aug 14, 2013 5:48 am

Hello Julio!
Why my stones float? they should sink! :)
http://youtu.be/5luiCrcmf4w
sova
 
Posts: 23
Joined: Mon Mar 05, 2012 8:58 am

Re: Documentation about NewtonCreateBody

Postby Julio Jerez » Wed Aug 14, 2013 6:42 am

are you using the buoyancy?
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Documentation about NewtonCreateBody

Postby sova » Wed Aug 14, 2013 7:59 am

Julio Jerez wrote:are you using the buoyancy?

Yes, I have used your latest example from svn.
sova
 
Posts: 23
Joined: Mon Mar 05, 2012 8:58 am

Re: Documentation about NewtonCreateBody

Postby Julio Jerez » Wed Aug 14, 2013 8:17 am

Ha ok cool,

yes you are right, I noticed that I made a mistake in the relative fluid density.
I knew when I made the test, but I did not fix it because I still have to add the viscosity calculation,
I figured I can fix that when I resume the code. bu then I move to other prioritis
I am glad you testing it, Basically teh bug is that I calculated the water volume equavalene to the solid volume incorrectly,
I will fix it now.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Documentation about NewtonCreateBody

Postby Julio Jerez » Wed Aug 14, 2013 9:15 am

Ok if you sync to svn the volume is now correct.
basically I have the ration bewten volume of fluid and volume of solid in the numerator, an dsoudl eb on the denominator
Code: Select all
      void OnInside(NewtonBody* const visitor)
      {
         dFloat Ixx;
         dFloat Iyy;
         dFloat Izz;
         dFloat mass;
         
         NewtonBodyGetMassMatrix(visitor, &mass, &Ixx, &Iyy, &Izz);
         if (mass > 0.0f) {
            dMatrix matrix;
            dVector cog;
            dVector accelPerUnitMass;
            dVector torquePerUnitMass;
            const dVector gravity (0.0f, DEMO_GRAVITY, 0.0f, 0.0f);

            NewtonBodyGetMatrix (visitor, &matrix[0][0]);
            NewtonBodyGetCentreOfMass(visitor, &cog[0]);
            cog = matrix.TransformVector (cog);
            NewtonCollision* const collision = NewtonBodyGetCollision(visitor);

            
            dFloat shapeVolume = NewtonConvexCollisionCalculateVolume (collision);

// this was
// dFloat fluidDentity = m_waterToSolidVolumeRatio  / shapeVolume);

// but should be
            dFloat fluidDentity = 1.0f / (m_waterToSolidVolumeRatio * shapeVolume);

            NewtonConvexCollisionCalculateBuoyancyAcceleration (collision, &matrix[0][0], &cog[0], &gravity[0], &m_plane[0], fluidDentity, 0.1f, &accelPerUnitMass[0], &torquePerUnitMass[0]);



basically the resaming is this

you have a solid with a volume,
if you place that solid under a fluid, I will displace an impound of fluid of equal volume.

the you say what fraction of the volume of fluid will be equal to the mass of the solid.

if the solid density oif the same as the fluid, the fraction is 1.0
if the solid is more dense than the fluid, the you need more fluid (for example a rock will required more fluid than the what the volume displace, and the was the error)
if the solid is less dense, the friction should be less than 1.0 because
then for the equation

Code: Select all
density = mass / volumeOfFliud

but:
Code: Select all
volumeOfFluld = fraction * volumeOfSolid

the you have
Code: Select all
density = mass / (fraction * volumeOfSolid)

and I had teh fraction in the wrong place
Code: Select all
 density = mass * fraction / (volumeOfSolid)


them to make the calculation dimensionless you set the mass to a unit mass
Code: Select all
densityPerUnitMass =  1.0 / (ratio * volumeOfSolid)

the code will return the acceleration and angular acceleration that the fluid apply to the body
note that this code also work for gasses. for example by animation ratio yo ucna make a hot air ballom
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests