Newton Physik Problem

Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Neue Antwort erstellen

SamFisher

Betreff: Newton Physik Problem

BeitragMo, Jul 30, 2012 3:35
Antworten mit Zitat
Benutzer-Profile anzeigen
Wollte mal ein bisschen mit 3d Engine rumspielen. Da hab ich mich für die MiniB3dExtended enstschieden. Da ist schon die NewtonPyhsik teilweise eingebaut. Nach hin und her probieren hab ich ein kleines Testprogramm mir geschrieben. Nun ist das Problem, das wenn ich einen größeren Cube, quasi als Plane definieren und ich ein paar kleiner Cubes drauffallen lasse, es alles korrekt abprallt. Aber wenn ich aus den kleineren Cubes, Spheres mache dann fallen die einfach durch!! Vielleicht kann mir da einer weiter helfen!?

BlitzMax: [AUSKLAPPEN]
'Minib3d Newton Test
'SuperStrict

Import klepto.minib3dextnew

Graphics3D 800, 600
SeedRnd MilliSecs()
Global camera:TCamera = CreateCamera()
CameraRange camera, .1, 1000

PositionEntity camera, 0, 0, -20
Local light:TLight = CreateLight()
light.PositionEntity(0, 10, -20)
'dVector minSize (-500.0f, -500.0f, -500.0f) ;
'dVector maxSize ( 500.0f, 500.0f, 500.0f);
Local minSize:TVec3 = Vec3(-500:Float, -500:Float, -500:Float)
Local maxSize:TVec3 = vec3(500:Float, 500:Float, 500)
Global world:TPhysicWorld = TPhysicWorld.Create(minsize, maxsize)
Global mxs:Float, mys:Float
Local Pla:TMesh = CreateCube()
ScaleEntity Pla, 50, 1, 50
PositionEntity Pla, 0, -50, 0
EntityColor(Pla, 255, 128, 0)
Global cube:TMesh[101]
Global p_cube:TPhysicBody[101]
Local p_plane:TPhysicBody = TPhysicBodyBox.Create(world, Pla)

For Local a:Int = 0 To 50

cube[a] = CreateSphere()
PositionEntity (cube[a], Rand(-20, 20), Rand(-20, 20), Rand(-20, 20))
RotateEntity(cube[a], Rand(0, 10), Rand(0, 10), Rand(0, 10))
p_cube[a] = TPhysicBodyBox.Create(world, cube[a])
p_cube[a].SetMass(1)
Next



Repeat
Cls
Steuerung()
If KeyHit(KEY_ESCAPE) Then End
If KeyHit(KEY_SPACE) Then Shooting()
RenderWorld()
UpdateWorld()
world.Update()


Text(0, 0, GetFPS())
Flip
Forever

Function Steuerung()
mxs:Float = mxs:Float + (MouseXSpeed() / 5.0)
mys:Float = mys:Float + (MouseYSpeed() / 5.0)
RotateEntity camera, mys:Float, -mxs:Float, 0
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
MouseXSpeed() ;' flush
MouseYSpeed() ;' flush
MoveEntity camera, KeyDown(KEY_D) - KeyDown(KEY_A) , 0, KeyDown(KEY_W) - KeyDown(KEY_S)



End Function
Global ball:TMesh
Global p_ball:TPhysicBody
Function Shooting()
Global ball:TMesh = CreateSphere()
Global p_ball:TPhysicBody = TPhysicBodySphere.Create(world, ball)
p_ball.SetMass(.5)

'p_ball.ApplyImpulse(10, 0, 0, 0, 0, 0)
End Function
 

Boris1993

BeitragMi, Aug 01, 2012 15:47
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich denke du solltest nicht TPhysikbodybox nehmen sondern eher etwas wie TPhysikbodysphere falls es das gibt.

SamFisher

BeitragDo, Aug 02, 2012 17:20
Antworten mit Zitat
Benutzer-Profile anzeigen
Das meinte ich auch. So funktioniert es ja. Aber wenn ich statt TPhysicBodyBox, TPhysicBodySphere benutze fallen die einfach durch die vorhandene TPhysicBodyBox...

So funktionierts:BlitzMax: [AUSKLAPPEN]
'Minib3d Newton Test
'SuperStrict

Import klepto.minib3dextnew

Graphics3D 800, 600
SeedRnd MilliSecs()
Global camera:TCamera = CreateCamera()
CameraRange camera, .1, 1000

