public void Save(SaveContext saveContext) { var utility = saveContext.Utility; CGFXDebug.SaveStart(this, saveContext); // Bone Indices if (BoneReferences != null) { BoneIndices = BoneReferences.Select(b => (uint)b.Index).ToList(); // Rebuild from referenced objects } saveContext.WriteValueListPointerPlaceholder(BoneIndices); // Skinning utility.Write((uint)Skinning); // Faces saveContext.WriteObjectListPointerPlaceholder(Faces); ///////////////////////////// // Begin saving dependent data saveContext.SaveAndMarkReference(BoneIndices); saveContext.SaveAndMarkReference(Faces); Faces.SaveList(saveContext); }
public BoneReferences GetBoneReferences() { BoneReferences boneReferences = new BoneReferences(); if (PsaFile.DataSection[MiscSectionLocation + 9] >= 8096 && PsaFile.DataSection[MiscSectionLocation + 9] < PsaFile.DataSectionSize) { int boneReferencesLocation = PsaFile.DataSection[MiscSectionLocation + 9]; boneReferences.Offset = boneReferencesLocation; int boneReferencesValuesLocation = PsaFile.DataSection[MiscSectionLocation + 9] / 4; for (int i = 0; i < 10; i++) { boneReferences.Bones.Add(PsaFile.DataSection[boneReferencesValuesLocation + i]); } } Console.WriteLine(boneReferences); return(boneReferences); }
public BoneReferences GetBoneReferences() { BoneReferences boneReferences = new BoneReferences(); // checks if bone references section exists (the other one, NOT the one in misc section) if (PsaFile.DataSection[DataSectionLocation + 18] >= 8096 && PsaFile.DataSection[DataSectionLocation + 18] < PsaFile.DataSectionSize) { boneReferences.Offset = PsaFile.DataSection[DataSectionLocation + 18]; int boneReferencesLocation = PsaFile.DataSection[DataSectionLocation + 18] / 4; // j // this gets number of bone references...somehow // no idea why it needs this info from misc section's bone references... if (PsaFile.DataSection[DataSectionLocation + 4] >= 8096 && PsaFile.DataSection[DataSectionLocation + 4] < PsaFile.DataSectionSize) // if misc section exists... { int miscSectionLocation = PsaFile.DataSection[DataSectionLocation + 4] / 4; if (PsaFile.DataSection[miscSectionLocation + 9] >= 8096 && PsaFile.DataSection[miscSectionLocation + 9] < PsaFile.DataSectionSize) // if misc section's bone references exist { // I thinkkk this calcs the difference between the two locations, which would be how many bone references are in this section before it reaches misc section's bone references...maybe?? int numberOfBoneReferences = (PsaFile.DataSection[miscSectionLocation + 9] - PsaFile.DataSection[DataSectionLocation + 18]) / 4; // I guess there has to at least be just one bone references at minimum if (numberOfBoneReferences == 0) { numberOfBoneReferences = 1; } boneReferences.BonesCount = numberOfBoneReferences; for (int i = 0; i < numberOfBoneReferences; i++) { boneReferences.Bones.Add(PsaFile.DataSection[boneReferencesLocation + i]); } } } } Console.WriteLine(boneReferences); return(boneReferences); }