Exemplo n.º 1
0
        public void ReadFromBinary(Stream stream)
        {
            var reader = new BinaryReader(stream);

            //56 byte data section at the start of each zone object.
            ClassnameHash = reader.ReadUInt32();
            Handle        = reader.ReadUInt32();
            Bmin          = reader.ReadVector3f();
            Bmax          = reader.ReadVector3f();
            Flags         = reader.ReadUInt16();
            BlockSize     = reader.ReadUInt16();
            Parent        = reader.ReadUInt32();
            Sibling       = reader.ReadUInt32();
            Child         = reader.ReadUInt32();
            Num           = reader.ReadUInt32();
            NumProps      = reader.ReadUInt16();
            Size          = reader.ReadUInt16();

            for (int i = 0; i < NumProps; i++)
            {
                var prop = PropertyManager.ReadPropertyFromBinary(stream);
                Properties.Add(prop);
            }

            TrySetClassnameString();
            TrySetDescriptionString();
        }
Exemplo n.º 2
0
        public void ReadFromXml(XElement element)
        {
            //Read zone object data & convert flags to ushort
            var objectData = element.GetRequiredElement("Data");

            ClassnameHash = objectData.GetRequiredAttributeValue("ClassnameHash").ToUint32();
            Handle        = objectData.GetRequiredValue("Handle").ToUint32(); //Todo: Figure out how this value is chosen
            Bmin          = objectData.GetRequiredElement("Bmin").ToVector3f();
            Bmax          = objectData.GetRequiredElement("Bmax").ToVector3f();
            SetFlagsFromXml(objectData.GetRequiredElement("Flags"));
            BlockSize = objectData.GetRequiredAttributeValue("BlockSize").ToUint16();  //Todo: Update this based on xml data
            Parent    = objectData.GetOptionalValue("Parent", "4294967295").ToUint32();
            Sibling   = objectData.GetOptionalValue("Sibling", "4294967295").ToUint32();
            Child     = objectData.GetOptionalValue("Child", "4294967295").ToUint32();
            Num       = objectData.GetRequiredValue("Num").ToUint32();               //Todo: Figure out what the hell this means
            NumProps  = objectData.GetRequiredAttributeValue("NumProps").ToUint16(); //Todo: Update this based on xml data
            Size      = objectData.GetRequiredAttributeValue("Size").ToUint16();     //Todo: Update this based on xml data

            //Read properties
            var propertiesNode = element.GetRequiredElement("Properties");

            foreach (var property in propertiesNode.Elements("Property"))
            {
                Properties.Add(PropertyManager.ReadPropertyFromXml(property));
            }
            NumProps = (ushort)Properties.Count; //Update in case person editing xml forgot to
            //Todo: Update BlockSize & individual prop size when they change
            TrySetClassnameString();
            TrySetDescriptionString();
        }
Exemplo n.º 3
0
 public void Read(BinaryReader data)
 {
     NameOffset         = data.ReadUInt32();
     InverseTranslation = data.ReadVector3f();
     Translation        = data.ReadVector3f();
     ParentIndex        = data.ReadUInt32();
     Vid = data.ReadUInt32();
 }
Exemplo n.º 4
0
        public void ReadFromXml(XElement propertyRoot, ushort type, ushort size, uint nameHash)
        {
            Type     = type;
            Size     = size;
            NameHash = nameHash;

            Data = propertyRoot.GetRequiredElement("Data").ToVector3f();
        }
Exemplo n.º 5
0
        public uint RenderBlocksOffset; //Seems to be a ptr set at runtime

        public void Read(BinaryReader data)
        {
            NumRenderBlocks    = data.ReadInt32();
            OffsetTransform    = data.ReadVector3f();
            Bmin               = data.ReadVector3f();
            Bmax               = data.ReadVector3f();
            RenderBlocksOffset = data.ReadUInt32();
        }
Exemplo n.º 6
0
        public void ReadFromXml(XElement propertyRoot, ushort type, ushort size, uint nameHash)
        {
            Type     = type;
            Size     = size;
            NameHash = nameHash;

            var dataNode = propertyRoot.GetRequiredElement("Data");

            Position = dataNode.GetRequiredElement("position").ToVector3f();
            Orient   = dataNode.GetRequiredElement("orient").ToMatrix33();
        }
Exemplo n.º 7
0
        public bool ReadFromStream(Stream stream, ushort type, ushort size, uint nameHash)
        {
            Type     = type;
            Size     = size;
            NameHash = nameHash;

            if (size == 12)
            {
                var reader = new BinaryReader(stream);
                Data = reader.ReadVector3f();
                return(true);
            }
            else
            {
                Console.WriteLine("Error! Found vector3f property with size != 12 bytes. Unknown data! Skipping property.");
                return(false);
            }
        }
Exemplo n.º 8
0
        public bool ReadFromStream(Stream stream, ushort type, ushort size, uint nameHash)
        {
            Type     = type;
            Size     = size;
            NameHash = nameHash;

            if (size == 48)
            {
                var reader = new BinaryReader(stream);
                Position = reader.ReadVector3f();
                Orient   = reader.ReadMatrix33();
                return(true);
            }
            else
            {
                Console.WriteLine("Error! Found op (orient + position) property with size != 48 bytes. Unknown data! Skipping property.");
                return(false);
            }
        }
Exemplo n.º 9
0
 public void Read(BinaryReader data, VertexFormat format)
 {
     if (format == VertexFormat.Pixlit1UvNmap)
     {
         Pos     = data.ReadVector3f();
         Normal  = data.ReadCompressedVector4f();
         Tangent = data.ReadCompressedVector4f();
         Uvs     = new vector4f(data.ReadInt16(), data.ReadInt16(), 0.0f, 0.0f);
     }
     else if (format == VertexFormat.Pixlit3UvNmap)
     {
         Pos     = data.ReadVector3f();
         Normal  = data.ReadCompressedVector4f();
         Tangent = data.ReadCompressedVector4f();
         Uvs     = new vector4f(data.ReadInt16(), data.ReadInt16(), 0.0f, 0.0f);
         data.Skip(8); //Skip other UVs, .obj files only support 1 uv per object so for now need to ignore these. These are usually just 0,0 anyway
     }
     else
     {
         throw new Exception($"{format.ToString()} is an unsupported vertex format! Please show the maintainer of this tool this error and the related mesh file.");
     }
 }
Exemplo n.º 10
0
 public static void Write(this BinaryWriter writer, vector3f vec3)
 {
     writer.Write(vec3.x);
     writer.Write(vec3.y);
     writer.Write(vec3.z);
 }