[C++ & C#] Convert Vertex[] to Float[] ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
JDHunter
Posts: 17
Joined: Tue Jun 20, 2006 6:15 am
Location: Germany
Contact:

[C++ & C#] Convert Vertex[] to Float[] ?

Post by JDHunter »

Hello,

i working on convert from the ODE Tut
There where "Converting Irrlicht Meshes to ODE TriMesh"

The Problem is how can/must i convert a Vertex[] to a Float[] in C#?


I have a problem with understanding the way of c++ :roll:
There was deklair a Vector3-Array (vertices[])
Now there where fill with value (vertices[cv][0]=mb_vertices[j].Pos.X,...)
Later... a Function would like a Array of Float with Vertex Datas. The Vector3-Array will consign to (dReal*)vertices.

Code: Select all

vertices=new dVector3[vertexcount];

for(j=0;j<mb->getVertexCount();j++){
  vertices[cv][0]=mb_vertices[j].Pos.X;
  vertices[cv][1]=mb_vertices[j].Pos.Y;
  vertices[cv][2]=mb_vertices[j].Pos.Z;
  cv++;
} 

dGeomTriMeshDataBuildSimple(data,(dReal*)vertices, vertexcount, indices, indexcount);
This Code in C# turns Error's i now, but i'm not sure like this is right

Code: Select all

vertices = new Vector3[vertexcount]; 

for(j=0;j<mb.VertexCount;j++){
  vertices[cv] = mb.GetVertex(j).Position;
  cv++;
}

GeomTriMeshDataBuildSimple(data,(float[])vertices, vertexcount, indices, indexcount);
Thanks in advance
JDHunter
Posts: 17
Joined: Tue Jun 20, 2006 6:15 am
Location: Germany
Contact:

Post by JDHunter »

OK Cleared!

I had became help of a other forum.

Code: Select all

float[] vertices = new float[vertexnum*3]

for (int i =0; i<mb.GetVertexCount();i++)
{
  vertices[cv]=mb_vertices[i].Pos.X;
  vertices[cv+1]=mb_vertices[i].Pos.Y;
  vertices[cv+2]=mb_vertices[i].Pos.Z;
cv+=3;
} 
Post Reply