Exemplo n.º 1
0
 /// <summary>New default Material</summary>
 public Matr()
 {
     IdName = "default";
     Diffuse = new D3DColor(0xFFFFFFFF);
     Ambient = new D3DColor(0xFFFFFFFF);
     Specular = new D3DColor(0xFFFFFFFF);
     Emissive = new D3DColor(0);
     Power = 0;
     Comments = String.Empty;
 }
Exemplo n.º 2
0
 /// <summary>New Material from provided fields</summary>
 /// <param name="id">Identifier name</param>
 /// <param name="d">Diffuse color</param>
 /// <param name="a">Ambient color</param>
 /// <param name="s">Specular color</param>
 /// <param name="e">Emissive color</param>
 /// <param name="p">Power</param>
 /// <param name="c">Comments in ini file</param>
 public Matr(String id, D3DColor d, D3DColor a, D3DColor s, D3DColor e, 
     float p, String c)
 {
     IdName = id;
     Diffuse = d;
     Ambient = a;
     Specular = s;
     Emissive = e;
     Power = p;
     Comments = c;
 }
Exemplo n.º 3
0
 /// <summary>New Material from a string, like in Matr ini file
 /// <remarks>Throws ArgumentException if the string has bad format</remarks></summary>
 /// <param name="str">String like in ini file line</param>
 public Matr(String str)
 {
     UInt32 d, a, s, e;
     String[] st = str.Split(' ');
     if (st.Length != 6) throw new ArgumentException("Incorrect Material format; str must have 6 fields separated by spaces like this:\r\nwater FFFFFFFF FFFFFFFF FF60DEE6 FF47607E 5");
     if (!UInt32.TryParse(st[1], out d)) throw new ArgumentException("Incorrect Material format; 2nd field cannot be parsed to UInt32.");
     if (!UInt32.TryParse(st[2], out a)) throw new ArgumentException("Incorrect Material format;  3rd cannot be parsed to UInt32.");
     if (!UInt32.TryParse(st[3], out s)) throw new ArgumentException("Incorrect Material format;  4th cannot be parsed to UInt32.");
     if (!UInt32.TryParse(st[4], out e)) throw new ArgumentException("Incorrect Material format;  5th cannot be parsed to UInt32.");
     if (!float.TryParse(st[5], out Power)) throw new ArgumentException("Incorrect Material format; 6th field cannot be parsed to Single IEEE float.");
     IdName = st[0];
     Diffuse = new D3DColor(d);
     Ambient = new D3DColor(a);
     Specular = new D3DColor(s);
     Emissive = new D3DColor(e);
     Comments = String.Empty;
 }
Exemplo n.º 4
0
 /// <summary>New Material from a byte array, like in Matr dbc file
 /// <remarks>Throws ArgumentException if the byte array has bad format</remarks></summary>
 /// <param name="b">Data read from dbc binary file</param>
 public Matr(Byte[] b)
 {
     if (b.Length != 52) throw new ArgumentException("Incorrect Material format; b must have 52 bytes");
     Byte[] c = new Byte[4];
     Byte[] i = new Byte[32];
     Buffer.BlockCopy(b, 0, i, 0, 32);
     IdName = Common.Bytes32ToString(i);
     Diffuse = new D3DColor(b[32], b[33], b[34], b[35]);
     Ambient = new D3DColor(b[36], b[37], b[38], b[39]);
     Specular = new D3DColor(b[40], b[41], b[42], b[43]);
     Emissive = new D3DColor(b[44], b[45], b[46], b[47]);
     Power = BitConverter.ToSingle(b, 48);
     Comments = String.Empty;
 }