private void Build() { const int CountOffset = 0x04; const int SizeOffset = 0x08; const int BlockPositionsOffset = 0x34; const int BlockPositionSize = 0x04; byte[] buffer = File.GetData(); int blockCount = BitConverter.ToInt32(buffer, CountOffset); int blockSize = BitConverter.ToInt32(buffer, SizeOffset); string blockDirectory = File.Path.Substring(0, File.Path.LastIndexOf('/') + 1); Parts = new TransformedModel[blockCount]; for (int i = 0; i < blockCount; ++i) { string blockPath = blockDirectory + string.Format("{0:D4}.mdl", i); ModelFile blockModelFile = (ModelFile)File.Pack.Collection.GetFile(blockPath); short x = BitConverter.ToInt16(buffer, BlockPositionsOffset + BlockPositionSize * i + 0); short z = BitConverter.ToInt16(buffer, BlockPositionsOffset + BlockPositionSize * i + 2); Vector3 translation = new Vector3 { X = blockSize * (x + 0.5f), Y = 0, Z = blockSize * (z + 0.5f) }; Parts[i] = new TransformedModel(blockModelFile.GetModelDefinition(), translation, Vector3.Zero, Vector3.One); } }
public static void WriteObjectFile(String path, ModelFile mdlFile) { Model mdl = mdlFile.GetModelDefinition().GetModel(ModelQuality.High); Mesh[] meshes = mdl.Meshes; List <Vector3> vsList = new List <Vector3>(); List <Vector4> vcList = new List <Vector4>(); List <Vector4> vtList = new List <Vector4>(); List <Vector3> nmList = new List <Vector3>(); List <Vector3> inList = new List <Vector3>(); for (int i = 0; i < meshes.Length; i++) { EnumerateFromVertices(meshes[i].Vertices, ref vsList, ref vcList, ref vtList, ref nmList); EnumerateIndices(meshes[i].Indices, ref inList); WriteObjectFileForMesh(path, mdl.Meshes[i].Material.Get(), mdl.Definition, i, vsList, vcList, vtList, nmList, inList); vsList.Clear(); vcList.Clear(); vtList.Clear(); nmList.Clear(); inList.Clear(); } }
private Mesh InitNonVariantMesh(string path) { ModelFile mf = (ModelFile)Parent.Realm.Packs.GetFile(path); Model model = mf.GetModelDefinition().GetModel(ModelQuality.High); Mesh ret = LoadMesh(model); return(ret); }
private Mesh InitEquipMesh(Tribe t, Sex s, Quad q, EquipSlotKey slotKey) { var path = PathFormatter.Instance.GetEquipmentModelPath(t, s, q, slotKey); ModelFile mf = (ModelFile)Parent.Realm.Packs.GetFile(path); Model model = mf.GetModelDefinition().GetModel(ModelQuality.High); ImcVariant variant = PathFormatter.Instance.GetVariant(q, slotKey); Mesh ret = LoadMeshWithVariant(model, variant); return(ret); }
/// <summary> /// Get the model for a specific QWord, character type, and the current <see cref="EquipSlot" />. /// </summary> /// <param name="key">The identifier of the model.</param> /// <param name="characterType">Character type to get the model for.</param> /// <param name="materialVersion">When this method returns, contains the variant contained within <c>key</c>.</param> /// <returns>Returns the <see cref="Model" /> for the specified <c>key</c> and <c>characterType</c>.</returns> public ModelDefinition GetModel(Quad key, int characterType, out Graphics.ImcVariant variant) { variant = Graphics.ImcVariant.Default; if (!ModelHelpers.TryGetValue(Key, out ModelHelper helper)) { return(null); } if (helper == null) { return(null); } PackCollection packs = Collection.Collection.PackCollection; int variantIndex = (int)((key.ToInt64() >> (helper.VariantIndexWord * 16)) & 0xFFFF); string imcPath = string.Format(helper.ImcFileFormat, key.Value1, key.Value2, key.Value3, key.Value4, characterType); if (!packs.TryGetFile(imcPath, out File imcBase)) { return(null); } ImcFile imc = new Graphics.ImcFile(imcBase); variant = imc.GetVariant(helper.ImcPartKey, variantIndex); IO.File modelBase = null; while (!packs.TryGetFile(string.Format(helper.ModelFileFormat, key.Value1, key.Value2, key.Value3, key.Value4, characterType), out modelBase) && CharacterTypeFallback.TryGetValue(characterType, out characterType)) { } ModelFile asModel = modelBase as Graphics.ModelFile; if (asModel == null) { return(null); } return(asModel.GetModelDefinition()); }
public ContentModel(Engine engine, ModelVariantIdentifier variant, ModelFile file, ModelQuality quality) : this(engine, variant, file.GetModelDefinition(), quality) { }
public AnimatedModel(Engine engine, Skeleton skeleton, ModelVariantIdentifier variant, ModelFile file, ModelQuality quality) : this(engine, skeleton, variant, file.GetModelDefinition(), quality) { }