static void TestMapgeo() { MapGeometry mgeo = new MapGeometry(@"C:/Users/Crauzer/Desktop/data/maps/mapgeometry/sr/base_srx.mapgeo"); string randomMaterialName = mgeo.Models[180].Submeshes[0].Material; mgeo.Models.Clear(); OBJFile object1 = new OBJFile("room155.obj"); OBJFile object2 = new OBJFile("room156.obj"); OBJFile object3 = new OBJFile("room157.obj"); AddOBJ(object1, "MapGeo_Instance_0"); AddOBJ(object2, "MapGeo_Instance_1"); AddOBJ(object3, "MapGeo_Instance_2"); mgeo.Write("base_srx.mapgeo.edited", 7); void AddOBJ(OBJFile obj, string name) { //We will add each object 2 times just for fun to see how transformation works (List <ushort> indices, List <MapGeometryVertex> vertices) = obj.GetMGEOData(); R3DMatrix44 transformation = R3DMatrix44.FromTranslation(new Vector3(0, 50, 100)); MapGeometrySubmesh submesh = new MapGeometrySubmesh("", 0, (uint)indices.Count, 0, (uint)vertices.Count); MapGeometryModel model1 = new MapGeometryModel(name, vertices, indices, new List <MapGeometrySubmesh>() { submesh }, MapGeometryLayer.AllLayers); mgeo.AddModel(model1); } }
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); }
public MapGeometryModel(string name, List <MapGeometryVertex> vertices, List <ushort> indices, List <MapGeometrySubmesh> submeshes, MapGeometryLayer layer, R3DMatrix44 transformation) : this(name, vertices, indices, submeshes) { this.Layer = layer; this.Transformation = transformation; }
public NVRChannel(string name, Color color, R3DMatrix44 matrix) { this.Name = name; this.Color = color; this.Matrix = matrix; }
public NVRChannel(BinaryReader br) { this.Color = br.ReadColor(ColorFormat.RgbaF32); this.Name = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Matrix = new R3DMatrix44(br); }
public NVRChannel(BinaryReader br) { this.Color = new ColorRGBAVector4(br); this.Name = Encoding.ASCII.GetString(br.ReadBytes(260)).Replace("\0", ""); this.Matrix = new R3DMatrix44(br); }
private static StackPanel ProcessPrimitiveValue(BINValue value, bool createFieldProperty = true) { StackPanel stackPanel = new StackPanel() { Orientation = Orientation.Horizontal }; if (createFieldProperty) { stackPanel.Children.Add(new TextBlock() { Text = BINGlobal.GetField(value.Property), Margin = new Thickness(0, 0, 15, 0) }); } if (value.Type == BINValueType.Boolean) { stackPanel.Children.Add(new TextBlock() { Text = ((bool)value.Value).ToString() }); } else if (value.Type == BINValueType.SByte) { stackPanel.Children.Add(new TextBlock() { Text = ((sbyte)value.Value).ToString() }); } else if (value.Type == BINValueType.Byte) { stackPanel.Children.Add(new TextBlock() { Text = ((byte)value.Value).ToString() }); } else if (value.Type == BINValueType.Int16) { stackPanel.Children.Add(new TextBlock() { Text = ((short)value.Value).ToString() }); } else if (value.Type == BINValueType.UInt16) { stackPanel.Children.Add(new TextBlock() { Text = ((ushort)value.Value).ToString() }); } else if (value.Type == BINValueType.Int32) { stackPanel.Children.Add(new TextBlock() { Text = ((int)value.Value).ToString() }); } else if (value.Type == BINValueType.UInt32) { stackPanel.Children.Add(new TextBlock() { Text = ((uint)value.Value).ToString() }); } else if (value.Type == BINValueType.Int64) { stackPanel.Children.Add(new TextBlock() { Text = ((long)value.Value).ToString() }); } else if (value.Type == BINValueType.UInt64) { stackPanel.Children.Add(new TextBlock() { Text = ((ulong)value.Value).ToString() }); } else if (value.Type == BINValueType.Float) { stackPanel.Children.Add(new TextBlock() { Text = ((float)value.Value).ToString() }); } else if (value.Type == BINValueType.FloatVector2) { Vector2 vector = value.Value as Vector2; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1} ]", vector.X, vector.Y) }); } else if (value.Type == BINValueType.FloatVector3) { Vector3 vector = value.Value as Vector3; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2} ]", vector.X, vector.Y, vector.Z) }); } else if (value.Type == BINValueType.FloatVector4) { Vector4 vector = value.Value as Vector4; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2}, {3} ]", vector.X, vector.Y, vector.Z, vector.W) }); } else if (value.Type == BINValueType.Matrix44) { R3DMatrix44 matrix = value.Value as R3DMatrix44; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2}, {3} ]\n", matrix.M11, matrix.M12, matrix.M13, matrix.M14) + string.Format("[ {0}, {1}, {2}, {3} ]\n", matrix.M21, matrix.M22, matrix.M23, matrix.M24) + string.Format("[ {0}, {1}, {2}, {3} ]\n", matrix.M31, matrix.M32, matrix.M33, matrix.M34) + string.Format("[ {0}, {1}, {2}, {3} ]", matrix.M41, matrix.M42, matrix.M43, matrix.M44) }); } else if (value.Type == BINValueType.Color) { ColorRGBAVector4Byte color = value.Value as ColorRGBAVector4Byte; stackPanel.Children.Add(new TextBlock() { Text = string.Format("[ {0}, {1}, {2}, {3} ]", color.R, color.G, color.B, color.A) }); } else if (value.Type == BINValueType.String) { stackPanel.Children.Add(new TextBlock() { Text = (string)value.Value }); } else if (value.Type == BINValueType.StringHash) { stackPanel.Children.Add(new TextBlock() { Text = ((uint)value.Value).ToString() }); } else if (value.Type == BINValueType.LinkOffset) { stackPanel.Children.Add(new TextBlock() { Text = BINGlobal.GetEntry((uint)value.Value) }); } else if (value.Type == BINValueType.FlagsBoolean) { stackPanel.Children.Add(new TextBlock() { Text = ((bool)value.Value).ToString() }); } return(stackPanel); }