[B3D][Tokamak] Relative Impulse

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Lord_Vader

Betreff: [B3D][Tokamak] Relative Impulse

BeitragMi, Aug 20, 2014 20:59
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,

da man mit Tokamak nur Kräfte und Impulse in Global-Koordinaten angeben kann hier eine Include zum Umrechnen in zum Objekt relevanten Koordinaten.

Bis jetzt nur für ApplyImpulse und ApplyImpulse2. Wenn ich Torque usw nochmal brauchen werde, dann werde ich es noch erweitern.

Viel Spaß damit!

[Edit]

Die Masse hat komischerweise keinen Einfluss auf die Drehung. Mit Code: [AUSKLAPPEN]
xf# = TFormedX() * yaw# / Mass#
kann man das Problem lösen, man muss nur die Masse zwischenspeichern, da es keinen Befehl zum Abfragen gibt -.-

Code: [AUSKLAPPEN]
Global relpiv=CreatePivot()

;Relative Kraft
Function relforce(rb,x#,y#,z#)
   
   Local xf#=0,yf#=0,zf#=0
   
   setpivot(rb)
   
   ;In X-Richtung
   TFormNormal 1,0,0,relpiv,0
   
   xf# = xf# + TFormedX() * x#
   yf# = yf# + TFormedY() * x#
   zf# = zf# + TFormedZ() * x#
   
   ;In Y-Richtung
   TFormNormal 0,1,0,relpiv,0
   
   xf# = xf# + TFormedX() * y#
   yf# = yf# + TFormedY() * y#
   zf# = zf# + TFormedZ() * y#
   
   ;In Z-Richtung
   TFormNormal 0,0,1,relpiv,0
   
   xf# = xf# + TFormedX() * z#
   yf# = yf# + TFormedY() * z#
   zf# = zf# + TFormedZ() * z#
   
   TOKRB_ApplyImpulse(rb,xf#,yf#,zf#)
   
End Function

;Relatives Drehen
Function relturn(rb,pitch#,yaw#,roll#)
   
   Local xf#,yf#,zf#
   
   setpivot(rb)
   
   
      
   ;X-Richtung (Yaw)
   TFormNormal 1,0,0,relpiv,0
   
   xf# = TFormedX() * yaw#
   yf# = TFormedY() * yaw#
   zf# = TFormedZ() * yaw#
   
   TFormPoint 0,0,1,relpiv,0 ;Angriffspunkt
   TOKRB_ApplyImpulse2(rb,xf# * 0.5,yf# * 0.5,zf# * 0.5,TFormedX(),TFormedY(),TFormedZ())
   
   TFormPoint 0,0,-1,relpiv,0 ;Angriffspunkt (Gegenüber, sonst drift)
   TOKRB_ApplyImpulse2(rb,xf# * -0.5,yf# * -0.5,zf# * -0.5,TFormedX(),TFormedY(),TFormedZ())
   
   ;In Y-Richtung (Pitch)
   TFormNormal 0,1,0,relpiv,0
   
   xf# = TFormedX() * pitch#
   yf# = TFormedY() * pitch#
   zf# = TFormedZ() * pitch#
   
   TFormPoint 0,0,1,relpiv,0 ;Angriffspunkt
   TOKRB_ApplyImpulse2(rb,xf# * 0.5,yf# * 0.5,zf# * 0.5,TFormedX(),TFormedY(),TFormedZ())
   
   TFormPoint 0,0,-1,relpiv,0 ;Angriffspunkt (Gegenüber, sonst drift)
   TOKRB_ApplyImpulse2(rb,xf# * -0.5,yf# * -0.5,zf# * -0.5,TFormedX(),TFormedY(),TFormedZ())

   ;In Z-Richtung (roll)
   TFormNormal 0,-1,0,relpiv,0
   
   xf# = TFormedX() * roll#
   yf# = TFormedY() * roll#
   zf# = TFormedZ() * roll#
   
   TFormPoint 1,0,0,relpiv,0 ;Angriffspunkt
   TOKRB_ApplyImpulse2(rb,xf# * 0.5,yf# * 0.5,zf# * 0.5,TFormedX(),TFormedY(),TFormedZ())
   
   TFormPoint -1,0,0,relpiv,0 ;Angriffspunkt (Gegenüber, sonst drift)
   TOKRB_ApplyImpulse2(rb,xf# * -0.5,yf# * -0.5,zf# * -0.5,TFormedX(),TFormedY(),TFormedZ())

   
End Function

Function setpivot(rb)
   
   PositionEntity relpiv,TOKRB_GetX(rb),TOKRB_GetY(rb),TOKRB_GetZ(rb)
   RotateEntity relpiv,TOKRB_GetPitch(rb),TOKRB_GetYaw(rb),TOKRB_GetRoll(rb)   
   
   
End Function

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group