public override Material Clone() { var material = new MaterialPM(ShaderSettings, RenderDirrectives, shaderProgram); foreach (var texture in textures) { material.SetTexture(texture.Value, texture.Key); } return(material); }
void ReadMaterials() { reader.BaseStream.Position = 0x38; int matOffset = (int)reader.BaseStream.Position + reader.ReadInt32(); reader.BaseStream.Position = matOffset + 4; reader.BaseStream.Position += reader.ReadInt32(); int materialCount = reader.ReadInt32(); int[] offsets = new int[materialCount]; for (int i = 0; i < materialCount; i++) { offsets[i] = (int)reader.BaseStream.Position + reader.ReadInt32(); } foreach (var moffs in offsets) { reader.BaseStream.Position = moffs + 4; int MaterialNameTextOffset = (int)reader.BaseStream.Position + reader.ReadInt32(); reader.BaseStream.Position = MaterialNameTextOffset; string MaterialName = reader.readString(); reader.BaseStream.Position = moffs + 0x48; string MaterialFileName = reader.readString(); ShaderSettings sdrs = new ShaderSettings(); RenderDirectives rndd = new RenderDirectives(); sdrs.HasSkeleton = true; sdrs.TextureDiffuse = true; sdrs.TextureSpecular = true; sdrs.RecieveShadow = false; rndd.HasEdges = true; Material mat = new MaterialPM(sdrs, rndd); mat.Name = MaterialName; mat.Outline.EdgeScaler = 0.1f; materialTable.Add(MaterialName, mat); mat.UniformManager.Set("uv_scale", Vector4.One); //scale face shadow texture if (MaterialName.Contains("face")) { mat.UniformManager.Set("uv_scale", new Vector4(1, 1, 4, 4)); } try { ReadTexturesFromMaterial(MaterialName, mat); } catch (Exception e) { Console.WriteLine(e.Message); } } }