AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Kennt hier Jemand die Function NewtoncreateCompoundCollision
Thema durchsuchen
Ansicht
Themen-Optionen

Kennt hier Jemand die Function NewtoncreateCompoundCollision

Ein Thema von Corpsman · begonnen am 12. Jun 2006 · letzter Beitrag vom 13. Jun 2006
Antwort Antwort
Seite 1 von 2  1 2      
Benutzerbild von Corpsman
Corpsman

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

Kennt hier Jemand die Function NewtoncreateCompoundCollision

  Alt 12. Jun 2006, 14:12
Hi,

Ich bin gerade mal wieder dabei ein kleines Spiel zu schreiben, diesmal in OpenGL und Newton.dll für Delphi.

Das Spiel Läuft auch schon wunderbar.

Nu wollte ich noch ein klein wenig was erweitern.

Das Prob ist nur,das das Forum für die Newton.dll auf English ist und die Irgendwie nur Antworten wenn man nach C++ Fragt oder was weis ich, mir antworten sie jedenfalls net.

Bis Jetzt habe ich es zumindest ganz Gut auch so geschafft.

Nur komme ich nun nicht mehr weiter.

Was ich machen will :

Ich habe Diverse Elemente in meiner Newtonwelt erstellt. ( Fast immer nur NewtonCreateBox )

Nun mus man denen dan eine Masse einen Schwerpunkt und eine Callback function geben für die Schwerkraft.

Alles Kein problem habe ich auch gemacht und läuft wunderbar.

Mein Prob ist das ich 2 dieser Objecte zu einem Zusammenfassen will, Laut dem Newton Forum soll das Gehen.

Ich habe es mit
Delphi-Quellcode:
Function Combine(box1, Box2: Pnewtonbody): PNewtonCollision;
Var
  Arr: Array[0..1] Of pNewtonbody;
Begin
  Arr[0] := Box1;
  Arr[1] := Box2;
  Result := newtoncreateCompoundCollision(newtonworld, 2, @arr);
End;
Probiert aber es geschieht nichts.

nu seid Ihr meine Letzte Hoffnung.

Gibts hier vielleicht jemanden der Weis wie's geht ?
Uwe
My Sitewww.Corpsman.de

My marble madness clone Balanced ( ca. 70,0 mb ) aktuell ver 2.01
  Mit Zitat antworten Zitat
Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#2

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 14:17
Ich nicht persönlich, aber bei delphigl.com/forum gibts einige.
Sascha Willems ist leider kaum mehr aktiv.
Ich kann dir leider persönlich jetzt nicht mehr sagen, hab grad was anderes zu tun, sorry.
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat
TurboMartin

Registriert seit: 13. Feb 2006
Ort: Bad Honnef
765 Beiträge
 
Turbo Delphi für Win32
 
#3

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 14:35
Ich weiß zwar nicht, wie du C kannst, aber vielleicht hilft das:
Code:
********************************************************************************************** 
// 
// complex collision primitives creation functions
// note: can only be used with static bodies (bodies with infinite mass)
// 
// ********************************************************************************************** 
inline NewtonCollision* NewtonCreateCompoundCollision (const NewtonWorld* newtonWorld, int count,
                                             NewtonCollision* const collisionPrimitiveArray[])

   assert(count >= 0);
   for (int i = 0; i < count; ++i)
      assert(collisionPrimitiveArray[i]);
   return nw::NewtonCreateCompoundCollision(newtonWorld, count, collisionPrimitiveArray);


inline NewtonCollision* NewtonCreateUserMeshCollision (const NewtonWorld* newtonWorld, const float *minBox,
                                             const float *maxBox, void *userData, NewtonUserMeshCollisionCollideCallback collideCallback,
                                             NewtonUserMeshCollisionRayHitCallback rayHitCallback, NewtonUserMeshCollisionDestroyCallback destroyCallback)

   NewtonValidateVector(minBox);
   NewtonValidateVector(maxBox);
   return nw::NewtonCreateUserMeshCollision(newtonWorld, minBox, maxBox, userData, collideCallback, rayHitCallback, destroyCallback);


//
Tomorrow will be cancelled due to lack of interest.

  Mit Zitat antworten Zitat
Benutzerbild von Corpsman
Corpsman

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

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 14:41
Der Code den du da hast ist Gegoogelt. Den Habe ich auch gefunden und daraus ja meine Combine Function gemacht.

Sie Tut nur leider net.
Uwe
My Sitewww.Corpsman.de

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

Registriert seit: 13. Feb 2006
Ort: Bad Honnef
765 Beiträge
 
Turbo Delphi für Win32
 
#5

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 14:52
Zitat von Corpsman:
Ich habe es mit
Delphi-Quellcode:
Function Combine(box1, Box2: Pnewtonbody): PNewtonCollision;
Var
  Arr: Array[0..1] Of pNewtonbody;
Begin
  Arr[0] := Box1;
  Arr[1] := Box2;
  Result := newtoncreateCompoundCollision(newtonworld, 2, @arr);
End;
Probiert aber es geschieht nichts.
mach mal

Delphi-Quellcode:
Function Combine(box1, Box2: Pnewtonbody): PNewtonCollision;
Var
  Arr: Array[0..1] Of pNewtonbody;
Begin
  Arr[0] := Box1;
  Arr[1] := Box2;
  Result := NewtonCreateCompoundCollision(newtonworld, 1, @Arr);
End;
und bind newtonwrap.cpp oder newtonwrap.h in den Code ein.
Danach stellst du bei den Projektoptionen ein, dass er C++-Code erzeugen soll.

PS: is nicht gegoogelt ist vonhier!
Tomorrow will be cancelled due to lack of interest.

  Mit Zitat antworten Zitat
Benutzerbild von DGL-luke
DGL-luke

Registriert seit: 1. Apr 2005
Ort: Bad Tölz
4.149 Beiträge
 
Delphi 2006 Professional
 
#6

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 14:54
@TurboMartin:

C einbinden

@Corpsman: Arbeitest du mit Sascah Willems' Pascal-headern? http://newton.delphigl.de ?
Lukas Erlacher
Suche Grafiktablett. Spenden/Gebrauchtangebote willkommen.
Gotteskrieger gesucht!
For it is the chief characteristic of the religion of science that it works. - Isaac Asimov, Foundation I, Buch 1
  Mit Zitat antworten Zitat
TurboMartin

Registriert seit: 13. Feb 2006
Ort: Bad Honnef
765 Beiträge
 
Turbo Delphi für Win32
 
#7

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 15:03
Zitat von DGL-luke:
@TurboMartin:

C einbinden
Wieso nicht?
Bei mir ging es ma, aber seit dem Delphi 7 auf dem einen Rechner kaputt ist, und nicht reparierbar ist, ohne Windows neu aufzusetzen, weiß ich nicht mehr genau wie.
Tomorrow will be cancelled due to lack of interest.

  Mit Zitat antworten Zitat
Benutzerbild von Corpsman
Corpsman

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

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 15:08
Also die Inteer Zahl gibt die Anzahl der Body's an diese ist ja 2 mit 1 tut es auch nicht, was du da mit dem C sach meinst verstehe ich net ganz.

Ich lade euch nu einfach mal das gesamte Sample mit hoch dann könnt ihr euch das Chaos selbst ansehen

Übrigens Progge ich mit D5 Prof.
Und Ja ich benutze diese Header Files
Angehängte Dateien
Dateityp: zip newton_problem_377.zip (404,9 KB, 4x aufgerufen)
Uwe
My Sitewww.Corpsman.de

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

Registriert seit: 13. Feb 2006
Ort: Bad Honnef
765 Beiträge
 
Turbo Delphi für Win32
 
#9

Re: Kennt hier Jemand die Function NewtoncreateCompoundColli

  Alt 12. Jun 2006, 15:27
Zitat von NewtonImport.pas:
Delphi-Quellcode:
function NewtonCreateCompoundCollision( const newtonWorld : PNewtonWorld; count : int;
                                        const collisionPrimitiveArray : TcollisionPrimitiveArray ) : PNewtonCollision; cdecl; external{$IFDEF __GPC__}name 'NewtonCreateCompoundCollision'{$ELSE}NewtonDLL{$ENDIF __GPC__};
Ich glaub, du brauchst einen anderen Array:  const collisionPrimitiveArray : TcollisionPrimitiveArray Edit:
Musst du noch einfügen:
Delphi-Quellcode:
type
  TCollisionPrimitiveArray = array of PNewtonCollision;
Tomorrow will be cancelled due to lack of interest.

  Mit Zitat antworten Zitat
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
Antwort Antwort
Seite 1 von 2  1 2      


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:29 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz