Another Stacking Problem

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Another Stacking Problem

Postby VoS » Fri Nov 27, 2009 5:22 pm

Hello,

I'm using the Newton included in Leadwerks Engine.
When I stack boxes their behaviour is somehow incorrect.
Pictures tell in this case more then words, please have a look at:
http://forum.leadwerks.com/viewtopic.php?f=2&t=5959

First I thought it is because of the autofreeze. But I apply
a bit of torque every update so the freezing does not become activated
(with debugphysics() the boxes stay green instead of red(freezed)).
I tried friction, damping, high masses, high gravity..

Unfortunately I'm limited to the command set of Leadwerks:
http://www.leadwerks.com/wiki/index.php?title=Bodies

Any help appreciated.
VoS
 
Posts: 4
Joined: Fri Nov 27, 2009 9:52 am

Re: Another Stacking Problem

Postby Julio Jerez » Fri Nov 27, 2009 5:36 pm

this is something that should never happens.
I cannot imagine what kind of errornuos setting could possible lead to that?
maybe is the Inertia in totally out of wack.
what are the inertia and mass values?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Another Stacking Problem

Postby VoS » Fri Nov 27, 2009 6:26 pm

Hi Julio,

I have made a simple example for the LE forum in Blitzmax.
Physical important commands are marked with "****************".
Mass is 20, elasticity 0. Everything else is standard.
Inertia? Can't be changed with Leadwers AFAIK.

You can download the executable at
http://www.skopia.de/test/NewtonTest.exe
(Press Key "1" to drop cube, cursor left and right to move body)

Tell me if you need somthing else.

Code: Select all
SuperStrict

Framework leadwerks.engine

Local world:TWorld
Local gbuffer:TBuffer
Local camera:TCamera
Local mesh:TMesh
Local light:TLight
Local Ground:TBody



RegisterAbstractPath "C:\Programme\Leadwerks Engine SDK"   '

Graphics(800, 600)

world = CreateWorld()
If Not world RuntimeError "Failed to create world."

gbuffer = createBuffer(GraphicsWidth(), GraphicsHeight(), BUFFER_COLOR | BUFFER_DEPTH | BUFFER_NORMAL)

camera = CreateCamera()
PositionEntity camera, [0.0, 5.0, -14.0]

Ground = CreateBodyBox(10, 1, 10)
EntityType(Ground, 2)

Collisions(3, 2, 1)
Collisions(3, 3, 1)

SetPhysicsQuality(1) ' *********************** exact physics
world.SetGravity(Vec3(0, -1.5, 0)) ' ***********************
DebugPhysics(True) '' ***********************


light = CreateDirectionalLight()

RotateEntity light, [45.0, 45.0, 45.0]

Repeat
   
If KeyHit(KEY_ESCAPE) Exit
If AppTerminate() Exit
   
If KeyDown(KEY_1)
   Local so:TSOCube = New TSOCube.Create(Vec3(0, 10, 0))
   DebugLog "Cube created"
   FlushKeys()
End If
If KeyDown(KEY_LEFT)
   For Local so:TSOCube = EachIn TSOCube.list
      If so.lastdropped = True
         DebugLog "Adding force"
         AddBodyForce(so.body, Vec3(-10, 0, 0)) ' *********************** move cube left
      End If
   Next
End If

If KeyDown(KEY_RIGHT)
   For Local so:TSOCube = EachIn TSOCube.list
      If so.lastdropped = True
         DebugLog "Adding force"
         AddBodyForce(so.body, Vec3(10, 0, 0)) ' *********************** move cube right
      End If
   Next
EndIf
   
UpdateAppTime()
UpdateWorld(AppSpeed())

SetBuffer(gbuffer)
RenderWorld()
SetBuffer(BackBuffer())
RenderLights(gbuffer)
   
Flip(0)

Forever

gbuffer = Null
FreeEntity light
GCCollect()
End

Type TSOCube
   Global list:TList = New TList
   Field Link:TLink ' tracks not only the templates, but too the new instances
   ' just for testing, kann weg
   Field mesh:TMesh
   Field body:TBody
   Field mass:Float = 20 ' ***********************
   Field lastdropped:Int
   Field elasticity:Float = 0 ' ***********************
   Method New()
      Link = list.AddLast(Self)
   End Method
   Method Create:TSOCube(Position:TVec3)
      Self.body = CreateBodyBox(1, 1, 1)
      SetBodyMass(Self.body, Self.mass)  ' ***********************
      SetBodyElasticity(Self.body, 0) ' ***********************
      PositionEntity(Self.body, Position)
      EntityType(Self.body, 3)
      SetBodyElasticity(Self.body, Self.elasticity) ' ***********************
      
      ' do not steer all bodies, just the last one
      For Local so:TSOCube = EachIn TSOCube.list
         so.lastdropped = False
      Next
      Self.lastdropped = True
      
      Return Self      
   End Method
End Type

VoS
 
Posts: 4
Joined: Fri Nov 27, 2009 9:52 am

Re: Another Stacking Problem

Postby Julio Jerez » Fri Nov 27, 2009 6:53 pm

that execultable does not run.
It show white screen with blithmax title thats is all.

you need to make a fully working executable with the dlls.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Another Stacking Problem

Postby VoS » Fri Nov 27, 2009 7:16 pm

Excuse me. My fault.
This should work:
http://www.skopia.de/test/NewtonTest.rar
VoS
 
Posts: 4
Joined: Fri Nov 27, 2009 9:52 am

Re: Another Stacking Problem

Postby Julio Jerez » Fri Nov 27, 2009 7:34 pm

I see the Bug, and you are right that is very extrange. I am, amost positive that some physics setting is very wrong because that should not happens for such normal setup.

however I cannot debug it because that demo is using an older version of Newton, probably 2.08 or 2.09.
we are at 2.10 and 2.11 (experomental still) but boteh those version change few thong that makes data incomatible.

you have to ask leadwerk to link his engine to the lastest Version of Newton 2.10 or 2.11
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Another Stacking Problem

Postby VoS » Fri Nov 27, 2009 8:06 pm

Thanks Julio, will go back to the Leadwerks forum.
VoS
 
Posts: 4
Joined: Fri Nov 27, 2009 9:52 am

Re: Another Stacking Problem

Postby Carli » Sat Nov 28, 2009 10:19 am

Worlds gravity is -1.5. The size of the bodies is ~1
I've played with mass, friction and elasticity.


lol - since when did objects have negative masses?
Carli
 
Posts: 245
Joined: Fri Oct 02, 2009 5:28 am

Re: Another Stacking Problem

Postby Stucuk » Sat Nov 28, 2009 6:30 pm

Carli wrote:
Worlds gravity is -1.5. The size of the bodies is ~1
I've played with mass, friction and elasticity.


lol - since when did objects have negative masses?


~ is the tide symbol. It means about/roughly/etc. So you can re-write it as:

Worlds gravity is -1.5. The size of the bodies is about 1 unit
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 9 guests