Example #1
0
void Bvh::Draw(int animId, double time)
{
	if (!m_block.indices.size()) {
		return;
	}

	Mat BoneMatrices[BONE_MAX];
	assert(m_frames.size() <= dimof(BoneMatrices));

	if (animId != 0) {
		for (auto& it : m_frames) {
			it.frameTransformMatrix = v2m(it.offset);
		}
		CalcFrameMatrices();
	} else {
		CalcAnimation(time);
	}

	if (g_type == "pivot") {
		for (BONE_ID i = 0; (unsigned)i < m_frames.size(); i++)	{
			BvhFrame& f = m_frames[i];
			BoneMatrices[i] = f.result;
		}
		debugRenderer.DrawPivots(BoneMatrices, m_frames.size());
	} else {
		for (BONE_ID i = 0; (unsigned)i < m_frames.size(); i++)	{
			BvhFrame& f = m_frames[i];
			BoneMatrices[i] = f.boneOffsetMatrix * f.result;
		}
		m_meshRenderer.Draw(BoneMatrices, dimof(BoneMatrices), m_block);
	}
}
Example #2
0
void Camera::CalcAnimation(GLfloat start[3], GLfloat end[3], GLfloat radius, int count)
{
    GLfloat dR = (radius - rad) / (GLfloat)count;
    for (int i = 0; i < count; i++)
    {
        radius_an[i] = rad + i*dR;
    }
    rad = radius_an[count-1];
    CalcAnimation(start, end, count);
}