Hey, I'm having a problem where buoyancy isn't working. I've got a cube, and I've set it's buoyancy settings, and instead of floating, it like, bounces... It's as if it had no mass!
Has anyone run into this, any idea how to fix it.
I can provide more code if needed, but here's what im doing:
`Initialize Newton, and create the Newton World.
NDB_NewtonCreate
`Set the temp vector to our gravity constant (acceleration due to gravity)
`then set as our standard gravity force.
NDB_SetVector 0.0, -50.0, 0.0
NDB_SetStandardGravity
`Now an important step when using buoyancy, you must setup the "liquid" settings.
`in this demo I'll use a global liquid for all bodies, but you can set these settings
`individually for each body as well, have a look at the docs for more details.
NDB_GetStandardGravity
NDB_SetStandardLiquid 0.9, 0.5, 0.5
` the first time you call this command, you may get a very large time#,
` so I call it twice at the start, to make sure we're getting a nice small time# value.
time# = NDB_GetElapsedTimeInSec()
time# = NDB_GetElapsedTimeInSec()
MakeBox(100,1000,100,100,100,100,0,0,0,5.0)
function MakeBox(x#,y#,z#,sx#,sy#,sz#,rx#,ry#,rz#,mass#)
Col = NDB_NewtonCreateBox(sx#, sy#, sz#)
Body = NDB_NewtonCreateBody(Col)
NDB_BuildMatrix rx#, ry#, rz#, x#, y#, z#
NDB_NewtonBodySetMatrix Body
NDB_CalculateMIBoxSolid mass#, sx#, sy#, sz#
NDB_NewtonBodySetMassMatrix Body, mass#
NDB_NewtonReleaseCollision Col
` obj = FreeObject()
obj = 1009
make object cube obj, 1
scale object obj, sx#*100.0, sy#*100.0, sz#*100.0
position object obj, x#, y#, z#
rotate object obj, rx#, ry#, rz#
` color = GetColor()
` color object obj, color
set object ambience obj, 50
NDB_BodySetDBProData Body, obj
NDB_NewtonBodySetDestructorCallback Body
NDB_BodySetGravity Body, 1
`finally, setup the bouyancy settings for the body! First, we turn on bouyancy for the body.
NDB_BodySetBuoyancy Body, 1
`then, we set the "buoyancy plane" for the body. this is the plane representing the surface of the water
`at the body's position. see the docs for a detailed explanation of how to calculate this. in our case,
`the water is always a flat plane pointing up, on the origin (0,0,0).
NDB_SetVector 1, 0.0, 1.0, 0.0, 0.0
NDB_BodySetBuoyancyPlane Body
endfunction Body

The greatest multiplayer text adventure ever...