Physikproblem[gelöst]
Übersicht![](/themes/Standard/arrow.png)
![](/themes/Standard/arrow.png)
![]() |
hecticSieger des IS Talentwettbewerb 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Das alles mache ich schon seit vielen Jahren. Begonnen auf dem Amiga600 und dessen Basic, dann Power-Basic auf dem PC, gelegentlich auch QBasic, dann habe ich Blitz-Basic entdeckt. Beruflich habe ich höhstens als System-Engineer gearbeitet und erstellte Software-Packages die dann über ein SMS (gemeint sind keine Kurznachrichten von Mobiltelefonen) an Firmenrechner gesendet wurden. Also alles nur aus Spaß am programmieren.
Die Physik aus der Draw3D ist nur reine 2D. Ist aber schon eine etwas verbesserte Version, als aus dem Buggy-Beispiel. |
||
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Wow. Verdienter Respekt... Les mich grade bei den Types bisschen ein. schreibe gleich mal nen code rein (variable)
Hab mir das folgender maßen gedacht. ich mach 2 types. Der erste definiert mit x,y,z die Anfangs und weiterführenden Koordinaten der Tetraeder Polygone, und der zweite type definiert mir die x,y,z anfangs- und weiterführenden Werte der Polygone meines Quaders. (?) un dann verbinden ? aber das verbinden kann ich ja eigentlich nich mit nem type machen weil dann verbinde ich ja alle plygone meines objektes mit denen des tetraeders... da kann ich den mesh auch gleich wie er is fallen lassen ^^ Code: [AUSKLAPPEN] Type vertex_1 Field x# Field y# Field z# Field ax# Field ay# Field az# Field x1# Field x2# Field x3# End Type Type vertex_2 Field x_p# Field y_p# Field z_p# Field x1_p# Field x2_p# Field x3_p# End Type |
||
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
So Mahlzeit. Hab mal bisschen gebastelt aber irgendwie gehts trotzdem nich so richtig...
Mein Bildschirm bleibt schwarz. Keine Fehlermeldung oder sowas... ich hab das ganze mal so veranstaltet: x,y,z koordinate per entity x,y,z ausspucken lassen... type festgelegt für: - x,y,z kord. - alte x,y,z kord. - beschl. in x,y,z - geschwind. in x,y,z.. jetzt die koord. des entitys in old_x etc speichern lassen... mit info\vx die geschwindigkeit berechnet aus der beschleunigung und dem zeitfaktor timestep.. dann den neuen punkt berechnen lassen aus dem alten Punkt oldx plus die geschwindigkeit vx... irgendwie komm ich nich dahinter... das ganze sollte nur geschwindigkeitsreal den Mittelpunkt dieses Quaders nach unten bewegen... mehr nich x.x wenn jemand was weis immer her damit.. Code: [AUSKLAPPEN] Graphics3D 1024,768,32,2 SetBuffer BackBuffer() Global camera_damping#=0.5 Global timer = CreateTimer(30) ;verschiedene Meshes ;player cube=CreateCube() camera_pivot=CreatePivot(cube) PositionEntity camera_pivot,0,0,-15 EntityType cube,1 EntityRadius cube,1 MoveEntity cube,3,5,10 surface1 = GetSurface(cube,1) vertex = CountVertices(surface1) cube1=CreateCube() EntityColor cube1,0,0,128 EntityType cube1,2 ScaleMesh cube1,0.5,0.5,0.5 MoveEntity cube1 ,3,3,10 flr=CreatePlane() EntityColor flr,30,144,255 EntityAlpha flr,0.9 EntityType flr,2 flr_Text=LoadTexture("boden.jpg") EntityTexture flr,flr_Text physik=CreateCube() EntityColor physik,120,20,120 lane=CreatePlane EntityType physik ,1 MoveEntity physik,3,15,10 ;cam (1) camera=CreateCamera() light=CreateLight() RotateEntity light,90,0,0 ;type Type vertex Field x# Field y# Field z# Field old_x# Field old_y# Field old_z Field ax# Field ay# Field az# Field vx# Field vy# Field vz# End Type Const gravity_x# = 0 Const gravity_y# = 1 Const gravity_z# = 0 Const timestep# = 1 While Not KeyHit(1) Cls V_Auslesen() V_Beschleunigung() V_Position() ;Rendern() WaitTimer timer Flip 0 Wend End Function V_Auslesen() For info.vertex = Each vertex info\x# = EntityX(cube) info\y# = EntityY(cube) info\z# = EntityZ(cube) Next End Function Function V_Beschleunigung() For info.vertex = Each vertex info\ax# = gravity_x# info\ay# = gravity_y# info\az# = gravity_z# Next End Function Function V_Position() For info.vertex = Each vertex old_x# = info\x# old_y# = info\y# old_z# = info\z# info\vx# = info\ax# * timestep# info\vy# = info\ay# * timestep# info\vz# = info\az# * timestep# info\x# = info\old_x# + info\vx# info\y# = info\old_y# + info\vy# info\z# = info\old_z# + info\vz# ;neue_xposition = alte_xpos + speed_im_moment WaitTimer timer Next End Function While Not KeyDown(1) cam_x#=EntityX(camera) cam_y#=EntityY(camera) cam_z#=EntityZ(camera) cube_x#=EntityX(cube) cube_y#=EntityY(cube) cube_z#=EntityZ(cube) piv_x#=EntityX(camera_pivot,1) piv_y#=EntityY(camera_pivot,1) piv_z#=EntityZ(camera_pivot,1) move_x#=(piv_x#-cam_x#)*camera_damping# move_y#=(piv_y#-cam_y#)*camera_damping# move_z#=(piv_z#-cam_z#)*camera_damping# mxs=MouseXSpeed() mys=MouseYSpeed() TurnEntity cube,mys/3,-mxs/3,0 RotateEntity cube,EntityPitch(cube),EntityYaw(cube),0 TranslateEntity camera,move_x#,move_y#,move_z# AlignToVector camera,cube_x#-cam_x#,cube_y#-cam_y#,cube_z#-cam_z#,3,camera_damping# RotateEntity camera,EntityPitch(camera),EntityYaw(camera),0 ;Tastaturbelegung If KeyDown(205) MoveEntity cube,0.05,0,0 If KeyDown(203) MoveEntity cube,-0.05,0,0 If KeyDown(200) MoveEntity cube,0,0,0.05 If KeyDown(208) MoveEntity cube,0,0,-0.05 ;Kollision Collisions 1,2,2,2 col=CountCollisions(cube) Text 0,0,"cols:" For i=1 To col Text 000,i*20,"ent="+CollisionEntity(cube,1) Next Text 0,0, "X pos" + EntityX#(cube) Text 0,20,"y pos" + EntityY#(cube) Text 0,40, "z pos" + EntityZ#(cube) WaitTimer timer Flip 0 UpdateWorld RenderWorld Wend End |
||
![]() |
Noobody |
![]() Antworten mit Zitat ![]() |
---|---|---|
Du hast da auch zwei Hauptschleifen drin - die erste gibt überhaupt nichts aus, weswegen du auch nichts siehst, während die zweite gar nie aufgerufen wird. | ||
Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. -- Wernher von Braun |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
hm.. okay danke erstmal auch wenn ich erst ma gucken muss wie ich das nu löse... wenn mir wer helfen kann wär ich dankbar häng grad durch ![]() |
||
![]() |
Noobody |
![]() Antworten mit Zitat ![]() |
---|---|---|
Ich hab dir mal einen entsprechenden Code mit Würfeln und Tetraedern geschrieben (linke/rechte Maustaste drücken): Code: [AUSKLAPPEN] Const GWIDTH = 800
Const GHEIGHT = 600 Graphics3D GWIDTH, GHEIGHT, 0, 2 SetBuffer BackBuffer() Const MAX_VERTICES = 64 Const MAX_EDGES = 64 Const MAX_FACES = 64 Type TParticle Field X# Field Y# Field Z# Field OldX# Field OldY# Field OldZ# Field A_X# Field A_Y# Field A_Z# Field Mass# Field ProjX Field ProjY Field Parent.TEntity End Type Type TConstraint Field ID Field P1.TParticle Field P2.TParticle Field Length# Field Force# Field Parent.TEntity End Type Type TEntity Field VertexCount Field Vertex.TParticle[ MAX_VERTICES - 1 ] Field EdgeCount Field Edge.TConstraint[ MAX_EDGES - 1 ] Field CenterX# Field CenterY# Field CenterZ# Field MinX# Field MinY# Field MinZ# Field MaxX# Field MaxY# Field MaxZ# Field Collision End Type Type TLink Field Surface Field Mesh Field Index Field Particle.TParticle End Type Const TIMESTEP# = 1 Global GRAVITY_X# = 0 Global GRAVITY_Y# = -0.001 Global GRAVITY_Z# = 0 Global Iterations = 10, EntityCount, VertexCount Cam = CreateCamera() PositionEntity Cam, 0, 0, -10 Light = CreateLight( 2 ) PositionEntity Light, 0, 30, 0 LightRange Light, 100 LightColor Light, 128, 128, 128 MouseYSpeed() MouseXSpeed() CreateTetrahedron( 0, 0, 10, 5, 5, 5 ) Timer = CreateTimer( 60 ) While Not KeyHit( 1 ) TurnEntity Cam, MouseYSpeed(), -MouseXSpeed(), 0 MoveMouse 400, 300 MoveEntity Cam, ( KeyDown( 32 ) - KeyDown( 30 ) )*0.5, 0, ( KeyDown( 17 ) - KeyDown( 31 ) )*0.5 Counter = MilliSecs() AccumulateForces() Verlet() SatisfyConstraints() LagString$ = "Physik: " + ( MilliSecs() - Counter ) + "ms " UpdateLinks() UserInput() Counter = MilliSecs() RenderWorld Render( Cam ) LagString$ = LagString$ + "Zeichnen: " + ( MilliSecs() - Counter ) + "ms" Color 128, 128, 128 Text 0, 0, LagString$ + " | " + EntityCount + " Objekte, " + VertexCount + " Vertices" Flip 0 WaitTimer Timer Wend End Function UserInput() If MouseHit( 2 ) Then CreateTetrahedron( Rnd( -10, 10 ), 0, Rnd( -10, 10 ), 5, 5, 5 ) EntityCount = EntityCount + 1 VertexCount = VertexCount + 8 ElseIf MouseHit( 1 ) Then CreateBox( Rnd( -10, 10 ), 0, Rnd( -10, 10 ), 5, 5, 5 ) EntityCount = EntityCount + 1 VertexCount = VertexCount + 8 EndIf End Function Function AccumulateForces() For Particle.TParticle = Each TParticle Particle\A_X# = GRAVITY_X# Particle\A_Y# = GRAVITY_Y# Particle\A_Z# = GRAVITY_Z# Next End Function Function Verlet() For Particle.TParticle = Each TParticle Temp_X# = Particle\X# Temp_Y# = Particle\Y# Temp_Z# = Particle\Z# Particle\X# = Particle\X# + Particle\X# - Particle\OldX# + Particle\A_X#*TIMESTEP#*TIMESTEP# Particle\Y# = Particle\Y# + Particle\Y# - Particle\OldY# + Particle\A_Y#*TIMESTEP#*TIMESTEP# Particle\Z# = Particle\Z# + Particle\Z# - Particle\OldZ# + Particle\A_Z#*TIMESTEP#*TIMESTEP# Particle\OldX# = Temp_X# Particle\OldY# = Temp_Y# Particle\OldZ# = Temp_Z# Next End Function Function SatisfyConstraints() For i = 1 To Iterations For Constraint.TConstraint = Each TConstraint For Particle.TParticle = Each TParticle Particle\X# = Min( Max( Particle\X#, -100 ), 100 ) Particle\Y# = Min( Max( Particle\Y#, 0 ), 100 ) Particle\Z# = Min( Max( Particle\Z#, -100 ), 100 ) Next If Constraint\P1\Mass + Constraint\P2\Mass > 0 Then DeltaX# = Constraint\P2\X# - Constraint\P1\X# DeltaY# = Constraint\P2\Y# - Constraint\P1\Y# DeltaZ# = Constraint\P2\Z# - Constraint\P1\Z# DeltaLength# = Sqr( DeltaX#*DeltaX# + DeltaY#*DeltaY# + DeltaZ#*DeltaZ# ) Diff# = ( DeltaLength# - Constraint\Length# )/DeltaLength# AccWeight# = Constraint\P1\Mass + Constraint\P2\Mass Ratio1# = Constraint\P2\Mass/AccWeight# Ratio2# = Constraint\P1\Mass/AccWeight# Constraint\P1\X# = Constraint\P1\X# + DeltaX#*Diff#*Constraint\Force#*Ratio1# Constraint\P1\Y# = Constraint\P1\Y# + DeltaY#*Diff#*Constraint\Force#*Ratio1# Constraint\P1\Z# = Constraint\P1\Z# + DeltaZ#*Diff#*Constraint\Force#*Ratio1# Constraint\P2\X# = Constraint\P2\X# - DeltaX#*Diff#*Constraint\Force#*Ratio2# Constraint\P2\Y# = Constraint\P2\Y# - DeltaY#*Diff#*Constraint\Force#*Ratio2# Constraint\P2\Z# = Constraint\P2\Z# - DeltaZ#*Diff#*Constraint\Force#*Ratio2# EndIf Next Next End Function Function Render( Cam ) LockBuffer BackBuffer() For Particle.TParticle = Each TParticle CameraProject Cam, Particle\X#, Particle\Y#, Particle\Z# Particle\ProjX = ProjectedX() Particle\ProjY = ProjectedY() Next Color 255, 0, 0 For Constraint.TConstraint = Each TConstraint If Constraint\P1\ProjX*Constraint\P1\ProjY*Constraint\P2\ProjX*Constraint\P2\ProjY Then Line Constraint\P1\ProjX, Constraint\P1\ProjY, Constraint\P2\ProjX, Constraint\P2\ProjY EndIf Next For Particle.TParticle = Each TParticle WritePixel Particle\ProjX, Particle\ProjY, $FFFFFF Next UnlockBuffer BackBuffer() End Function Function Min#( A#, B# ) If A# < B# Then Return A# Else Return B# End Function Function Max#( A#, B# ) If A# > B# Then Return A# Else Return B# End Function Function CreateParticle.TParticle( Parent.TEntity, X#, Y#, Z#, Mass# = 1 ) If Parent <> Null Then If Parent\VertexCount < MAX_VERTICES - 1 Then Particle.TParticle = New TParticle Particle\X# = X# Particle\Y# = Y# Particle\Z# = Z# Particle\OldX# = X# Particle\OldY# = Y# Particle\OldZ# = Z# Particle\Parent = Parent Particle\Mass# = Mass# Parent\Vertex[ Parent\VertexCount ] = Particle Parent\VertexCount = Parent\VertexCount + 1 Return Particle EndIf EndIf End Function Function CreateConstraint.TConstraint( Parent.TEntity, P1.TParticle, P2.TParticle, Force# = 1 ) If Parent <> Null Then If Parent\EdgeCount < MAX_EDGES - 1 Then If P1 <> P2 Then Constraint.TConstraint = New TConstraint Constraint\P1 = P1 Constraint\P2 = P2 ConstraintLengthSq# = ( Constraint\P1\X# - Constraint\P2\X# )*( Constraint\P1\X# - Constraint\P2\X# ) + ( Constraint\P1\Y# - Constraint\P2\Y# )*( Constraint\P1\Y# - Constraint\P2\Y# ) + ( Constraint\P1\Z# - Constraint\P2\Z# )*( Constraint\P1\Z# - Constraint\P2\Z# ) Constraint\Length# = Sqr( ConstraintLengthSq# ) Constraint\Parent = Parent Constraint\Force# = Force# Parent\Edge[ Parent\EdgeCount ] = Constraint Parent\EdgeCount = Parent\EdgeCount + 1 Return Constraint EndIf EndIf EndIf End Function Function CreateTetrahedron( X#, Y#, Z#, Width#, Height#, Depth# ) Entity.TEntity = New TEntity P1.TParticle = CreateParticle( Entity, X# - Width#/2, Y# - Height#/2, Z# - Depth#/2, 1 ) P2.TParticle = CreateParticle( Entity, X# + Width#/2, Y# - Height#/2, Z# - Depth#/2, 1 ) P3.TParticle = CreateParticle( Entity, X#, Y# - Height#/2, Z# + Depth#/2, 1 ) P4.TParticle = CreateParticle( Entity, X#, Y# + Height#/2, Z#, 1 ) C1.TConstraint = CreateConstraint( Entity, P1, P2, 1 ) C2.TConstraint = CreateConstraint( Entity, P2, P3, 1 ) C3.TConstraint = CreateConstraint( Entity, P3, P1, 1 ) C5.TConstraint = CreateConstraint( Entity, P1, P4, 1 ) C6.TConstraint = CreateConstraint( Entity, P2, P4, 1 ) C7.TConstraint = CreateConstraint( Entity, P3, P4, 1 ) Mesh = CreateMesh() Surf = CreateSurface( Mesh ) V1 = AddVertex( Surf, P1\X#, P1\Y#, P1\Z# ) V2 = AddVertex( Surf, P2\X#, P2\Y#, P2\Z# ) V3 = AddVertex( Surf, P3\X#, P3\Y#, P3\Z# ) V4 = AddVertex( Surf, P4\X#, P4\Y#, P4\Z# ) AddTriangle Surf, V1, V2, V3 AddTriangle Surf, V1, V4, V2 AddTriangle Surf, V3, V4, V1 AddTriangle Surf, V2, V4, V3 LinkVertex( Mesh, Surf, V1, P1 ) LinkVertex( Mesh, Surf, V2, P2 ) LinkVertex( Mesh, Surf, V3, P3 ) LinkVertex( Mesh, Surf, V4, P4 ) End Function Function CreateBox( X#, Y#, Z#, Width#, Height#, Depth# ) Entity.TEntity = New TEntity P1.TParticle = CreateParticle( Entity, X# - Width#/2, Y# - Height#/2, Z# - Depth#/2, 1 ) P2.TParticle = CreateParticle( Entity, X# + Width#/2, Y# - Height#/2, Z# - Depth#/2, 1 ) P3.TParticle = CreateParticle( Entity, X# + Width#/2, Y# + Height#/2, Z# - Depth#/2, 1 ) P4.TParticle = CreateParticle( Entity, X# - Width#/2, Y# + Height#/2, Z# - Depth#/2, 1 ) P5.TParticle = CreateParticle( Entity, X# - Width#/2, Y# - Height#/2, Z# + Depth#/2, 1 ) P6.TParticle = CreateParticle( Entity, X# + Width#/2, Y# - Height#/2, Z# + Depth#/2, 1 ) P7.TParticle = CreateParticle( Entity, X# + Width#/2, Y# + Height#/2, Z# + Depth#/2, 1 ) P8.TParticle = CreateParticle( Entity, X# - Width#/2, Y# + Height#/2, Z# + Depth#/2, 1 ) C1.TConstraint = CreateConstraint( Entity, P1, P2, 1 ) C2.TConstraint = CreateConstraint( Entity, P2, P3, 1 ) C3.TConstraint = CreateConstraint( Entity, P3, P4, 1 ) C4.TConstraint = CreateConstraint( Entity, P4, P1, 1 ) C5.TConstraint = CreateConstraint( Entity, P5, P6, 1 ) C6.TConstraint = CreateConstraint( Entity, P6, P7, 1 ) C7.TConstraint = CreateConstraint( Entity, P7, P8, 1 ) C8.TConstraint = CreateConstraint( Entity, P8, P5, 1 ) C9.TConstraint = CreateConstraint( Entity, P3, P7, 1 ) C10.TConstraint = CreateConstraint( Entity, P4, P8, 1 ) C11.TConstraint = CreateConstraint( Entity, P1, P5, 1 ) C12.TConstraint = CreateConstraint( Entity, P2, P6, 1 ) CreateConstraint( Entity, P4, P6, 1 ) CreateConstraint( Entity, P3, P5, 1 ) CreateConstraint( Entity, P7, P1, 1 ) CreateConstraint( Entity, P8, P2, 1 ) Mesh = CreateMesh() Surf = CreateSurface( Mesh ) V1 = AddVertex( Surf, P1\X#, P1\Y#, P1\Z# ) V2 = AddVertex( Surf, P2\X#, P2\Y#, P2\Z# ) V3 = AddVertex( Surf, P3\X#, P3\Y#, P3\Z# ) V4 = AddVertex( Surf, P4\X#, P4\Y#, P4\Z# ) V5 = AddVertex( Surf, P5\X#, P5\Y#, P5\Z# ) V6 = AddVertex( Surf, P6\X#, P6\Y#, P6\Z# ) V7 = AddVertex( Surf, P7\X#, P7\Y#, P7\Z# ) V8 = AddVertex( Surf, P8\X#, P8\Y#, P8\Z# ) AddTriangle Surf, V1, V4, V3 AddTriangle Surf, V1, V3, V2 AddTriangle Surf, V4, V8, V7 AddTriangle Surf, V4, V7, V3 AddTriangle Surf, V2, V3, V7 AddTriangle Surf, V2, V7, V6 AddTriangle Surf, V5, V1, V2 AddTriangle Surf, V5, V2, V6 AddTriangle Surf, V6, V7, V8 AddTriangle Surf, V6, V8, V5 AddTriangle Surf, V5, V8, V4 AddTriangle Surf, V5, V4, V1 LinkVertex( Mesh, Surf, V1, P1 ) LinkVertex( Mesh, Surf, V2, P2 ) LinkVertex( Mesh, Surf, V3, P3 ) LinkVertex( Mesh, Surf, V4, P4 ) LinkVertex( Mesh, Surf, V5, P5 ) LinkVertex( Mesh, Surf, V6, P6 ) LinkVertex( Mesh, Surf, V7, P7 ) LinkVertex( Mesh, Surf, V8, P8 ) End Function Function LinkVertex( Mesh, Surface, Index, Particle.TParticle ) Link.TLink = New TLink Link\Surface = Surface Link\Mesh = Mesh Link\Index = Index Link\Particle = Particle End Function Function UpdateLinks() For Link.TLink = Each TLink VertexCoords Link\Surface, Link\Index, Link\Particle\X#, Link\Particle\Y#, Link\Particle\Z# UpdateNormals Link\Mesh Next End Function Die Objekte werden absichtlich im Boden drin erstellt, so dass sie ein wenig durch die Gegend spicken (ist ja langweilig, wenn sie einfach senkrecht runterfallen). |
||
Man is the best computer we can put aboard a spacecraft ... and the only one that can be mass produced with unskilled labor. -- Wernher von Braun |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
kann ich dem Programm sagen es soll 3 mal in bspw 1.ms einen wert aktualisieren ?
also ich hab bspw folgendes: (arbeite grade mit dem ball tut ausm forum... hab schon bissl umgeschrieben) -hole mir den wert geschwindigkeit raus und zeig ihn an bspw - 3 - erhöhe diesen wert um 0,1 - 3,1 - hole mir den wert erneut - 3,1 - erhöhe ihn erneut um 0,1 - 3,2 sowas ? Problem besteht weiterhin... meine 2d bälle ham konstante geschwindigkeit ... x.x |
||
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
habs 2d schonmal hinbekommen glaub ich ![]() mit vielen bällen die wahllos auf dem Bildschirm erscheinen und runter fallen Das is das abgeänderte Beispiel von einem Tut aus dem Forum hier.. Code: [AUSKLAPPEN] Graphics 800,600,16,2 SetBuffer BackBuffer() timer = CreateTimer(50) ;wird später zum ball erstellen benötigt (timer) Global counter Const time# = 0.8 Const gravity_x#=0 Const gravity_y#=1 ;das ist der ball type mit seinen "feldern"(eigenschaften) Type ball Field farbe# Field grosse# Field speed_x# Field speed_y# Field ball_x# Field ball_y# Field acc_x# Field acc_y# End Type ;main schleife ------------------------- While Not KeyHit(1) Cls balle_erstellen() gravity() geschwindigkeit() balle_machen_lassen() WaitTimer timer Flip 0 Wend End ;--------------------------------------- ;hier werden die balle in zeilichen abständen erstellt Function balle_erstellen() counter = counter +1 If counter >= 1 Then counter = 10 info.ball = New ball ;ball erstellen info\farbe# = Rnd(0,255) ;eigenschaften werte zuweisen info\grosse# = Rnd(2,9) info\ball_x# = Rnd(0,800) info\ball_y# = Rnd(-5,500) End If End Function Function gravity() For info.ball = Each ball info\acc_x# = graivty_x# info\acc_y# = gravity_y# Next End Function Function geschwindigkeit() For info.ball = Each ball info\speed_x# = 2 info\speed_y# = info\speed_y# + 0.5*info\acc_y#*time#*time# Next End Function Function balle_machen_lassen() For info.ball = Each ball ;alle bälle ansprechen info\ball_y# = info\ball_y# + info\speed_y# info\ball_x# = info\ball_x# + info\speed_x# Color info\farbe#,100,50: Oval info\ball_x# , info\ball_y# , info\grosse# , info\grosse# ;farbe von ball und ball erstellen If info\ball_y# >600 Then Delete info.ball ;unten angekommen ball löschen Next End Function Ps.: entweder stell ich mich total dämlich an oder viele Leute ham grundlegende Physikalische Probleme bei den Aufrufszahlen ![]() |
||
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
So ich komm einfach nich weiter... hab versucht das ganze jetzt 3d zu erweitern. Sprich das einfach viele Spheren aus dem nichts kommen und runterfallen. Habe dazu meinen beliebten Kamerblock und ein Plane erstellt... das Problem.. ich seh schwarz x.x
(siehe unten) |
||
- Zuletzt bearbeitet von TwentyEight28 am So, März 22, 2009 18:51, insgesamt einmal bearbeitet
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
Packe alles in eine schleife, also nicht 4mal For t.type = Each type aufrufen sondern nur einmal...
Edit : Hab den code mal ein wenig verändert, sonst siehts ncht wirklich nach Physik aus... Code: [AUSKLAPPEN] Graphics 800,600,16,2
SetBuffer BackBuffer() timer = CreateTimer(50) ;wird später zum ball erstellen benötigt (timer) Global counter Const time# = 0.8 Const gravity_x#=0 Const gravity_y#=1 ;das ist der ball type mit seinen "feldern"(eigenschaften) Type ball Field farbe# Field grosse# Field speed_x# Field speed_y# Field ball_x# Field ball_y# Field acc_x# Field acc_y# End Type ;main schleife ------------------------- While Not KeyHit(1) Cls balle_erstellen() Update() WaitTimer timer Flip 0 Wend End ;--------------------------------------- ;hier werden die balle in zeilichen abständen erstellt Function balle_erstellen() counter = counter +1 If counter >= 1 Then counter = 10 info.ball = New ball ;ball erstellen info\farbe# = Rnd(0,255) ;eigenschaften werte zuweisen info\grosse# = Rnd(2,9) info\ball_x# = Rnd(0,800) info\ball_y# = Rnd(-5,500) info\speed_x# = Rnd(-1,1) * 2 End If End Function Function Update() For info.ball = Each ball info\acc_x# = graivty_x# info\acc_y# = gravity_y# info\speed_y# = info\speed_y# + 0.5*info\acc_y#*time#*time# info\ball_y# = info\ball_y# + info\speed_y# info\ball_x# = info\ball_x# + info\speed_x# Color info\farbe#,100,50: Oval info\ball_x# , info\ball_y# , info\grosse# , info\grosse# ;farbe von ball und ball erstellen If info\ball_y# => 600 Then info\speed_y = info\speed_y * -(1.0/gravity_y/2.0) info\ball_y = info\ball_y - info\grosse EndIf If info\ball_x < -info\grosse Or info\ball_x > 800+info\grosse Delete info.ball EndIf Next End Function mfg ToeB |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
- Zuletzt bearbeitet von ToeB am So, März 22, 2009 17:58, insgesamt einmal bearbeitet
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
... ih das geht ja echt xD . Bei mir gings nich loL.. Vielen Dank dafür =) . Hast noch ne Anregung für 3d Geschichte ? Geb dir ein aus wenn de das hinbekommst ich beis schier in die scheiß Tastatur... | ||
- Zuletzt bearbeitet von TwentyEight28 am So, März 22, 2009 18:02, insgesamt einmal bearbeitet
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
Guck in meinem Code oben da siehst dus... Das was du 4mal durchgegangen bist, bin ich hier nur einamal durchgegangen, und zwar in der Function "Update"...
mfg ToeB |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Okay danke dir ![]() Grüße |
||
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
Kommt drauf an was du machen willst... willst du nur bälle springen lassen, machs wie in dem Beispiel nur noch mit der ZAchse, willst du Boxen runterfallen sehen, könntest du über die winkel was machen, willst du xbeliebige formen fallen lassen, musst du es so machen wie Nobody oder halt sowas wie einen wrapper für eine Physik-Dll ( z.B. Newton.dll ) schreiben.....
mfg ToeB |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ja genau das is der Punkt... Ich wollt erst ma nur Bälle springen lassen. Der Code is oben schon drin... Habs versucht mit der Z-Achse aber ich hab nur nen schwarzen screen das is das problem ^^ .
Danke für eure/deine Hilfe ![]() Code: [AUSKLAPPEN] Graphics3D 800,600,32,2 SetBuffer BackBuffer() timer = CreateTimer(50) Global counter Const time# = 0.8 Const gravity_x#=0 Const gravity_y#=1 Const gravity_z#=0 lane=CreatePlane() EntityColor lane,0,0,128 camera=CreateCamera() light=CreateLight() RotateEntity light,90,0,0 cube=CreateCube() camera_pivot=CreatePivot(cube) PositionEntity camera_pivot,0,0,-15 Type ball Field farbe# Field grosse# Field speed_x# Field speed_y# Field speed_z# Field ball_x# Field ball_y# Field ball_z# Field acc_x# Field acc_y# Field acc_z# End Type ;main schleife ------------------------- While Not KeyHit(1) Cls balle_erstellen() gravity() WaitTimer timer Flip 0 Wend End ;--------------------------------------- ;hier werden die balle in zeilichen abständen erstellt Function balle_erstellen() counter = counter +1 If counter >= 1 Then counter = 1 info.ball = New ball ;ball erstellen info\farbe# = Rnd(0,255) ;eigenschaften werte zuweisen info\ball_x# = Rnd(0,800) info\ball_y# = Rnd(-5,500) info\ball_z# = Rnd(-60,60) info\speed_x# = Rnd(-1,1)*2 info\speed_z# = Rnd(-2,2) End If End Function Function gravity() For info.ball = Each ball info\acc_x# = gravity_x# info\acc_y# = gravity_y# info\acc_z# = gravity_z# info\speed_y# = info\speed_y# + 0.5*info\acc_y#*time#*time# info\ball_y# = info\ball_y# + info\speed_y# info\ball_x# = info\ball_x# + info\speed_x# info\ball_z# = info\ball_z# + info\speed_z# CreateSphere(6) Color info\farbe#,0,128 If info\ball_y# => 600 Then Delete info.ball Next End Function While Not KeyDown(1) cam_x#=EntityX(camera) cam_y#=EntityY(camera) cam_z#=EntityZ(camera) cube_x#=EntityX(cube) cube_y#=EntityY(cube) cube_z#=EntityZ(cube) piv_x#=EntityX(camera_pivot,1) piv_y#=EntityY(camera_pivot,1) piv_z#=EntityZ(camera_pivot,1) move_x#=(piv_x#-cam_x#)*camera_damping# move_y#=(piv_y#-cam_y#)*camera_damping# move_z#=(piv_z#-cam_z#)*camera_damping# mxs=MouseXSpeed() mys=MouseYSpeed() TurnEntity cube,mys/3,-mxs/3,0 RotateEntity cube,EntityPitch(cube),EntityYaw(cube),0 TranslateEntity camera,move_x#,move_y#,move_z# AlignToVector camera,cube_x#-cam_x#,cube_y#-cam_y#,cube_z#-cam_z#,3,camera_damping# RotateEntity camera,EntityPitch(camera),EntityYaw(camera),0 WaitTimer timer Flip 0 UpdateWorld RenderWorld Wend End |
||
![]() |
ToeB |
![]() Antworten mit Zitat ![]() |
---|---|---|
Code: [AUSKLAPPEN] Graphics3D 800,600,32,2
SetBuffer BackBuffer() timer = CreateTimer(50) Global counter Const time# = 0.8 Const gravity_x#=0 Const gravity_y#=-0.1 Const gravity_z#=0 lane=CreatePlane() EntityColor lane,0,0,128 camera=CreateCamera() CameraRange camera,0.1,1000 light=CreateLight() RotateEntity light,90,0,0 Type ball Field farbe# Field grosse# Field speed_x# Field speed_y# Field speed_z# Field ball_x# Field ball_y# Field ball_z# Field acc_x# Field acc_y# Field acc_z# Field mesh Field prall End Type ;main schleife ------------------------- While Not KeyHit(1) Cls TurnEntity Camera,+MouseYSpeed()/3.0,0,0,0 TurnEntity Camera,0,-MouseXSpeed()/3.0,0,1 MoveMouse 400,300 balle_erstellen() gravity() UpdateWorld() RenderWorld() WaitTimer timer Flip 0 Wend End ;--------------------------------------- ;hier werden die balle in zeilichen abständen erstellt Function balle_erstellen() counter = counter +1 If counter >= 10 Then counter = 1 info.ball = New ball ;ball erstellen info\farbe# = Rnd(0,255) ;eigenschaften werte zuweisen info\ball_x# = Rnd(-10,10) info\ball_y# = Rnd(100,150) info\ball_z# = Rnd(50,100) info\speed_x# = Rnd(-1,1)*0.05 info\speed_z# = Rnd(-1,1)*0.05 info\mesh = CreateSphere(6) PositionEntity info\mesh,info\ball_x,info\ball_y,info\ball_z End If End Function Function gravity() For info.ball = Each ball info\acc_x# = gravity_x# info\acc_y# = gravity_y# info\acc_z# = gravity_z# info\speed_y# = info\speed_y# + 0.5*info\acc_y#*time#*time# info\ball_y# = info\ball_y# + info\speed_y# info\ball_x# = info\ball_x# + info\speed_x# info\ball_z# = info\ball_z# + info\speed_z# PositionEntity info\mesh,info\ball_x,info\ball_y,info\ball_z If info\ball_y# < 0 Then info\speed_y = info\speed_Y * -0.75 info\prall = info\prall + 1 EndIf If info\prall > 10 FreeEntity info\mesh : Delete info.ball Next End Function mfg ToeB |
||
Religiöse Kriege sind Streitigkeiten erwachsener Männer darum, wer den besten imaginären Freund hat.
Race-Project - Das Rennspiel der etwas anderen Art SimpleUDP3.0 - Neuste Version der Netzwerk-Bibliothek Vielen Dank an dieser Stelle nochmal an Pummelie, welcher mir einen Teil seines VServers für das Betreiben meines Masterservers zur verfügung stellt! |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
grr... ich dachte ich bekomms hin... du freak ^^ Vielen Dank =) jetz hab ich ein Grundgerüst an dem ich rumbasteln kann... mir hatte die Zeile info\mesh gefehlt ![]() ![]() sag bescheid wennde ma in Leipzig bist hast en großes kühles gut bei mir ^^ reinhaun |
||
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Nachdem dieses PRoblem gelöst wurde steht das nächste aufm Plan. Kann ich das ganze irgendwie in Blitz Max umsetzen ? Mache mit nem Kumpel son mini projekt und der meint ich solle mich in bmax einarbeiten weil er das besser kann und besser findet... however.. gibts da großartige unterschiede weil einfach den Code so wie er in b3d läuft in bmax kopieren geht mal nich soweit bin ich schon ^^ .
grüße |
||
![]() |
hecticSieger des IS Talentwettbewerb 2006 |
![]() Antworten mit Zitat ![]() |
---|---|---|
Klar kann man das auch in BlitzMax umsetzen. Ich wüsste jetzt auch nicht, warum es nicht gehen sollte. Das setzt allerdings voraus, dass man den Code auch versteht und sich mit der anderen Programmiersprache auskennt, oder außernander setzt.
Ich glaube mich aber zu erinnern, dass irgendwo im BlitzMax-Codearchiv auch eine Verletintegration vorhanden sein müsste. |
||
Download der Draw3D2 V.1.1 für schnelle Echtzeiteffekte über Blitz3D |
TwentyEight28 |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Ja das stimmt wol... Les mich grade rein. Vorteilhaft (oder Nachteilig?) ist das ich nich wirklich viel Erfahrung mit Programmierung habe da isses nich so schwer sich "neu einzulesen" . Aber sone richtige Befehlsliste für BlitzMax gibt es anscheinend nicht so wie ich das sehe (?) .
Und ich dachte daran den B3D Code so umzuschreiben das er in Bmax funktioniert. 3D Darstellung funktioniert doch dort oder ? Edit: Hat sich geklärt so wies aussieht nicht... hab ma Irrlicht mit Editor runtergeladen vielleicht kann man ja BlitzMax für die Programmierseite nehmen und den Editor fürs erstellen. Achso falls es von Interesse ist, für kleine private Spiele darf man die Havok Physik Engine verwenden. Is 300MB groß... wollt ich nur mal sagen (open source for private use... ) |
||
Übersicht
![](/themes/Standard/arrow.png)
![](/themes/Standard/arrow.png)
Powered by phpBB © 2001 - 2006, phpBB Group