private List <FLVER.Bone> GetAllBonesReferencedByVertex(FLVER2 f, FLVER2.Mesh m, FLVER.Vertex v) { if (!PrecalculatedBoneLists.ContainsKey(v)) { List <FLVER.Bone> result = new List <FLVER.Bone>(); for (var i = 0; i < v.BoneIndices.Length; i++) { var vertBoneIndex = v.BoneIndices[i]; if (vertBoneIndex >= 0) { if (Importer.JOBCONFIG.UseDirectBoneIndices) { result.Add(f.Bones[vertBoneIndex]); } else { if (m.BoneIndices[vertBoneIndex] >= 0) { result.Add(f.Bones[m.BoneIndices[vertBoneIndex]]); } } } } PrecalculatedBoneLists.Add(v, result); } return(PrecalculatedBoneLists[v]); }
private void LoadFLVER2(FLVER2 flver, bool useSecondUV, Dictionary <string, int> boneIndexRemap = null, bool ignoreStaticTransforms = false) { lock (_lock_submeshes) { Submeshes = new List <FlverSubmeshRenderer>(); } foreach (var submesh in flver.Meshes) { // Blacklist some materials that don't have good shaders and just make the viewer look like a mess MTD mtd = null;// InterrootLoader.GetMTD(Path.GetFileName(flver.Materials[submesh.MaterialIndex].MTD)); if (mtd != null) { if (mtd.ShaderPath.Contains("FRPG_Water_Env")) { continue; } if (mtd.ShaderPath.Contains("FRPG_Water_Reflect.spx")) { continue; } } var smm = new FlverSubmeshRenderer(this, flver, submesh, useSecondUV, boneIndexRemap, ignoreStaticTransforms); Bounds = new BoundingBox(); lock (_lock_submeshes) { Submeshes.Add(smm); Bounds = BoundingBox.CreateMerged(Bounds, smm.Bounds); } } }
Matrix GetParentBoneMatrix(FLVER2 f, FLVER.Bone bone) { FLVER.Bone parent = bone; var boneParentMatrix = Matrix.Identity; do { boneParentMatrix *= Matrix.CreateScale(parent.Scale.X, parent.Scale.Y, parent.Scale.Z); boneParentMatrix *= Matrix.CreateRotationX(parent.Rotation.X); boneParentMatrix *= Matrix.CreateRotationZ(parent.Rotation.Z); boneParentMatrix *= Matrix.CreateRotationY(parent.Rotation.Y); //boneParentMatrix *= Matrix.CreateRotationY(parent.EulerRadian.Y); //boneParentMatrix *= Matrix.CreateRotationZ(parent.EulerRadian.Z); //boneParentMatrix *= Matrix.CreateRotationX(parent.EulerRadian.X); boneParentMatrix *= Matrix.CreateTranslation(parent.Translation.X, parent.Translation.Y, parent.Translation.Z); //boneParentMatrix *= Matrix.CreateScale(parent.Scale); if (parent.ParentIndex >= 0) { parent = f.Bones[parent.ParentIndex]; } else { parent = null; } }while (parent != null); return(boneParentMatrix); }
public SkeletonExporter(FbxScene scene, FLVER2 flver, HKX.HKASkeleton hKASkeleton, List <DsBone> bones) { Scene = scene; this.Flver = flver; this.bones = bones; this.hkaSkeleton = hKASkeleton; }
private NewMesh LoadArmorMesh(IBinder partsbnd) { List <TPF> tpfs = new List <TPF>(); FLVER2 flver = null; foreach (var f in partsbnd.Files) { string nameCheck = f.Name.ToLower(); if (nameCheck.EndsWith(".tpf") || TPF.Is(f.Bytes)) { tpfs.Add(TPF.Read(f.Bytes)); } else if (flver == null && nameCheck.EndsWith(".flver") || FLVER2.Is(f.Bytes)) { flver = FLVER2.Read(f.Bytes); } } foreach (var tpf in tpfs) { TexturePool.AddTpf(tpf); } NewMesh mesh = null; if (flver != null) { mesh = new NewMesh(flver, false, boneIndexRemap); } Scene.RequestTextureLoad(); return(mesh); }
public void AddAllDummiesFromFlver(FLVER2 flver) { //var newDmy = new FLVER2.Dummy(); //newDmy.ReferenceID = 205; //newDmy.AttachBoneIndex = 19; //float newX = (-0.09398f / 2.25f) + 0.01f; //float newY = (((1.659459f) + (1.54340553f)) / 2) + 0.007f; //float newZ = (((-0.2146896f) + (-0.09559878f)) / 2) * 0.68f; //newDmy.Position = new System.Numerics.Vector3(newX, newY, newZ); //newDmy.Upward = new System.Numerics.Vector3(0, 1, 0); //newDmy.Forward = new System.Numerics.Vector3(0, 0, -1); //newDmy.UseUpwardVector = true; //newDmy.DummyBoneIndex = 59; //flver.Dummies.Add(newDmy); //newDmy = new FLVER2.Dummy(); //newDmy.ReferenceID = 205; //newDmy.AttachBoneIndex = 19; //newX = -((-0.09398f / 2.25f) + 0.01f); //newY = (((1.659459f) + (1.54340553f)) / 2) + 0.007f; //newZ = (((-0.2146896f) + (-0.09559878f)) / 2) * 0.68f; //newDmy.Position = new System.Numerics.Vector3(newX, newY, newZ); //newDmy.Upward = new System.Numerics.Vector3(0, 1, 0); //newDmy.Forward = new System.Numerics.Vector3(0, 0, -1); //newDmy.UseUpwardVector = true; //newDmy.DummyBoneIndex = 59; //flver.Dummies.Add(newDmy); //flver.Write(@"C:\Users\Meowmaritus\GitHub\DSAnimStudio\DSAnimStudio\bin\x64\Debug\OUTPUTFLVER.flver"); foreach (var d in flver.Dummies) { AddDummyPoly(d); } if (DummyPolyByRefID.ContainsKey(200)) { for (int i = 0; i < DummyPolyByRefID[200].Count; i++) { DummyPolyByRefID[200][i].DisableTextDraw = i > 0; } } }
public DsBone(FLVER.Bone flverBone, FLVER2 flver) { HkxBoneIndex = -1; Name = flverBone.Name; ParentName = flverBone.ParentIndex > 0 ? flver.Bones[flverBone.ParentIndex].Name : null; }
public void AddAllDummiesFromFlver(FLVER2 flver) { foreach (var d in flver.Dummies) { AddDummyPoly(d); } _dummyPolyByRefID = _dummyPolyByRefID.OrderBy(kvp => kvp.Key).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); }
private static ModelDataType GetModelDataType(byte[] fileContents) { if (FLVER2.Is(fileContents)) { return(ModelDataType.Flver); } if (HKX.Is(fileContents)) { return(ModelDataType.Hkx); } return(ModelDataType.Unk); }
public void FixAllBoundingBoxes(FLVER2 f) { PrecalculatedBoneLists.Clear(); foreach (var b in f.Bones) { SetBoneBoundingBox(f, b); //if (b.Name == "Dummy") // b.Name = "dymmy"; //else if (b.Name == "SFX") // b.Name = "SFX用"; } var submeshBBs = new List <BoundingBox>(); foreach (var sm in f.Meshes) { var bb = GetBoundingBox(sm.Vertices.Select(v => new Vector3(v.Position.X, v.Position.Y, v.Position.Z)).ToList()); if (bb.Max.LengthSquared() != 0 || bb.Min.LengthSquared() != 0) { submeshBBs.Add(bb); sm.BoundingBox = new FLVER2.Mesh.BoundingBoxes(); sm.BoundingBox.Min = bb.Min.ToNumerics(); sm.BoundingBox.Max = bb.Max.ToNumerics(); } else { sm.BoundingBox = null; } } if (submeshBBs.Count > 0) { var finalBB = submeshBBs[0]; for (int i = 1; i < submeshBBs.Count; i++) { finalBB = BoundingBox.CreateMerged(finalBB, submeshBBs[i]); } f.Header.BoundingBoxMin = new System.Numerics.Vector3(finalBB.Min.X, finalBB.Min.Y, finalBB.Min.Z); f.Header.BoundingBoxMax = new System.Numerics.Vector3(finalBB.Max.X, finalBB.Max.Y, finalBB.Max.Z); } else { f.Header.BoundingBoxMin = new System.Numerics.Vector3(float.MaxValue, float.MaxValue, float.MaxValue); f.Header.BoundingBoxMax = new System.Numerics.Vector3(float.MinValue, float.MinValue, float.MinValue); } }
public void AddAllDummiesFromFlver(FLVER2 flver) { foreach (var d in flver.Dummies) { AddDummyPoly(d); } if (DummyPolyByRefID.ContainsKey(200)) { for (int i = 0; i < DummyPolyByRefID[200].Count; i++) { DummyPolyByRefID[200][i].DisableTextDraw = i > 0; } } }
public Model(FLVER2 flver) { Type = ModelType.ModelTypeFlver; Submeshes = new List <FlverSubmeshRenderer>(); var subBoundsPoints = new List <Vector3>(); foreach (var submesh in flver.Meshes) { // Blacklist some materials that don't have good shaders and just make the viewer look like a mess MTD mtd = null;// InterrootLoader.GetMTD(Path.GetFileName(flver.Materials[submesh.MaterialIndex].MTD)); if (mtd != null) { if (mtd.ShaderPath.Contains("FRPG_Water_Env")) { continue; } if (mtd.ShaderPath.Contains("FRPG_Water_Reflect.spx")) { continue; } } var smm = new FlverSubmeshRenderer(this, flver, submesh); Submeshes.Add(smm); subBoundsPoints.Add(smm.Bounds.Min); subBoundsPoints.Add(smm.Bounds.Max); } //DEBUG// //Console.WriteLine($"{flver.Meshes[0].DefaultBoneIndex}"); //Console.WriteLine(); //Console.WriteLine(); //foreach (var mat in flver.Materials) //{ // Console.WriteLine($"{mat.Name}: {mat.MTD}"); //} ///////// if (Submeshes.Count == 0) { Bounds = new BoundingBox(); IsVisible = false; } else { Bounds = BoundingBox.CreateFromPoints(subBoundsPoints); } }
private static IEnumerable <DsBone> FixupDsBonesInternal(FLVER2 flver, HKX.HKASkeleton hkx) { if (hkx == null) { return(FixupDsBones(flver)); } if (flver == null) { return(FixupDsBones(hkx)); } return(flver.Bones.Join(hkx.Bones.GetArrayData().Elements, flverBone => flverBone.Name, hkxBone => hkxBone.Name.GetString(), (flverBone, hkxBone) => new DsBone(flverBone, flver, hkxBone, hkx) )); }
private void SetBoneBoundingBox(FLVER2 f, FLVER.Bone b) { var bb = GetBoundingBox(GetVerticesParentedToBone(f, b).Select(v => new Vector3(v.Position.X, v.Position.Y, v.Position.Z)).ToList()); if (bb.Max.LengthSquared() != 0 || bb.Min.LengthSquared() != 0) { var matrix = GetParentBoneMatrix(f, b); b.BoundingBoxMin = Vector3.Transform(bb.Min, Matrix.Invert(matrix)).ToNumerics(); b.BoundingBoxMax = Vector3.Transform(bb.Max, Matrix.Invert(matrix)).ToNumerics(); } else { b.BoundingBoxMin = new System.Numerics.Vector3(float.MaxValue, float.MaxValue, float.MaxValue); b.BoundingBoxMax = new System.Numerics.Vector3(float.MinValue, float.MinValue, float.MinValue); } }
private static Matrix4x4 CalculateGlobalTransformFlver(FLVER.Bone bone, FLVER2 flver) { Matrix4x4 localTransform = bone.ComputeLocalTransform(); //Matrix4x4 localTransform = Matrix4x4.CreateTranslation(bone.Translation) // * Matrix4x4.CreateRotationY(bone.Rotation.Y) // * Matrix4x4.CreateRotationY(bone.Rotation.Z) // * Matrix4x4.CreateRotationY(bone.Rotation.X) // * Matrix4x4.CreateScale(bone.Scale); if (bone.ParentIndex >= 0) { localTransform *= CalculateGlobalTransformFlver(flver.Bones[bone.ParentIndex], flver); } return(localTransform); }
private List <FLVER.Vertex> GetVerticesParentedToBone(FLVER2 f, FLVER.Bone b) { var result = new List <FLVER.Vertex>(); foreach (var sm in f.Meshes) { foreach (var v in sm.Vertices) { var bonesReferencedByThisShit = GetAllBonesReferencedByVertex(f, sm, v); if (bonesReferencedByThisShit.Contains(b)) { result.Add(v); } } } return(result); }
bool IResource._Load(string file, AccessLevel al, GameType type) { bool ret; if (type == GameType.DemonsSouls) { FlverDeS = FLVER0.Read(file); ret = LoadInternalDeS(al, type); } else { var cache = (al == AccessLevel.AccessGPUOptimizedOnly) ? GetCache() : null; Flver = FLVER2.Read(file, cache); ret = LoadInternal(al, type); ReleaseCache(cache); } return(ret); }
private static Matrix4x4 CalculateGlobalTransform(DsBoneData boneData, FLVER2 flver, HKX.HKASkeleton hkaSkeleton) { if (boneData.exportData.SoulsData.HkxBoneIndex >= 0) { System.Diagnostics.Debug.Assert(hkaSkeleton != null); System.Console.WriteLine("Using HKA transform"); return(CalculateGlobalTransformHka(boneData.exportData.SoulsData.HkxBoneIndex, hkaSkeleton)); } if (flver != null) { System.Console.WriteLine("Using FLVER transform"); return(CalculateGlobalTransformFlver(boneData.flverBone, flver)); } throw new System.ArgumentException("Can't calculate transform " + nameof(boneData)); }
public static IEnumerable <DsBone> FixupDsBones(FLVER2 flver, HKX.HKASkeleton hkx) { var skel = FixupDsBonesInternal(flver, hkx); Func <DsBone, DsBone> boneConversion = bone => { //if (bone.Name == "Pelvis") //{ // bone.ParentName = "RootRotXZ"; //} if (bone.Name == "Spine") { bone.ParentName = "Pelvis"; } return(bone); }; return(skel.Select(boneConversion)); }
/// <summary> /// Matches bones by name between skeletons and runs boneCheck on them. /// Will assert if a bone does not exist in reimported skeleton or if a bone exists /// twice in reimported skeleton, depending on the bool parameters. /// </summary> public static void AssertReimportedSkeletonMatch(FLVER2 original, FLVER2 reimported, Action <FLVER.Bone, FLVER.Bone> boneCheck, bool assertOnBoneNotExisting = true, bool assertOnBoneExistingTwice = true) { foreach (var bone in original.Bones) { var matchingBoneList = reimported.Bones.Where(b => b.Name == bone.Name).ToList(); if (assertOnBoneNotExisting && matchingBoneList.Count == 0) { throw new SapTestAssert($"Bone '{bone.Name}' was not defined in the reimported skeleton."); } if (assertOnBoneExistingTwice && matchingBoneList.Count > 1) { throw new SapTestAssert($"Bone '{bone.Name}' was defined multiple times in the reimported skeleton."); } if (matchingBoneList.Count > 0) { var match = matchingBoneList[0]; boneCheck.Invoke(bone, match); } } }
private void LoadFLVER2(FLVER2 flver, bool useSecondUV, int baseDmyPolyID = 0, bool ignoreStaticTransforms = false) { Type = ModelType.ModelTypeFlver; Skeleton = new NewAnimSkeleton(this, flver.Bones); MainMesh = new NewMesh(flver, useSecondUV, null, ignoreStaticTransforms); Bounds = MainMesh.Bounds; DummyPolyMan.AddAllDummiesFromFlver(flver); //DEBUG// //Console.WriteLine($"{flver.Meshes[0].DefaultBoneIndex}"); //Console.WriteLine(); //Console.WriteLine(); //foreach (var mat in flver.Materials) //{ // Console.WriteLine($"{mat.Name}: {mat.MTD}"); //} ///////// }
private bool LoadInternalDeS(AccessLevel al, GameType type) { if (al == AccessLevel.AccessFull || al == AccessLevel.AccessGPUOptimizedOnly) { GPUMeshes = new FlverSubmesh[FlverDeS.Meshes.Count()]; GPUMaterials = new FlverMaterial[FlverDeS.Materials.Count()]; Bounds = new BoundingBox(); Bones = FlverDeS.Bones; for (int i = 0; i < FlverDeS.Materials.Count(); i++) { GPUMaterials[i] = new FlverMaterial(); ProcessMaterial(FlverDeS.Materials[i], GPUMaterials[i], type); } for (int i = 0; i < FlverDeS.Meshes.Count(); i++) { GPUMeshes[i] = new FlverSubmesh(); ProcessMesh(FlverDeS.Meshes[i], GPUMeshes[i]); if (i == 0) { Bounds = GPUMeshes[i].Bounds; } else { Bounds = BoundingBox.Combine(Bounds, GPUMeshes[i].Bounds); } } } if (al == AccessLevel.AccessGPUOptimizedOnly) { Flver = null; } //return false; return(true); }
public void LoadFlver(FLVER2 flver, MeshRenderableProxy proxy) { var meshesNode = new NamedEntity(this, null, "Meshes"); Objects.Add(meshesNode); RootObject.AddChild(meshesNode); for (int i = 0; i < flver.Meshes.Count; i++) { var meshnode = new NamedEntity(this, flver.Meshes[i], $@"mesh_{i}"); if (proxy.Submeshes.Count > 0) { meshnode.RenderSceneMesh = proxy.Submeshes[i]; proxy.Submeshes[i].SetSelectable(meshnode); } Objects.Add(meshnode); meshesNode.AddChild(meshnode); } var materialsNode = new NamedEntity(this, null, "Materials"); Objects.Add(materialsNode); RootObject.AddChild(materialsNode); for (int i = 0; i < flver.Materials.Count; i++) { var matnode = new Entity(this, flver.Materials[i]); Objects.Add(matnode); materialsNode.AddChild(matnode); } var layoutsNode = new NamedEntity(this, null, "Layouts"); Objects.Add(layoutsNode); RootObject.AddChild(layoutsNode); for (int i = 0; i < flver.BufferLayouts.Count; i++) { var laynode = new NamedEntity(this, flver.BufferLayouts[i], $@"layout_{i}"); Objects.Add(laynode); layoutsNode.AddChild(laynode); } var bonesNode = new NamedEntity(this, null, "Bones"); Objects.Add(bonesNode); RootObject.AddChild(bonesNode); var boneEntList = new List <TransformableNamedEntity>(); for (int i = 0; i < flver.Bones.Count; i++) { var bonenode = new TransformableNamedEntity(this, flver.Bones[i], flver.Bones[i].Name); bonenode.RenderSceneMesh = Universe.GetBoneDrawable(this, bonenode); Objects.Add(bonenode); boneEntList.Add(bonenode); } for (int i = 0; i < flver.Bones.Count; i++) { if (flver.Bones[i].ParentIndex == -1) { bonesNode.AddChild(boneEntList[i]); } else { boneEntList[flver.Bones[i].ParentIndex].AddChild(boneEntList[i]); } } // Add dummy polys attached to bones var dmysNode = new NamedEntity(this, null, "DummyPolys"); Objects.Add(dmysNode); RootObject.AddChild(dmysNode); for (int i = 0; i < flver.Dummies.Count; i++) { var dmynode = new TransformableNamedEntity(this, flver.Dummies[i], $@"dmy_{i}"); dmynode.RenderSceneMesh = Universe.GetDummyPolyDrawable(this, dmynode); Objects.Add(dmynode); dmysNode.AddChild(dmynode); } }
public void LoadDummiesFromFLVER(FLVER2 flver, int baseDmyPolyID = 0) { MODEL.DbgPrimDrawer.ClearPrimitives(DbgPrimCategory.DummyPoly); AnimatedDummyPolyClusters = new Dictionary <int, DbgPrimDummyPolyCluster>(); ClusterWhichDmyPresidesIn = new Dictionary <int, List <DbgPrimDummyPolyCluster> >(); var dummiesByBoneID = new Dictionary <int, List <FLVER2.Dummy> >(); foreach (var dmy in flver.Dummies) { if (dummiesByBoneID.ContainsKey(dmy.AttachBoneIndex)) { dummiesByBoneID[dmy.AttachBoneIndex].Add(dmy); } else { dummiesByBoneID.Add(dmy.AttachBoneIndex, new List <FLVER2.Dummy> { dmy }); } } List <FLVER2.Dummy> stationaryDmy = new List <FLVER2.Dummy>(); for (int i = 0; i < flver.Bones.Count; i++) { if (dummiesByBoneID.ContainsKey(i)) { var dmyPrim = new DbgPrimDummyPolyCluster(0.5f, dummiesByBoneID[i], flver.Bones, baseDmyPolyID, i); foreach (var dmy in dummiesByBoneID[i]) { if (!ClusterWhichDmyPresidesIn.ContainsKey(dmy.ReferenceID + baseDmyPolyID)) { ClusterWhichDmyPresidesIn.Add(dmy.ReferenceID + baseDmyPolyID, new List <DbgPrimDummyPolyCluster>()); } if (!ClusterWhichDmyPresidesIn[dmy.ReferenceID + baseDmyPolyID].Contains(dmyPrim)) { ClusterWhichDmyPresidesIn[dmy.ReferenceID + baseDmyPolyID].Add(dmyPrim); } } MODEL.DbgPrimDrawer.AddPrimitive(dmyPrim); AnimatedDummyPolyClusters.Add(i, dmyPrim); } else { var dmyPrim = new DbgPrimDummyPolyCluster(0.5f, new List <FLVER2.Dummy>(), flver.Bones, baseDmyPolyID, i); MODEL.DbgPrimDrawer.AddPrimitive(dmyPrim); AnimatedDummyPolyClusters.Add(i, dmyPrim); } } foreach (var kvp in dummiesByBoneID) { if (kvp.Key >= 0) { } } if (dummiesByBoneID.ContainsKey(-1)) { StationaryDummyPolys = new DbgPrimDummyPolyCluster(0.5f, dummiesByBoneID[-1], flver.Bones, baseDmyPolyID, -1); MODEL.DbgPrimDrawer.AddPrimitive(StationaryDummyPolys); } else { if (StationaryDummyPolys != null) { MODEL.DbgPrimDrawer.RemovePrimitive(StationaryDummyPolys); } StationaryDummyPolys = null; } Console.WriteLine("TEST"); }
static void FixAllStupidDummyCoordinatesInFLVER2(FLVER2 flver, float scale, bool mirrorX) { Matrix GetBoneParentMatrix(SoulsFormats.FLVER2.Bone b) { SoulsFormats.FLVER2.Bone parentBone = b; var result = Matrix.Identity; do { result *= Matrix.CreateScale(parentBone.Scale.X, parentBone.Scale.Y, parentBone.Scale.Z); result *= Matrix.CreateRotationX(parentBone.Rotation.X); result *= Matrix.CreateRotationZ(parentBone.Rotation.Z); result *= Matrix.CreateRotationY(parentBone.Rotation.Y); result *= Matrix.CreateTranslation(parentBone.Translation.X, parentBone.Translation.Y, parentBone.Translation.Z); if (parentBone.ParentIndex >= 0) { parentBone = flver.Bones[parentBone.ParentIndex]; } else { parentBone = null; } }while (parentBone != null); return(result); } Matrix GetDummyPolyMatrix(FLVER2.Dummy dummy) { var dummyMatrix = GetBoneParentMatrix(flver.Bones[dummy.DummyBoneIndex]); return(Matrix.CreateLookAt( Vector3.Zero, new Vector3(dummy.Forward.X, dummy.Forward.Y, dummy.Forward.Z), dummy.UseUpwardVector ? new Vector3(dummy.Upward.X, dummy.Upward.Y, dummy.Upward.Z) : Vector3.Up) * Matrix.CreateTranslation(new Vector3(dummy.Position.X, dummy.Position.Y, dummy.Position.Z)) * dummyMatrix); } foreach (var dmy in flver.Dummies) { if (dmy.DummyBoneIndex >= 0) { Matrix m = GetDummyPolyMatrix(dmy) * Matrix.CreateScale(scale * (mirrorX ? -1 : 1), scale, scale); Vector3 finalDummyPosition = Vector3.Transform(Vector3.Zero, m); Vector3 finalDummyUp = Vector3.TransformNormal(Vector3.Up, m); Vector3 finalDummyForward = Vector3.TransformNormal(Vector3.Forward, m); dmy.Position = new System.Numerics.Vector3(finalDummyPosition.X, finalDummyPosition.Y, finalDummyPosition.Z); dmy.Upward = new System.Numerics.Vector3(finalDummyUp.X, finalDummyUp.Y, finalDummyUp.Z); dmy.Forward = new System.Numerics.Vector3(finalDummyForward.X, finalDummyForward.Y, finalDummyForward.Z); dmy.UseUpwardVector = true; dmy.AttachBoneIndex = -1; } } }
public Model(IProgress <double> loadingProgress, string name, IBinder chrbnd, int modelIndex, IBinder anibnd, IBinder texbnd = null, List <string> additionalTpfNames = null, string possibleLooseTpfFolder = null, int baseDmyPolyID = 0, bool ignoreStaticTransforms = false, IBinder additionalTexbnd = null) : this() { Name = name; List <BinderFile> flverFileEntries = new List <BinderFile>(); List <TPF> tpfsUsed = new List <TPF>(); if (additionalTpfNames != null) { foreach (var t in additionalTpfNames) { if (File.Exists(t)) { tpfsUsed.Add(TPF.Read(t)); } } } FLVER2 flver = null; foreach (var f in chrbnd.Files) { var nameCheck = f.Name.ToLower(); if (flver == null && (nameCheck.EndsWith(".flver") || FLVER2.Is(f.Bytes))) { if (nameCheck.EndsWith($"_{modelIndex}.flver") || modelIndex == 0) { flver = FLVER2.Read(f.Bytes); } } else if (nameCheck.EndsWith(".tpf") || TPF.Is(f.Bytes)) { tpfsUsed.Add(TPF.Read(f.Bytes)); } else if (anibnd == null && nameCheck.EndsWith(".anibnd")) { if (nameCheck.EndsWith($"_{modelIndex}.anibnd") || modelIndex == 0) { if (BND3.Is(f.Bytes)) { anibnd = BND3.Read(f.Bytes); } else { anibnd = BND4.Read(f.Bytes); } } } } if (flver == null) { throw new ArgumentException("No FLVERs found within CHRBND."); } LoadFLVER2(flver, useSecondUV: false, baseDmyPolyID, ignoreStaticTransforms); loadingProgress.Report(1.0 / 4.0); AnimContainer = new NewAnimationContainer(this); if (anibnd != null) { LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_ANIBND", $"Loading ANIBND for {Name}...", innerProg => { AnimContainer.LoadBaseANIBND(anibnd, innerProg); }); } else { // This just messes up the model cuz they're already in // reference pose, whoops //Skeleton.ApplyBakedFlverReferencePose(); } loadingProgress.Report(2.0 / 3.0); if (tpfsUsed.Count > 0) { LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_TPFs", $"Loading TPFs for {Name}...", innerProg => { for (int i = 0; i < tpfsUsed.Count; i++) { TexturePool.AddTpf(tpfsUsed[i]); MainMesh.TextureReloadQueued = true; innerProg.Report(1.0 * i / tpfsUsed.Count); } MainMesh.TextureReloadQueued = true; }); } loadingProgress.Report(3.0 / 4.0); if (texbnd != null) { LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_TEXBND", $"Loading TEXBND for {Name}...", innerProg => { TexturePool.AddTextureBnd(texbnd, innerProg); MainMesh.TextureReloadQueued = true; }); } loadingProgress.Report(3.5 / 4.0); if (additionalTexbnd != null) { LoadingTaskMan.DoLoadingTaskSynchronous($"{Name}_AdditionalTEXBND", $"Loading extra TEXBND for {Name}...", innerProg => { TexturePool.AddTextureBnd(additionalTexbnd, innerProg); MainMesh.TextureReloadQueued = true; }); } loadingProgress.Report(3.9 / 4.0); if (possibleLooseTpfFolder != null && Directory.Exists(possibleLooseTpfFolder)) { TexturePool.AddTPFFolder(possibleLooseTpfFolder); MainMesh.TextureReloadQueued = true; } MainMesh.TextureReloadQueued = true; loadingProgress.Report(1.0); }
public DsBone(FLVER.Bone flverBone, FLVER2 flver, HKX.Bone hkxBone, HKX.HKASkeleton hkaSkeleton) : this(flverBone, flver) { HkxBoneIndex = hkaSkeleton.Bones.GetArrayData().Elements.IndexOf(hkxBone); ParentName = InitializeHkxParentName(hkxBone, hkaSkeleton); }
public NewMesh(FLVER2 flver, bool useSecondUV, Dictionary <string, int> boneIndexRemap = null, bool ignoreStaticTransforms = false) { LoadFLVER2(flver, useSecondUV, boneIndexRemap, ignoreStaticTransforms); }
private static IEnumerable <DsBone> FixupDsBones(FLVER2 flver) { return(flver.Bones.Select(flverBone => new DsBone(flverBone, flver))); }
public Model(FLVER2 flver, bool useSecondUV) : this() { LoadFLVER2(flver, useSecondUV); }