warrantyvoider wrote:Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FBXWrapper;
namespace PluginSystem
{
public class FBXExporter
{
public FBXVector4 CalculateBoneRotation(FBBone bone)
{
FBXAMatrix fbxrotMat = new FBXAMatrix();
FBXVector4 Forward = new FBXVector4(bone.Forward.members[0], bone.Forward.members[1], bone.Forward.members[2], 0);
FBXVector4 Right = new FBXVector4(bone.Right.members[0], bone.Right.members[1], bone.Right.members[2], 0);
FBXVector4 Up = new FBXVector4(bone.Up.members[0], bone.Up.members[1], bone.Up.members[2], 0);
fbxrotMat.SetRow(0, Right);
fbxrotMat.SetRow(1, Up);
fbxrotMat.SetRow(2, Forward);
fbxrotMat.SetRow(3, new FBXVector4(0, 0, 0, 1));
FBXVector4 boneRot = fbxrotMat.getR();
return boneRot;
}
public void UpdateSkeletonWithMorph(SkeletonAsset Skeleton, FBXNode pSkeletonNode, List<Vector> morphBones)
{
for (int i = 0; i < Skeleton.Bones.Count; i++)
{
FBBone fbbone = Skeleton.Bones[i];
FBXNode fbxBone = pSkeletonNode.FindChild(fbbone.Name);
Vector boneOffset = morphBones[i];
List<double> tmp = fbxBone.LclTranslation;
tmp[0] += boneOffset.members[0];
tmp[1] += boneOffset.members[1];
tmp[2] += boneOffset.members[2];
fbxBone.LclTranslation = tmp;
}
}
public void SetBoneTransform(FBBone bone, FBXNode fbxBoneNode)
{
List<double> tmp = new List<double>();
tmp.Add(bone.Location.members[0]);
tmp.Add(bone.Location.members[1]);
tmp.Add(bone.Location.members[2]);
fbxBoneNode.LclTranslation = tmp;
FBXVector4 rot = CalculateBoneRotation(bone);
tmp = new List<double>();
tmp.Add(rot.X);
tmp.Add(rot.Y);
tmp.Add(rot.Z);
fbxBoneNode.LclRotation = tmp;
}
}
}
comes along nicely already^^ but im running out of time today, see yall tomorrow
greetz
PS: FBXWrapper.h FBXWrapper.cpp
Hey,
Sorry, just saw your answers now. I didn't catch that you wanted to wrap all classes like that after reading your first post about it, because that's precisely what I didn't want to do at first
But anyway, I see the benefits of this approach.
So, do you want me to take over or are you well advanced so that there is no gain in it?
If you want me to finish, just drop me a line.
And again, great work, also with the quick fix the not-skinned mesh crashing...