Hey guys,
i'm using the .NET wrapper for horde. I want to use the
getNodeTransformMatrices function to save a transform matrix in my own c#-matrix class.
In C++, this would be easy by saving the returned matrix in a Pointer, which could be used as a 2-dimensional float-pointer - you can use this pointer at once as a matrix type. I'm not a good C++-programmer (thats why i use the .net-wrapper), but our prof gave us this solution how to handle the matrix in C++:
Code:
float *pxf ;
Horde3D :: getNodeTransformMatrices (plane , NULL , ( const float **) &pxf );
Matrix44f planeXform ;
planeXform .set (pxf );
In the C#-Wrapper, the getNodeTransformMatrices needs a struct of the type
IntPtr to save its values to.
Code:
IntPtr hordePointer;
// write Horde matrix to Intpointer
Horde3D.getNodeTransformMatrices(env, out test, out hordePointer);
Now i have the matrix returned by horde in one Intpointer. I found out that the size of this pointer (returned by
Marshal.SizeOf(hordePointer) is 4.
So i guess this Intpointer points itself to 4 Intpointers. Each of this Intpointers should contain 4 float values, that represent the Transformation Matrix.
Code:
IntPtr[] testArray = new IntPtr[4];
// get the 4 intpointers out of the hordepointer
for (int i = 0; i < Marshal.SizeOf(hordePointer); i++) {
testArray[i] = Marshal.ReadIntPtr(hordePointer, i * Marshal.SizeOf(typeof (IntPtr)));
}
Now i have 4 Intpointers. My problem now: how do i extract the 4 float values out of each intpointer? I guess i'm not far away from a solution... Anyone here good some experience in handling pointers in C#?
Thanks very much in advance for your help!