PositionEntity camera, 0, 0, -20
Local light:TLight = CreateLight()
light.PositionEntity(0, 10, -20)
'dVector minSize (-500.0f, -500.0f, -500.0f) ;
'dVector maxSize ( 500.0f, 500.0f, 500.0f);
Local minSize:TVec3 = Vec3(-500:Float, -500:Float, -500:Float)
Local maxSize:TVec3 = vec3(500:Float, 500:Float, 500)
Global world:TPhysicWorld = TPhysicWorld.Create(minsize, maxsize)
Global mxs:Float, mys:Float
Local Pla:TMesh = CreateCube()
ScaleEntity Pla, 50, 1, 50
PositionEntity Pla, 0, -50, 0
EntityColor(Pla, 255, 128, 0)
Global cube:TMesh[101]
Global p_cube:TPhysicBody[101]
Local p_plane:TPhysicBody = TPhysicBodyBox.Create(world, Pla)

For Local a:Int = 0 To 50

cube[a] = CreateCube()
PositionEntity (cube[a], Rand(-20, 20), Rand(-20, 20), Rand(-20, 20))
RotateEntity(cube[a], Rand(0, 10), Rand(0, 10), Rand(0, 10))
p_cube[a] = TPhysicBodyBox.Create(world, cube[a]) '[b]<----- Hier liegt das Problem[/b]
p_cube[a].SetMass(1)
Next



Repeat
Cls
Steuerung()
If KeyHit(KEY_ESCAPE) Then End
If KeyHit(KEY_SPACE) Then Shooting()
RenderWorld()
UpdateWorld()
world.Update()


Text(0, 0, GetFPS())
Flip
Forever

Function Steuerung()
mxs:Float = mxs:Float + (MouseXSpeed() / 5.0)
mys:Float = mys:Float + (MouseYSpeed() / 5.0)
RotateEntity camera, mys:Float, -mxs:Float, 0
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
MouseXSpeed() ;' flush
MouseYSpeed() ;' flush
MoveEntity camera, KeyDown(KEY_D) - KeyDown(KEY_A) , 0, KeyDown(KEY_W) - KeyDown(KEY_S)



End Function



Und so leider nicht:
BlitzMax: [AUSKLAPPEN]
'Minib3d Newton Test
'SuperStrict

Import klepto.minib3dextnew

Graphics3D 800, 600
SeedRnd MilliSecs()
Global camera:TCamera = CreateCamera()
CameraRange camera, .1, 1000

PositionEntity camera, 0, 0, -20
Local light:TLight = CreateLight()
light.PositionEntity(0, 10, -20)
'dVector minSize (-500.0f, -500.0f, -500.0f) ;
'dVector maxSize ( 500.0f, 500.0f, 500.0f);
Local minSize:TVec3 = Vec3(-500:Float, -500:Float, -500:Float)
Local maxSize:TVec3 = vec3(500:Float, 500:Float, 500)
Global world:TPhysicWorld = TPhysicWorld.Create(minsize, maxsize)
Global mxs:Float, mys:Float
Local Pla:TMesh = CreateCube()
ScaleEntity Pla, 50, 1, 50
PositionEntity Pla, 0, -50, 0
EntityColor(Pla, 255, 128, 0)
Global cube:TMesh[101]
Global p_cube:TPhysicBody[101]
Local p_plane:TPhysicBody = TPhysicBodyBox.Create(world, Pla)

For Local a:Int = 0 To 50

cube[a] = CreateSphere()
PositionEntity (cube[a], Rand(-20, 20), Rand(-20, 20), Rand(-20, 20))
RotateEntity(cube[a], Rand(0, 10), Rand(0, 10), Rand(0, 10))
p_cube[a] = TPhysicBodySphere.Create(world, cube[a])'[b]<-----[/b]
p_cube[a].SetMass(1)
Next



Repeat
Cls
Steuerung()
If KeyHit(KEY_ESCAPE) Then End
If KeyHit(KEY_SPACE) Then Shooting()
RenderWorld()
UpdateWorld()
world.Update()


Text(0, 0, GetFPS())
Flip
Forever

Function Steuerung()
mxs:Float = mxs:Float + (MouseXSpeed() / 5.0)
mys:Float = mys:Float + (MouseYSpeed() / 5.0)
RotateEntity camera, mys:Float, -mxs:Float, 0
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
MouseXSpeed() ;' flush
MouseYSpeed() ;' flush
MoveEntity camera, KeyDown(KEY_D) - KeyDown(KEY_A) , 0, KeyDown(KEY_W) - KeyDown(KEY_S)



End Function

SamFisher

BeitragDo, Okt 11, 2012 17:38
Antworten mit Zitat
Benutzer-Profile anzeigen
Problem übrigens vorherst gelöst:
einfach aus: TPhysicBodySphere.Create(world, cube[a])

das machen: TPhysicBodySphere.Create(world, cube[a], 1.0, 1.0, 0.9)

Irgendwie übernimmt das Modul den SZ# Float nicht richtig, oder er ist mit 1.0 einfach zu gross. Den mit 1.0 fallen die Sphere's durch und mit 0.9 nicht mehr...komisch!!
Aber erstmal gelöst!!
Commandline is for boys,
GUI is for girls!

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Beginners-Corner

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group