• Advertisement
Sign in to follow this  

[SlimDX]listvector 3 to byte[]

This topic is 2740 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have saved the positions of my vertex in list of vector3.
i want to create a mesh with that vector3 list, and i have made this:
Mesh malla = new Mesh(myDevice, myCustomMesh.facesList.Count, myCustomMesh.numberOfVertex, MeshFlags.Managed, VertexFormat.Position | VertexFormat.Texture1);
DataStream indexBuffer = malla.LockIndexBuffer(LockFlags.None);
DataStream vertexBuffer = malla.LockVertexBuffer(LockFlags.None);

Now i need to write the vector3 list to the vertexbuffer, so i suppose that the first thing i have to made is pass the vector3 list data to a byte[] buffer; to write it into the vertexBuffer using
vertexBuffer.Write(buffer,0,buffer.Length);


How can i pass the data from the vector3 list to a byte[]?

Share this post


Link to post
Share on other sites
Advertisement
Finally i made this:

 public Mesh createMesh(CustomMesh myCustomMesh)
{
Mesh malla = new Mesh(myDevice, myCustomMesh.facesList.Count, myCustomMesh.numberOfVertex, MeshFlags.Managed, VertexFormat.Position | VertexFormat.Texture1);
DataStream indexBuffer = malla.LockIndexBuffer(LockFlags.None);
DataStream vertexBuffer = malla.LockVertexBuffer(LockFlags.None);

foreach (Vector3 v in myCustomMesh.verticesList)
{
vertexBuffer.Write<Vector3>(v);
}
for (int i = 0; i < myCustomMesh.facesList.Count; i++)
{
ushort index;
index = (ushort)myCustomMesh.facesList.X;
indexBuffer.Write<ushort>(index);

index = (ushort)myCustomMesh.facesList.Y;
indexBuffer.Write<ushort>(index);

index = (ushort)myCustomMesh.facesList.Z;
indexBuffer.Write<ushort>(index);
}
return malla;
}


Now i would like to know if with this code i have all the vertex and indices data into the new mesh, or i have to make something more and also if i have to release the buffers

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement