Since it is possible to create procedural models (at least for static models), it seems reasonable that similar approach should work for creating skinned models
Issue #1:
Using _skinnedMesh.UpdateMesh(…) will crash Flax Editor and built game with Assertion Failed
[ 00:02:41.533 ]: [Error] Assertion failed!
File: C:\Flax\FlaxEngine\Source\Engine\Graphics\Models\SkinnedMesh.cpp
Line: 76
Expression: positionStream.IsLinear(PixelFormat::R32G32B32_Float)
================================================================
[ 00:02:41.533 ]: [Error] Critical error! Reason: Assertion failed!
File: C:\Flax\FlaxEngine\Source\Engine\Graphics\Models\SkinnedMesh.cpp
Line: 76
Expression: positionStream.IsLinear(PixelFormat::R32G32B32_Float)
[ 00:02:41.620 ]: [Error] Stack trace:
[ 00:02:41.620 ]: [Error] at FlaxEditor.exe!PlatformBase::Assert() in C:\Flax\FlaxEngine\Source\Engine\Platform\Base\PlatformBase.cpp:line 573
[ 00:02:41.620 ]: [Error] at FlaxEditor.exe!`anonymous namespace'::UpdateMesh() in C:\Flax\FlaxEngine\Source\Engine\Graphics\Models\SkinnedMesh.cpp:line 76
[ 00:02:41.620 ]: [Error] at FlaxEditor.exe!SkinnedMesh::UpdateMeshUInt() in C:\Flax\FlaxEngine\Source\Engine\Graphics\Models\SkinnedMesh.cpp:line 415
[ 00:02:41.620 ]: [Error] at FlaxEditor.exe!SkinnedMeshInternal::UpdateMeshUInt() in C:\Flax\FlaxEngine\Cache\Intermediate\FlaxEditor\Windows\x64\Development\Graphics\Graphics.Bindings.Gen.cpp:line 5203
[ 00:02:41.620 ]: [Error] at 0x7ffcbc6cad17
Is the code below using the right approach? Or should something be done differently?
public override void OnStart()
{
Float3[] vertices = new[]
{
new Float3(0.1f, 0.1f, 0.1f),
new Float3(2.1f, 0.1f, 0.1f),
new Float3(0.1f, 1.1f, 0.1f),
new Float3(1.1f, 1.1f, 0.1f)
};
uint[] indecies = new uint[]
{
//front face
0, 1, 2,
2, 1, 3
};
Color[] colors = new Color[]
{
new Color(222,0,0,0),
new Color(0,222,0,0),
new Color(222,0,222,0),
new Color(222,222,1,0)
};
Int4[] blendIndices = new Int4[vertices.Length];
Float4[] blendWeights = new Float4[vertices.Length];
blendWeights = new Float4[]
{
new Float4(1,0,0,0),
new Float4(1,0,0,0),
new Float4(1,0,0,0),
new Float4(1,0,0,0)
}
;
SkinnedModel _skinnedModel = Content.CreateVirtualAsset<SkinnedModel>();
_skinnedModel.SetupLODs(new[] { 1 });
_skinnedModel.LODs[0].Meshes[0].UpdateMesh(vertices, indecies, blendIndices, blendWeights);
Issue #2:
MeshAccessor allows to set Positions, Indecies, Normals, Tangents, Colors … but can only get BlendIndecies and BlendWeights. Would be nice to be able to set those also.