Exemplo n.º 1
0
    protected PC2Animation ParsePC2(TextAsset data)
    {
        PC2Animation anim = new PC2Animation();

        MemoryStream stream = new MemoryStream(data.bytes);
        BinaryReader reader = new BinaryReader(stream);

        // Skip header

        reader.ReadBytes(16);

        // Vertex count

        anim.vertexCount = reader.ReadInt32();

        // Skip irrelevant

        reader.ReadBytes(8);

        // Sample count

        anim.sampleCount = reader.ReadInt32();

        // Vertex data

        anim.vertices = new List <Vector3>();

        for (int i = 0; i < anim.sampleCount; ++i)
        {
            for (int j = 0; j < anim.vertexCount; ++j)
            {
                Vector3 vector = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                anim.vertices.Add(vector);
            }
        }

        anim.count = vertices.Length * anim.sampleCount;

        stream.Close();

        return(anim);
    }
Exemplo n.º 2
0
    protected PC2Animation ParsePC2(TextAsset data)
    {
        PC2Animation anim = new PC2Animation();

        MemoryStream stream = new MemoryStream(data.bytes);
        BinaryReader reader = new BinaryReader(stream);

        // Skip header

        reader.ReadBytes(16);

        // Vertex count

        anim.vertexCount = reader.ReadInt32();

        // Skip irrelevant

        reader.ReadBytes(8);

        // Sample count

        anim.sampleCount = reader.ReadInt32();

        // Vertex data

        anim.vertices = new List<Vector3>();

        for (int i = 0; i < anim.sampleCount; ++i)
        {
            for (int j = 0; j < anim.vertexCount; ++j)
            {
                Vector3 vector = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                anim.vertices.Add(vector);
            }
        }

        anim.count = vertices.Length * anim.sampleCount;

        stream.Close();

        return anim;
    }
Exemplo n.º 3
0
    void Start()
    {
        if (storedPC2Animations == null)
        {
            storedPC2Animations = new Dictionary <string, PC2Animation>();
        }

        transform.Rotate(rotationAdjustment);

        interval     = 1.0f / framerate;
        mesh         = this.GetComponent <MeshFilter>().mesh;
        vertices     = mesh.vertices;
        currentFrame = frameOffset;

        currentIndex = targetIndex = startingAnimationIndex;

        pc2Animations = new PC2Animation[rawDataItems.Length];

        int i = 0;

        foreach (TextAsset rawData in rawDataItems)
        {
            string signature = Signature(rawData.bytes, 128);

            if (!storedPC2Animations.ContainsKey(signature))
            {
                PC2Animation parsed = ParsePC2(rawData);
                storedPC2Animations.Add(signature, parsed);
            }

            PC2Animation stored = storedPC2Animations[signature];

            pc2Animations[i++] = stored;
        }

        ready = true;
    }