Sign in to follow this  

C++ to C#

This topic is 3936 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

does anyone know what the equivalent of this is in C#?
void LoadXFile( char* MeshFilename, ID3DXMesh* &Mesh )
{
	//Zero Mesh and create buffer
	Mesh = 0;
	ID3DXBuffer* MeshBuffer  = 0;

	//Load and optimize the mesh
	D3DXLoadMeshFromX( MeshFilename, D3DXMESH_MANAGED, D3DDevice, &MeshBuffer, 0, 0, 0, &Mesh);
	Mesh->OptimizeInplace( D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT | D3DXMESHOPT_VERTEXCACHE, (DWORD*)MeshBuffer->GetBufferPointer(), 0, 0, 0);

	//Release and zero the buffer
	MeshBuffer->Release(); MeshBuffer = NULL;
}

Share this post


Link to post
Share on other sites
Mesh mesh = LoadMeshFromX("model.x");
GraphicsStream stm = mesh.VertexBuffer.Lock(0, 0, LockFlags.None);
mesh.OptimizeInPlace(MeshFlags.OptimizeCompact, stm);

I hope this helps.
take care.

Share this post


Link to post
Share on other sites
This is closer:


Mesh mesh = Mesh.FromFile(MeshFilename, MeshFlags.Managed, device);
Microsoft.DirectX.GraphicsStream meshBuffer = mesh.VertexBuffer.Lock(0, 0, LockFlags.None);
mesh.OptimizeInPlace(MeshFlags.OptimizeAttributeSort | MeshFlags.OptimizeCompact | MeshFlags.OptimizeVertexCache, meshBuffer);
meshBuffer.Dispose();



Only thing I'm a bit fuzzy on is what flags to use when locking the vertex buffer. You may need to fiddle with that some.

Share this post


Link to post
Share on other sites

This topic is 3936 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this