Well, it seems that the fantastic .net wrapper avaialbe in sourceforge has been discontinuity. So, i'm doing a new one, but this time trying and putting examples about workint with it.
I'm just beginnig, so...be patient, and please..¡help me!
Ok. The first one, the mini Wrapper:
#region Using directives
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices; // DllImport
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
#endregion
namespace Haddd.Core
{
public class NewtonWrapper
{
[DllImport("Newton2.Dll")]
public static extern int NewtonCreate(int a, int b);
[DllImport("Newton2.Dll")]
public static extern int NewtonCreateBox(int newtonWorld, float dx, float dy, float dz, float[] offsetMatrix);
[DllImport("Newton2.Dll")]
public static extern int NewtonCreateBody(int newtonWorld, int collisionPtr);
[DllImport("Newton2.Dll")]
public static extern void NewtonReleaseCollision(int newtonWorld, int collisionPtr);
[DllImport("Newton2.Dll")]
public static extern void NewtonBodySetMassMatrix(int bodyPtr, float mass, float Ixx, float Iyy, float Izz);
[DllImport("Newton2.Dll")]
public static extern void NewtonBodySetMatrix(int bodyPtr, ref Matrix matrix);
[DllImport("Newton2.Dll")]
public static extern void NewtonBodySetOmega(int bodyPtr, ref Vector3 omega);
[DllImport("Newton2.Dll")]
public static extern void NewtonUpdate(int newtonWorld, float timestep);
[DllImport("Newton2.Dll")]
public static extern void NewtonBodyGetMatrix(int bodyPtr,ref Matrix matrix);
}
}
And the little example:
Creation:
nWorld = NewtonWrapper.NewtonCreate(0, 0);
// create the collsion shape
collision = NewtonWrapper.NewtonCreateBox(nWorld, 2.0f, 2.0f, 2.0f, null);
ribidBodyBox = NewtonWrapper.NewtonCreateBody(nWorld, collision);
NewtonWrapper.NewtonReleaseCollision(nWorld, collision);
NewtonWrapper.NewtonBodySetMassMatrix(ribidBodyBox, 1.0f, 1.0f, 1.0f, 1.0f);
Matrix mat = Matrix.Identity;
NewtonWrapper.NewtonBodySetMatrix(ribidBodyBox, ref mat);
Vector3 omega = new Vector3(5, 5, 5);
NewtonWrapper.NewtonBodySetOmega(ribidBodyBox,ref omega);
Update:
NewtonWrapper.NewtonUpdate(nWorld, Haddd.Timer.DeltaTime);
Matrix matrix=Matrix.Zero;
NewtonWrapper.NewtonBodyGetMatrix(ribidBodyBox, ref matrix);
cubo.AbsoluteTM = matrix;
It's the first example in the SDK, but C# and MDX compliant.