コード例 #1
0
ファイル: Animation.cpp プロジェクト: xctrex/KrakEngine
    void Animation::ReadFrom(ChunkReader& file)
    {
        GChunk animation = file.ReadChunkHeader();

        UINT NumberOfTracks = 0;
        file.Read(Duration);
        file.Read(NumberOfTracks);

        m_Tracks.resize(NumberOfTracks);
        for (UINT t = 0; t < NumberOfTracks; ++t)
        {
            UINT NumberOfKeyframes = 0;
            file.Read(NumberOfKeyframes);
            m_Tracks[t].KeyFrames.resize(NumberOfKeyframes);
            for (UINT f = 0; f < NumberOfKeyframes; ++f){
                // Read in the frame data of the keyframe
                Frame frame;
                file.Read(frame);
                m_Tracks[t].KeyFrames[f].time = frame.time;
                m_Tracks[t].KeyFrames[f].vqs.v = frame.T;
                m_Tracks[t].KeyFrames[f].vqs.q = frame.R;
            }
        }
    }
コード例 #2
0
ファイル: Animation.cpp プロジェクト: xctrex/KrakEngine
    void Skeleton::ReadFrom(ChunkReader& file)
    {
        GChunk skeletonChunk = file.ReadChunkHeader();

        UINT NumberOfBones = 0;
        file.Read(NumberOfBones);

        m_Bones.resize(NumberOfBones);
        m_OldJointPositions2D.resize(m_IKNumLinks);
        m_CurrentJointPositions2D.resize(m_IKNumLinks);
        m_TargetJointPositions2D.resize(m_IKNumLinks);
        m_OldJointRotations2D.resize(m_IKNumLinks);
        m_CurrentJointRotations2D.resize(m_IKNumLinks);
        m_TargetJointRotations2D.resize(m_IKNumLinks);

        // Initialize rotations
        for (size_t i = 0; i < m_OldJointRotations2D.size(); ++i)
        {
            m_OldJointRotations2D[i] = 0.f;
            m_CurrentJointRotations2D[i] = 0.f;
            m_TargetJointRotations2D[i] = 0.f;
        }
        m_OldJointRotations2D[0] = PI / 2.f;
        m_CurrentJointRotations2D[0] = PI / 2.f;
        m_TargetJointRotations2D[0] = PI / 2.f;

        // Initialize positions
        CalculateOldPosition2D();
        CalculateCurrentPosition2D();
        CalculateTargetPosition2D();

        for (UINT i = 0; i < NumberOfBones; ++i)
        {
            file.Read(m_Bones[i].Name);
            file.Read(m_Bones[i].ParentBoneIndex);

            // Read the bind pose
            XMFLOAT3 T;
            file.Read(T);
            XMFLOAT4 R;
            file.Read(R);
            m_Bones[i].BindVQS = VQS(T, R, 1.0f);

            // Read the model to bone space VQS
            file.Read(T);
            file.Read(R);
            m_Bones[i].ModelToBoneSpaceVQS = VQS(T, R, 1.0f);
        }
    }
コード例 #3
0
void Mesh::ReadFrom( ChunkReader& file )
{
	GChunk meshChunk = file.ReadChunkHeader();

	file.Read( VertexType );
	VertexSize = VertexDescription::Desc[ VertexType ].SizeOfVertex;

	file.Read( NumIndices );
	indexBufferData = new uint[ NumIndices ];
	file.ReadArray( indexBufferData , NumIndices );

	file.Read( NumVertices );
	vertexBufferData = new byte[ NumVertices * VertexSize ];
	file.ReadArraySize( vertexBufferData , NumVertices * VertexSize );

	NumPrimitives = NumIndices/3;
}