public NVRMaterial(BinaryReader br, bool readOld) { this.Name = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Type = (NVRMaterialType)br.ReadInt32(); if (readOld) { ColorRGBAVector4 diffuseColor = new ColorRGBAVector4(br); string diffuseName = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Channels.Add(new NVRChannel(diffuseName, diffuseColor, new R3DMatrix44())); ColorRGBAVector4 emmisiveColor = new ColorRGBAVector4(br); string emissiveName = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Channels.Add(new NVRChannel(emissiveName, emmisiveColor, new R3DMatrix44())); this.Channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); this.Channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); this.Channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); this.Channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); this.Channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); this.Channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); } 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, ColorRGBAVector4 color, NVRMaterialType matType, NVRMaterialFlags matFlags) { List <NVRChannel> channels = new List <NVRChannel>(); channels.Add(new NVRChannel(textureName, color, new R3DMatrix44())); for (int i = 0; i < 7; i++) { channels.Add(new NVRChannel("", new ColorRGBAVector4(0, 0, 0, 0), new R3DMatrix44())); } NVRMaterial newMat = new NVRMaterial(materialName, matType, matFlags, channels); return(newMat); }
public NVRChannel(string name, ColorRGBAVector4 color, R3DMatrix44 matrix) { this.Name = name; this.Color = color; this.Matrix = matrix; }
public MGEOObject(BinaryReader br, List <MGEOVertexElementGroup> vertexElementGroups, List <long> vertexBufferOffsets, List <ushort[]> indexBuffers, bool useSeparatePointLights, uint version) { this.Name = Encoding.ASCII.GetString(br.ReadBytes(br.ReadInt32())); uint vertexCount = br.ReadUInt32(); uint vertexBufferCount = br.ReadUInt32(); int vertexElementGroup = br.ReadInt32(); for (int i = 0; i < vertexCount; i++) { this.Vertices.Add(new MGEOVertex()); } for (int i = 0, currentVertexElementGroup = vertexElementGroup; i < vertexBufferCount; i++, currentVertexElementGroup++) { int vertexBufferID = br.ReadInt32(); long returnPosition = br.BaseStream.Position; br.BaseStream.Seek(vertexBufferOffsets[vertexBufferID], SeekOrigin.Begin); for (int j = 0; j < vertexCount; j++) { this.Vertices[j] = MGEOVertex.Combine(this.Vertices[j], new MGEOVertex(br, vertexElementGroups[currentVertexElementGroup].VertexElements)); } br.BaseStream.Seek(returnPosition, SeekOrigin.Begin); } uint indexCount = br.ReadUInt32(); int indexBuffer = br.ReadInt32(); this.Indices.AddRange(indexBuffers[indexBuffer]); uint submeshCount = br.ReadUInt32(); for (int i = 0; i < submeshCount; i++) { this.Submeshes.Add(new MGEOSubmesh(br, this)); } if (version != 5) { this.Unknown1 = br.ReadBoolean(); } this.BoundingBox = new R3DBox(br); this.Transformation = new R3DMatrix44(br); this.Unknown2 = br.ReadByte(); if (version == 7) { this.Unknown3 = br.ReadByte(); } if (useSeparatePointLights) { this.SeparatePointLight = new Vector3(br); } for (int i = 0; i < 9; i++) { this.UnknownFloats.Add(new Vector3(br)); } this.Lightmap = Encoding.ASCII.GetString(br.ReadBytes(br.ReadInt32())); this.Color = new ColorRGBAVector4(br); }