protected void SetSkinnedMeshAnimationInfo() { if (!SelfSkinning && skinnedMeshRenderer != null) { Matrix4x4[] rendererBindPoses = sharedMesh.bindposes; BoneWeight[] rendererWeights = sharedMesh.boneWeights; float[] bindPoses = new float[16 * rendererBindPoses.Length]; for (int p = 0; p < rendererBindPoses.Length; ++p) { for (int i = 0; i < 16; ++i) { bindPoses[p * 16 + i] = rendererBindPoses[p][i]; } } Oni.BoneWeights[] weights = new Oni.BoneWeights[rendererWeights.Length]; for (int i = 0; i < rendererWeights.Length; ++i) { weights[i] = new Oni.BoneWeights(rendererWeights[i]); } Oni.SetDeformableMeshAnimationData(deformableMesh, bindPoses, weights, rendererBindPoses.Length); } }
/** * If a Skinned Mesh Renderer is present, grabs bind poses and skin weights and transfers it to the particle simulation. * Does nothing if no Skinned Mesh Renderer can be found. */ public void UpdateBindPosesAndWeights() { if (skinnedMeshRenderer != null) { Matrix4x4[] rendererBindPoses = sharedMesh.bindposes; BoneWeight[] rendererWeights = sharedMesh.boneWeights; rendererBones = skinnedMeshRenderer.bones; bindPoseData = new float[16 * rendererBindPoses.Length]; boneData = new float[16 * rendererBones.Length]; // get bind pose data: for (int p = 0; p < rendererBindPoses.Length; ++p) { for (int i = 0; i < 16; ++i) { bindPoseData[p * 16 + i] = rendererBindPoses[p][i]; } } // get weights data: Oni.BoneWeights[] weights = new Oni.BoneWeights[rendererWeights.Length]; for (int i = 0; i < rendererWeights.Length; ++i) { weights[i] = new Oni.BoneWeights(rendererWeights[i]); } Oni.SetDeformableMeshAnimationData(deformableMesh, bindPoseData, weights, rendererBindPoses.Length); } }