Kugel rollt in eine Senke...wie?
Übersicht

![]() |
OrnosBetreff: Kugel rollt in eine Senke...wie? |
![]() Antworten mit Zitat ![]() |
---|---|---|
hallo
wie schaft man es, dass eine kugel (oder anderes objekt) die eine bestimmte geschwindigeit hat und auf eine Senke rollt erst schneller (weil sie erst runter rollt) und dann langsamer wird (weil sie hochrollt), so lange bis sie zum stillstand kommt. das schwere dabei (so finde ich) ist, es ist egal von wo aus die kugel im 3d-raum auf die senke zurollt edit: ach ja es kann auch passieren, dass die kugel nicht direkt auf die senke zurollt und dadurch abgelenkt wird ....wie macht man das (ich bin daran gescheitet...konnte keinen bezug finden) |
||
![]() |
Jan_Ehemaliger Admin |
![]() Antworten mit Zitat ![]() |
---|---|---|
Suche mal nach Tokamak oder ODE
(besser auf Blitzbasic.com) Ansonsten, Nehme dein Physik Formelwerk und setzte dich paar tage lang hin |
||
between angels and insects |
BIG BUG |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Zuerst müsstest Du herausfinden, wie das Polygon, auf welchem die Kugel liegt, ausgerichtet ist.
Wenn du aus den 3 Vertexpunkten entsprechende Vektoren errechnest(xyz-Differenz von v1->v2 & v1->v3) und über diese das Kreuzprodukt bildest, erhälst Du die sog. Flächennormale(Ausrichtung des Polygons). Entsprechend der X & Y-Ausrichtung dieses Vektors musst Du dann deine Kugel beschleunigen bzw. abbremsen. KA ob das so funktioniert, habe ich mir grad ausgedacht. Als Lösungsansatz wahrscheinlich brauchbar. |
||
B3D-Exporter für Cinema4D!(V1.4)
MD2-Exporter für Cinema4D!(final) |
Klaas |
![]() Antworten mit Zitat ![]() |
|
---|---|---|
Hier bitte ... ich denke das ist das was du suchst.
Wenn du bestimmt Abschnitte erklärt haben wilst sag bescheid. Alles zu erklären hab ich jetzt keine Lust. Wenn du es begreifen möchtest mußt du auf jedenfall Vektorrechnung können. Denk drann das du die Maps anlegst Code: [AUSKLAPPEN] Graphics3D 800,600,32,2 SetBuffer BackBuffer() AmbientLight(10,10,10) Dim light(3) light(1)=CreateLight(1) TurnEntity light(1),35,40,0 ;light(2)=CreateLight(2) ;MoveEntity light(2),200,10,200 cam_pivot=CreatePivot() camera=CreateCamera(cam_pivot) MoveEntity camera,0,0,0 Type ball Field entity Field vx#,vy#,vz# Field vpitch# Field vyaw# Field vroll# Field oldx#,oldy#,oldz# Field newx#,newy#,newz# Field radius End Type speed#=.3 Const t_struct=1 Const t_ball=2 Global AIR_FRICTION_CONSTANT#=0.001 Global GROUND_FRICTION_CONSTANT#=0.001 Global GRAVITY#=0.03 Collisions t_ball,t_struct,2,2 Collisions t_ball,t_ball,2,2 terrain=LoadTerrain("map.jpg") ScaleEntity terrain,0.5,10,0.5 EntityType terrain,t_struct TerrainShading terrain,True MoveEntity terrain,-64,-10,-64 For i=1 To 10 ball=createball() tex=LoadTexture("apfel.png") EntityTexture ball,tex MoveEntity ball,Rand(-15,15),Rnd(2,5),Rand(-15,15) Next timer=CreateTimer(50) While Not KeyHit(1) x_speed#=(MouseXSpeed()-x_speed)/4+x_speed y_speed#=(MouseYSpeed()-y_speed)/4+y_speed MoveMouse GraphicsWidth()/2,GraphicsHeight()/2 TurnEntity cam_pivot,0,-x_speed,0 TurnEntity camera,y_speed,0,0 If KeyDown(200) ;forward MoveEntity cam_pivot,0,0,speed# End If If KeyDown(208) ;backward MoveEntity cam_pivot,0,0,-speed# End If If KeyDown(203) ;left MoveEntity cam_pivot,-speed#,0,0 End If If KeyDown(205) ;right MoveEntity cam_pivot,speed#,0,0 End If If KeyDown(30) ;up MoveEntity cam_pivot,0,speed#,0 End If If KeyDown(44) ;down MoveEntity cam_pivot,0,-speed#,0 End If If KeyHit(57) ;down ;push(Rnd(-0.1,0.1),Rnd(0,1),Rnd(-0.1,0.1)) push(0,2,0) End If If KeyDown(31) ;down ShowEntity master End If physics() UpdateWorld RenderWorld Text 10,10,"Pitch : "+Int(EntityPitch(camera)) Text 10,25,"Yaw : "+Int(EntityYaw(cam_pivot)) Flip WaitTimer(timer) Wend End Function push(vx#,vy#,vz#) For a.ball = Each ball a\vx=a\vx+vx a\vy=a\vy+vy a\vz=a\vz+vz Next End Function Function turn(pitch#,yaw#,roll#) For a.ball = Each ball mx# = (roll# / (180/Pi)) * a\radius mz# = (pitch# / (180/Pi)) * a\radius a\vx# = mx# a\vz# = mz# Next End Function Function physics() For a.ball = Each ball Entity_Hit = EntityCollided(a\entity, t_struct) Entity_Hit2 = EntityCollided(a\entity, t_ball) If Entity_Hit2 Then Entity_Hit=True ; Calculate motion friction: ; Calculate the entity's current velocity. Velocity# = Sqr(a\Vx#^2 + a\Vy#^2 + a\Vz#^2) ; If the entity is moving, adjust it's velocity: If Velocity# > 0 ; Calculate the direction vector. ; The direction vector has a length of 1. Direction_X# = a\Vx# / Velocity# Direction_Y# = a\Vy# / Velocity# Direction_Z# = a\Vz# / Velocity# ; Compute air friction. ; Air friction is dependent on the speed of the entity, and will prevent it from accelerting forever. Air_Friction_Force# = AIR_FRICTION_CONSTANT# * Velocity#^2.0 Velocity# = Velocity# - (Air_Friction_Force#) ; If the entity collided with the level, apply ground friction. If Entity_Hit > 0 ; Compute ground friction. Ground friction is not dependent on the speed of the entity. Velocity# = Velocity# - (GROUND_FRICTION_CONSTANT#) End If If Entity_Hit2 > 0 Velocity# = Velocity# * 0.8 EndIf ; Make sure the entity's velocity doesn't go below 0. ; It is impossible to have a negative velocity in physics and "bad things" happen if you try to. If (Velocity# < 0) Then Velocity# = 0 ; Convert the entity's velocity and direction back into a motion vector. a\Vx# = Direction_X# * Velocity# a\Vy# = Direction_Y# * Velocity# a\Vz# = Direction_Z# * Velocity# ; If the entity collided with the level, make it bounce. If Entity_Hit > 0 ; Calculate bounce: ; Get the normal of the surface which the entity collided with. Nx# = CollisionNX(a\entity, 1) Ny# = CollisionNY(a\entity, 1) Nz# = CollisionNZ(a\entity, 1) ; Compute the dot product of the entity's motion vector and the normal of the surface collided with. VdotN# = a\Vx#*Nx# + a\Vy#*Ny# + a\Vz#*Nz# ; Calculate the normal force. NFx# = -2.0 * Nx# * VdotN# NFy# = -2.0 * Ny# * VdotN# NFz# = -2.0 * Nz# * VdotN# ; Add the normal force to the direction vector. a\Vx# = a\Vx# + NFx# a\Vy# = a\Vy# + NFy# a\Vz# = a\Vz# + NFz# ; Do not allow the entity to move vertically. ; If a\Vy# > 0 Then a\Vy# = 0 a\vy=a\vy*0.8 EndIf EndIf ; Apply directional thrust: ; If the entity collided with the level, apply directional thrust. ;If Entity_Hit > 0 ; Take thrust in object space, and translates it to an XYZ vector in world space. ;TFormVector 0, 0, Thrust#, ballpos, 0 ; Add any thrust being applied this frame. ; There's a very good reason why this is done AFTER the friction is calculated. ; It involves inequalities in force cause by variable framerates. a\Vx# = a\Vx# + (Thrust_X#) a\Vz# = a\Vz# + (Thrust_Z#) ;EndIf ; Apply gravity: a\Vy# = a\Vy# - (GRAVITY#) ; Move and rotate the entity: ; We rotate the entity by the actual distance moved and not by the velocity because if we rotate according ; to the velocity then the entity will roll when it's up against a wall and not moving. a\OldX# = a\NewX# a\OldZ# = a\NewZ# TranslateEntity a\entity, a\Vx#, a\Vy#, a\Vz#, True a\NewX# = EntityX#(a\entity, True) a\NewZ# = EntityZ#(a\entity, True) If entity_hit > 0 Mx# = (a\NewX# - a\OldX#) Mz# = (a\NewZ# - a\OldZ#) ; Rotate the entity the right amount for it's radius and the distance it has moved along the X and Z axis. ; This is kinda a hack and only designed for rolling on planes but you won't notice the diffrence. a\vroll# = (Mx# / a\radius) * (180.0/Pi) a\vpitch# = (Mz# / a\radius) * (180.0/Pi) End If TurnEntity a\entity,a\vpitch#,0,-a\vroll#,True Next End Function Function createball() a.ball=New ball a\entity=CreateSphere(8) a\radius=1 EntityRadius a\entity,1 EntityType a\entity,t_ball Return a\entity End Function |
||
![]() |
Ornos |
![]() Antworten mit Zitat ![]() |
---|---|---|
Danke
so in der art habe ich das gebraucht |
||
Übersicht


Powered by phpBB © 2001 - 2006, phpBB Group