} // loaded // materials // public static void ReadMOMT(Stream WMOrootstream, int MOMTsize) { wmoData.Info.nMaterials = MOMTsize / 64; for (int i = 0; i < wmoData.Info.nMaterials; i++) { WMOMaterial material = new WMOMaterial(); material.flags = ReadMaterialFlags(WMOrootstream); material.shader = ReadLong(WMOrootstream); // Index into CMapObj::s_wmoShaderMetaData. See below (shader types). material.blendMode = (BlendingMode)ReadLong(WMOrootstream); // Blending: see https://wowdev.wiki/Rendering#EGxBlend material.texture1_offset = ReadLong(WMOrootstream); // Diffuse Texture; offset into MOTX material.color1 = ReadRGBA(WMOrootstream); // emissive color; see below (emissive color) material.texture1_flags = ReadMaterialFlags(WMOrootstream); material.texture2_offset = ReadLong(WMOrootstream); // Environment Texture; envNameIndex; offset into MOTX material.color2 = ReadRGBA(WMOrootstream); // diffuse color; CWorldView::GatherMapObjDefGroupLiquids(): geomFactory->SetDiffuseColor((CImVectorⁱ*)(smo+7)); // environment textures don't need flags material.ground_type = ReadLong(WMOrootstream); // foreign_keyⁱ< uint32_t, &TerrainTypeRec::m_ID > ground_type; // according to CMapObjDef::GetGroundType material.texture3_offset = ReadLong(WMOrootstream); // offset into MOTX material.color3 = ReadRGBA(WMOrootstream); material.texture3_flags = ReadMaterialFlags(WMOrootstream); // skip runtime data // WMOrootstream.Seek(16, SeekOrigin.Current); wmoData.materials.Add(material); } } // loaded
public void LoadWMO() { WMOReader reader = new WMOReader(basedir); reader.LoadWMO(modelPath); WMOMaterial[] materials = new WMOMaterial[reader.wmofile.materials.Count()]; for (int i = 0; i < reader.wmofile.materials.Count(); i++) { for (int ti = 0; ti < reader.wmofile.textures.Count(); ti++) { if (reader.wmofile.textures[ti].startOffset == reader.wmofile.materials[i].texture1) { Texture2D texture; var blp = new BLPReader(basedir); blp.LoadBLP(reader.wmofile.textures[ti].filename); if (blp.bmp == null) { texture = Texture2D.FromFile <Texture2D>(device, "missingtexture.jpg"); } else { MemoryStream s = new MemoryStream(); blp.bmp.Save(s, System.Drawing.Imaging.ImageFormat.Png); s.Seek(0, SeekOrigin.Begin); texture = Texture2D.FromMemory <Texture2D>(device, s.ToArray()); s.Dispose(); } materials[i].materialID = (uint)i; materials[i].filename = reader.wmofile.textures[ti].filename; materials[i].texture = texture; } } } WoWWMOGroup[] groups = new WoWWMOGroup[reader.wmofile.header.nGroups]; for (int i = 0; i < reader.wmofile.header.nGroups; i++) { groups[i] = LoadGroupWMO(reader.wmofile.group[i]); } wmo.materials = materials; wmo.groups = groups; }