public object Load(Stream stream, string assetName)
        {
            GravityModel model = new GravityModel();

            if (!model.Load(stream))
                return false;

            stream.Close();

            return model;
        }
        public void Load(GravityModel owner, BinaryReader br, byte majorVersion, byte minorVersion)
        {
            _name       = br.ReadCString(40);
            _parentName = br.ReadCString(40);

            _textures = new Texture2D[br.ReadInt32()];
            for (int i = 0; i < _textures.Length; i++)
            {
                _textures[i] = owner.Textures[br.ReadInt32()];
            }

            _matrix = Matrix.Identity;

            _matrix.M11 = br.ReadSingle();
            _matrix.M12 = br.ReadSingle();
            _matrix.M13 = br.ReadSingle();

            _matrix.M21 = br.ReadSingle();
            _matrix.M22 = br.ReadSingle();
            _matrix.M23 = br.ReadSingle();

            _matrix.M31 = br.ReadSingle();
            _matrix.M32 = br.ReadSingle();
            _matrix.M33 = br.ReadSingle();

            _position.X = br.ReadSingle();
            _position.Y = br.ReadSingle();
            _position.Z = br.ReadSingle();

            _position2.X = br.ReadSingle();
            _position2.Y = br.ReadSingle();
            _position2.Z = br.ReadSingle();

            _rotationAngle = br.ReadSingle();

            _rotationAxis.X = br.ReadSingle();
            _rotationAxis.Y = br.ReadSingle();
            _rotationAxis.Z = br.ReadSingle();

            _scale.X = br.ReadSingle();
            _scale.Y = br.ReadSingle();
            _scale.Z = br.ReadSingle();

            Vector3[] vertices = new Vector3[br.ReadInt32()];
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i].X = br.ReadSingle();
                vertices[i].Y = br.ReadSingle();
                vertices[i].Z = br.ReadSingle();
            }

            Vector2[] texcoords = new Vector2[br.ReadInt32()];
            for (int i = 0; i < texcoords.Length; i++)
            {
                if (majorVersion > 1 || (majorVersion == 1 && minorVersion >= 2))
                {
                    br.ReadSingle();
                }

                texcoords[i].X = br.ReadSingle();
                texcoords[i].Y = br.ReadSingle();
            }

            List <VertexPositionNormalTexture> ggvertices = new List <VertexPositionNormalTexture>();

            List <int>[] indexes = new List <int> [_textures.Length];

            for (int i = 0; i < _textures.Length; i++)
            {
                indexes[i] = new List <int>();
            }

            int count = br.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                int start = i * 3;

                Vector3 v1 = vertices[br.ReadInt16()];
                Vector3 v2 = vertices[br.ReadInt16()];
                Vector3 v3 = vertices[br.ReadInt16()];

                Vector2 t1 = texcoords[br.ReadInt16()];
                Vector2 t2 = texcoords[br.ReadInt16()];
                Vector2 t3 = texcoords[br.ReadInt16()];

                int tex = br.ReadInt16();
                br.ReadInt16();
                int twoSide     = br.ReadInt32();
                int smoothGroup = br.ReadInt32();

                Vector3 normal = Vector3.Cross(v1 - v3, v2 - v3);
                normal.Normalize();

                ggvertices.Add(new VertexPositionNormalTexture(v1, normal, t1));
                ggvertices.Add(new VertexPositionNormalTexture(v2, normal, t2));
                ggvertices.Add(new VertexPositionNormalTexture(v3, normal, t3));

                indexes[tex].Add(start + 0);
                indexes[tex].Add(start + 1);
                indexes[tex].Add(start + 2);
            }

            gvertices = ggvertices.ToArray();

            _rotationFrames = new Tuple <Quaternion, int> [br.ReadInt32()];
            for (int i = 0; i < _rotationFrames.Length; i++)
            {
                int        time = br.ReadInt32();
                Quaternion q    = new Quaternion();

                q.X = br.ReadSingle();
                q.Y = br.ReadSingle();
                q.Z = br.ReadSingle();
                q.W = br.ReadSingle();

                _rotationFrames[i] = new Tuple <Quaternion, int>(q, time);
            }

            _vertices = new VertexBuffer(SharedInformation.GraphicsDevice, typeof(VertexPositionNormalTexture), gvertices.Length, BufferUsage.WriteOnly);
            _vertices.SetData(gvertices);

            _indexes = new IndexBuffer[_textures.Length];
            for (int i = 0; i < _textures.Length; i++)
            {
                if (indexes[i].Count > 0)
                {
                    _indexes[i] = new IndexBuffer(SharedInformation.GraphicsDevice, typeof(int), indexes[i].Count, BufferUsage.WriteOnly);
                    _indexes[i].SetData(indexes[i].ToArray());
                }
            }
        }
        public void Load(GravityModel owner, BinaryReader br, byte majorVersion, byte minorVersion)
        {
            _name = br.ReadCString(40);
            _parentName = br.ReadCString(40);

            _textures = new Texture2D[br.ReadInt32()];
            for (int i = 0; i < _textures.Length; i++)
            {
                _textures[i] = owner.Textures[br.ReadInt32()];
            }

            _matrix = Matrix.Identity;

            _matrix.M11 = br.ReadSingle();
            _matrix.M12 = br.ReadSingle();
            _matrix.M13 = br.ReadSingle();

            _matrix.M21 = br.ReadSingle();
            _matrix.M22 = br.ReadSingle();
            _matrix.M23 = br.ReadSingle();

            _matrix.M31 = br.ReadSingle();
            _matrix.M32 = br.ReadSingle();
            _matrix.M33 = br.ReadSingle();

            _position.X = br.ReadSingle();
            _position.Y = br.ReadSingle();
            _position.Z = br.ReadSingle();

            _position2.X = br.ReadSingle();
            _position2.Y = br.ReadSingle();
            _position2.Z = br.ReadSingle();

            _rotationAngle = br.ReadSingle();

            _rotationAxis.X = br.ReadSingle();
            _rotationAxis.Y = br.ReadSingle();
            _rotationAxis.Z = br.ReadSingle();

            _scale.X = br.ReadSingle();
            _scale.Y = br.ReadSingle();
            _scale.Z = br.ReadSingle();

            Vector3[] vertices = new Vector3[br.ReadInt32()];
            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i].X = br.ReadSingle();
                vertices[i].Y = br.ReadSingle();
                vertices[i].Z = br.ReadSingle();
            }

            Vector2[] texcoords = new Vector2[br.ReadInt32()];
            for (int i = 0; i < texcoords.Length; i++)
            {
                if (majorVersion > 1 || (majorVersion == 1 && minorVersion >= 2))
                    br.ReadSingle();

                texcoords[i].X = br.ReadSingle();
                texcoords[i].Y = br.ReadSingle();
            }

            List<VertexPositionNormalTexture> ggvertices = new List<VertexPositionNormalTexture>();
            List<int>[] indexes = new List<int>[_textures.Length];

            for (int i = 0; i < _textures.Length; i++)
                indexes[i] = new List<int>();

            int count = br.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                int start = i * 3;

                Vector3 v1 = vertices[br.ReadInt16()];
                Vector3 v2 = vertices[br.ReadInt16()];
                Vector3 v3 = vertices[br.ReadInt16()];

                Vector2 t1 = texcoords[br.ReadInt16()];
                Vector2 t2 = texcoords[br.ReadInt16()];
                Vector2 t3 = texcoords[br.ReadInt16()];

                int tex = br.ReadInt16();
                br.ReadInt16();
                int twoSide = br.ReadInt32();
                int smoothGroup = br.ReadInt32();

                Vector3 normal = Vector3.Cross(v1 - v3, v2 - v3);
                normal.Normalize();

                ggvertices.Add(new VertexPositionNormalTexture(v1, normal, t1));
                ggvertices.Add(new VertexPositionNormalTexture(v2, normal, t2));
                ggvertices.Add(new VertexPositionNormalTexture(v3, normal, t3));

                indexes[tex].Add(start + 0);
                indexes[tex].Add(start + 1);
                indexes[tex].Add(start + 2);
            }

            gvertices = ggvertices.ToArray();

            _rotationFrames = new Tuple<Quaternion, int>[br.ReadInt32()];
            for (int i = 0; i < _rotationFrames.Length; i++)
            {
                int time = br.ReadInt32();
                Quaternion q = new Quaternion();

                q.X = br.ReadSingle();
                q.Y = br.ReadSingle();
                q.Z = br.ReadSingle();
                q.W = br.ReadSingle();

                _rotationFrames[i] = new Tuple<Quaternion, int>(q, time);
            }

            _vertices = new VertexBuffer(SharedInformation.GraphicsDevice, typeof(VertexPositionNormalTexture), gvertices.Length, BufferUsage.WriteOnly);
            _vertices.SetData(gvertices);

            _indexes = new IndexBuffer[_textures.Length];
            for (int i = 0; i < _textures.Length; i++)
            {
                if (indexes[i].Count > 0)
                {
                    _indexes[i] = new IndexBuffer(SharedInformation.GraphicsDevice, typeof(int), indexes[i].Count, BufferUsage.WriteOnly);
                    _indexes[i].SetData(indexes[i].ToArray());
                }
            }
        }