Jump to content
  • Advertisement
Sign in to follow this  
perkbrian

C++ to C#

This topic is 4215 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!