Exemplo n.º 1
0
        protected int Write3D(ByteArray header)
        {
            int attrib = 0x0000;

            if (parent != -1)
            {
                attrib |= 1;
                header.WriteUInt32((uint)parent);
            }

            return attrib;
        }
Exemplo n.º 2
0
        public override ByteArray Write()
        {
            ByteArray data = new ByteArray();

            data.WriteUInt16(joints.Count);

            foreach (JointData jnt in joints)
            {
                jnt.Write(data);
            }

            return data;
        }
Exemplo n.º 3
0
        public override ByteArray Write()
        {
            ByteArray header = new ByteArray();

            int attrib = Write3D(header);

            if (materials.Count > 0)
            {
                attrib |= 256;

                header.WriteByte(materials.Count);

                if (materials.Count == 1)
                {
                    header.WriteUInt32((uint)materials[0]);
                }
                else
                {
                    for (int i = 0; i < materials.Count; i++)
                    {
                        header.WriteUInt32((uint)(materials[i] + 1));
                    }
                }
            }

            if (modifiers.Count > 0)
            {
                attrib |= 512;

                header.WriteByte(modifiers.Count);

                for (int i = 0; i < modifiers.Count; i++)
                {
                    header.WriteUInt32(modifiers[i]);
                }
            }

            ByteArray data = new ByteArray();

            data.WriteUInt16(attrib);
            data.WriteBytes(header.ToArray());

            data.WriteFloats(transform);
            data.WriteUInt32((uint)geometry);

            WriteTags(data);

            return data;
        }
Exemplo n.º 4
0
        public override ByteArray Write()
        {
            ByteArray header = new ByteArray();

            int attrib = WriteLight(header);

            ByteArray data = new ByteArray();

            data.WriteUInt16(attrib);
            data.WriteBytes(header.ToArray());

            data.WriteUInt24(color);
            data.WriteFloat(multiplier);

            return data;
        }
Exemplo n.º 5
0
        public override ByteArray Write()
        {
            ByteArray header = new ByteArray();

            int attrib = Write3D(header);

            ByteArray data = new ByteArray();

            data.WriteUInt16(attrib);
            data.WriteBytes(header.ToArray());

            data.WriteFloats(transform);
            data.WriteFloat(fov);

            WriteTags(data);

            return data;
        }
Exemplo n.º 6
0
        public override ByteArray Write()
        {
            ByteArray header = new ByteArray();

            int attrib = 0x0000;

            if (doubleSided) attrib |= 1;

            if (!receiveLights) attrib |= 2;
            if (!receiveShadows) attrib |= 4;
            if (!receiveFog) attrib |= 8;

            if (!repeat) attrib |= 16;

            if (alpha != 1)
            {
                attrib |= 32;
                header.WriteFloat(alpha);
            }

            if (blendMode != 0)
            {
                attrib |= 64;
                header.WriteByte(blendMode);
            }

            ByteArray data = new ByteArray();

            data.WriteUInt16(attrib);
            data.WriteBytes(header.ToArray());

            data.WriteByte(techniques.Count);

            foreach (TechBase tech in techniques)
            {
                ByteArray techData = tech.Write();

                data.WriteUInt16(tech.type);
                data.WriteUInt16((int)techData.Length);
                data.WriteBytes(techData.ToArray());
            }

            return data;
        }
Exemplo n.º 7
0
 public SEAData(string name, string type)
     : base(name, type)
 {
     Data = new ByteArray();
 }
Exemplo n.º 8
0
        public override void Read(ByteArray stream)
        {
            attrib = stream.ReadUInt16();

            numVertex = (attrib & 1) != 0 ? stream.ReadUInt32() : (uint)stream.ReadUInt16();
        }
Exemplo n.º 9
0
        public override void Read(ByteArray stream)
        {
            base.Read(stream);

            uint i, j, len = numVertex * 3;

            // NORMAL
            if ((attrib & 4) != 0)
            {
                normal = new float[len];

                i = 0;
                while (i < len)
                    normal[i++] = stream.ReadFloat();
            }

            // TANGENT
            if ((attrib & 8) != 0)
            {
                tangent = new float[len];

                i = 0;
                while (i < len)
                    tangent[i++] = stream.ReadFloat();

                // UVS
                if ((attrib & 32) != 0)
                {
                    int uvCount = stream.ReadUByte();
                    uint uvLen = numVertex * 2;

                    uv = new float[uvCount][];

                    i = 0;
                    while (i < uvLen)
                    {
                        // UV_VERTEX
                        uv[i++] = new float[uvLen];

                        j = 0;
                        while (j < numVertex)
                            uv[i][j++] = stream.ReadFloat();
                    }
                }
            }

            // JOINT_INDEXES | WEIGHTS
            if ((attrib & 64) != 0)
            {
                jointPerVertex = (uint)stream.ReadUByte();

                uint jntLen = numVertex * jointPerVertex;

                joint = new uint[jntLen];
                weight = new float[jntLen];

                i = 0;
                while (i < jntLen)
                    joint[i++] = (uint)stream.ReadUInt16();

                i = 0;
                while (i < jntLen)
                    weight[i++] = stream.ReadFloat();
            }

            // VERTEX_COLOR
            if ((attrib & 128) != 0)
            {
                int colorLen = stream.ReadUByte();

                color = new float[colorLen][];

                for (i = 0; i < colorLen; i++)
                {
                    color[i] = new float[len];

                    j = 0;
                    while (j < len)
                        color[j++][j] = (float)stream.ReadUByte() / 255.0f;
                }
            }

            // VERTEX
            vertex = new float[len];

            i = 0;
            while (i < len)
                vertex[i++] = stream.ReadFloat();

            int idxCount = stream.ReadUByte();

            indexes = new uint[idxCount][];

            // INDEXES
            if (isBig)
            {
                for (i = 0; i < idxCount; i++)
                {
                    uint triLen = stream.ReadUInt32() * 3;

                    indexes[i] = new uint[triLen];

                    j = 0;
                    while (j < triLen)
                        indexes[i][j++] = stream.ReadUInt32();
                }
            }
            else
            {
                for (i = 0; i < idxCount; i++)
                {
                    uint triLen = (uint)stream.ReadUInt16() * 3;

                    indexes[i] = new uint[triLen];

                    j = 0;
                    while (j < triLen)
                        indexes[i][j++] = (uint)stream.ReadUInt16();
                }
            }
        }
Exemplo n.º 10
0
        public override ByteArray Write()
        {
            ByteArray stream = new ByteArray();

            // update num of vertex
            numVertex = (uint)(vertex.Length / 3);

            int attrib = 0x0000;

            if (isBig) attrib |= 1;
            if (normal != null) attrib |= 4;
            if (tangent != null) attrib |= 8;
            if (uv != null) attrib |= 32;

            stream.WriteUInt16(attrib);

            if (isBig) stream.WriteUInt32(numVertex);
            else stream.WriteUInt16((int)numVertex);

            if (normal != null)
            {
                for (int i = 0; i < normal.Length; i++)
                {
                    stream.WriteFloat(normal[i]);
                }
            }

            if (tangent != null)
            {
                for (int i = 0; i < tangent.Length; i++)
                {
                    stream.WriteFloat(tangent[i]);
                }
            }

            if (uv != null)
            {
                stream.WriteByte(uv.Length);

                for (int i = 0; i < uv.Length; i++)
                {
                    for (int j = 0; j < uv[i].Length; j++)
                    {
                        stream.WriteFloat(uv[i][j]);
                    }
                }
            }

            for (int i = 0; i < vertex.Length; i++)
            {
                stream.WriteFloat(vertex[i]);
            }

            stream.WriteByte(indexes.Length);

            if (isBig)
            {
                for (int i = 0; i < indexes.Length; i++)
                {
                    uint[] idxs = indexes[i];

                    stream.WriteUInt32((uint)(idxs.Length / 3));

                    uint j = 0;
                    while (j < idxs.Length)
                    {
                        stream.WriteUInt32(idxs[j++]);
                    }
                }
            }
            else
            {
                for (int i = 0; i < indexes.Length; i++)
                {
                    uint[] idxs = indexes[i];

                    stream.WriteUInt16(idxs.Length / 3);

                    int j = 0;
                    while (j < idxs.Length)
                    {
                        stream.WriteUInt16((int)idxs[j++]);
                    }
                }
            }

            return stream;
        }
Exemplo n.º 11
0
 protected void WriteTags(ByteArray data)
 {
     data.WriteByte(0);
 }
Exemplo n.º 12
0
 public void WriteDataObject(ByteArray data)
 {
     WriteBytesObject(data.ToArray());
 }
Exemplo n.º 13
0
 public void WriteData(ByteArray data)
 {
     WriteBytes(data.ToArray());
 }
Exemplo n.º 14
0
 public override ByteArray Write()
 {
     ByteArray data = new ByteArray();
     data.WriteUTFBytes(url);
     return data;
 }
Exemplo n.º 15
0
        protected int WriteLight(ByteArray header)
        {
            int attrib = Write3D(header);

            return attrib;
        }