Einzelnen Beitrag anzeigen

Benutzerbild von Corpsman
Corpsman

Registriert seit: 8. Nov 2005
Ort: nähe Stuttgart
981 Beiträge
 
Delphi XE2 Professional
 
#10

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 15:31
Ich glaube ich mus mich für das Code Chaos in meinem Sample erst mal entschukdigen,

Das mit dem Array war mir auch aufgefallen.

Ich habe mir gerade das NewtonBasic Demo noch mal rein gezogen.

Und damit Folgendes Gemacht.

Delphi-Quellcode:

Procedure InitNewton;
Var
  TmpV: TVector3f;
  i: Integer;
  Arr: Array[0..1] Of pNewtonbody;
  Arr1: Array[0..1] Of PNewtonCollision;
  Collision2, Collision1: PNewtonCollision;
  Matrix: TMatrix4f; // Used to retrieve the matrix from newton

Begin
  Randomize;
  NewtonWorld := NewtonCreate(Nil, Nil);

  Collision1 := NewtonCreateBox(NewtonWorld, 1, 1, 1, Nil);
  Collision2 := NewtonCreateBox(NewtonWorld, 1, 1, 1, Nil);
  // Create the rigid body

  // NewtonBody := NewtonCreateBody(NewtonWorld, Collision);
  // Remove the collider, we don't need it anymore

  // Now we calculate the moment of intertia for this box. Note that a correct
  // moment of inertia is CRUCIAL for the CORRECT PHYSICAL BEHAVIOUR of a body,
  // so we use an special equation for calculating it
{  Inertia.x := pMass * (pSize.y * pSize.y + pSize.z * pSize.z) / 12;
  Inertia.y := pMass * (pSize.x * pSize.x + pSize.z * pSize.z) / 12;
  Inertia.z := pMass * (pSize.x * pSize.x + pSize.y * pSize.y) / 12;
}

  te := Combine(Collision1, Collision2);

  NewtonBody1 := NewtonCreateBody(NewtonWorld, Te);

  NewtonReleaseCollision(NewtonWorld, Te); // Wenn wir das machen könne wir es nicht mehr an CompundCollsiion übergeben.

  // Set the bodies mass and moment of inertia
  NewtonBodySetMassMatrix(NewtonBody1, 10, 160, 160, 160);
  // Now set the position of the body's matrix
  NewtonBodyGetMatrix(NewtonBody1, @Matrix[0, 0]);
  Matrix[3, 0] := 4;
  Matrix[3, 1] := 15;
  Matrix[3, 2] := 1;
  NewtonBodySetMatrix(NewtonBody1, @Matrix[0, 0]);
  // Finally set the callback in which the forces on this body will be applied
  NewtonBodySetForceAndTorqueCallBack(NewtonBody1, ForceAndTorqueCallBack);
Sieht Caotisch aus , und noch viel schlimmer ich habe keine Ahnung wo ich nun meine Renderfucntion hinpacken soll.

Aber der Pointer Newtonbody1 hat nun irgendwas bekommen, da meine Renderfunction anzeigt das die y - Coordinate fällt, was bedeuten würde das ich es zumindest geschafft habe ein Object in der Newtonwelt zu erstellen.

Ich lade nun nochmals die Unit1 hoch das ihr euch das ansehen könnt, der Rest hat sich ja nicht geändert.
Angehängte Dateien
Dateityp: pas unit1_231.pas (24,7 KB, 3x aufgerufen)
Uwe
My Sitewww.Corpsman.de

My marble madness clone Balanced ( ca. 70,0 mb ) aktuell ver 2.01
  Mit Zitat antworten Zitat