public NVRMaterial(BinaryReader br, bool readOld) { this.Name = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Type = (NVRMaterialType)br.ReadInt32(); if (readOld) { Color diffuseColor = br.ReadColor(ColorFormat.RgbaF32); string diffuseName = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Channels.Add(new NVRChannel(diffuseName, diffuseColor, R3DMatrix44.IdentityR3DMatrix44())); Color emmisiveColor = br.ReadColor(ColorFormat.RgbaF32); string emissiveName = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Channels.Add(new NVRChannel(emissiveName, emmisiveColor, R3DMatrix44.IdentityR3DMatrix44())); for (int i = 0; i < 6; i++) { this.Channels.Add(new NVRChannel("", new Color(0, 0, 0, 0), R3DMatrix44.IdentityR3DMatrix44())); } } else { this.Flags = (NVRMaterialFlags)br.ReadUInt32(); for (int i = 0; i < 8; i++) { this.Channels.Add(new NVRChannel(br)); } } }
public static NVRMaterial CreateMaterial(string materialName, string textureName, Color color, NVRMaterialType matType, NVRMaterialFlags matFlags) { List <NVRChannel> channels = new List <NVRChannel>(); channels.Add(new NVRChannel(textureName, color, R3DMatrix44.IdentityR3DMatrix44())); for (int i = 0; i < 7; i++) { channels.Add(new NVRChannel("", new Color(0, 0, 0, 0), R3DMatrix44.IdentityR3DMatrix44())); } NVRMaterial newMat = new NVRMaterial(materialName, matType, matFlags, channels); return(newMat); }