Jump to content
  • Advertisement
Sign in to follow this  

C++ to C#

This topic is 4299 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);

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!