# ConvertToBlendedMesh(..) in C#

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

## Recommended Posts

Greetings, I'm having some trouble getting ConvertToBlendedMesh(..) to work in C#.
				int faces;
Direct3D.BoneCombination[] bones = null;
try
{
mesh.SkinnedMesh = mesh.SkinInformation.ConvertToBlendedMesh(mesh.MeshData.Mesh, Direct3D.MeshFlags.Managed | Direct3D.MeshFlags.OptimizeVertexCache, mesh.GetAdjacencyStream(), out faces, out bones);
}
catch(Direct3D.Direct3DXException e)
{
Console.WriteLine(e.ErrorString);
}


My program loads and shows non skinned models perfectly, it even plays animations perfectly. Now I'm trying to add blended mesh support. I have been studying how the DX mesh viewer (MView) sets up their SkinnedMesh, but this part isn't translating well to C#. When I run my program, this code snippet catches an "Error in application" exception with DX error code D3DERR_INVALIDCALL. The program then continues, loads, and displays the mesh without animation because there's no skinning info setup. I think the error has to do with the BoneCombination. In the C++ version, you pass a reference to a NULLed DXBUFFER pointer then that gets boxed into the BoneCombination. But the C# version requires an out directly to the BoneCombination array. So obviously I tried making it null like the C++ buffer. It errors. I tried to initialise it to an array with a size equal to the number of bones, that returned the same error. If anyone knows how to do this, or has some sample C# source in setting up a skinned mesh, that would be very helpful.

##### Share on other sites
Have you tried ConvertToIndexedBlendedMesh() instead? Thats what ive used in the past.

##### Share on other sites
I have not tried it yet, and I will try it now.

I'm not quite sure what the Indexed version is. But I got the feeling it was just the same thing with more output information. I'm not sure if this is going to fix the problem, But I'll see.

If anyone knows what's wrong with the non-indexed version I'll still be curious.

Thanks

##### Share on other sites
Just FYI IndexedBlendedMesh is not supported in hardware on the vast majority of cards as FFP skinning really wasn't needed once shaders became available. You will have to use Mixed or Software VP if you are using Indexed whereas blended is supported in hardware.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 9
• 9
• 34
• 16
• ### Forum Statistics

• Total Topics
634123
• Total Posts
3015654
×