コード例 #1
0
//For AssImp versions < 3.1 (I think). Will wait a year a so before I use the 3.1 aiMatrix4x4-constructor instead
aiMatrix4x4 aiMatrix4x4Compose(const aiVector3D& scaling, const aiQuaternion& rotation, const aiVector3D& position) {
    aiMatrix4x4 r;

    aiMatrix3x3 m = rotation.GetMatrix();

    r.a1 = m.a1 * scaling.x;
    r.a2 = m.a2 * scaling.x;
    r.a3 = m.a3 * scaling.x;
    r.a4 = position.x;

    r.b1 = m.b1 * scaling.y;
    r.b2 = m.b2 * scaling.y;
    r.b3 = m.b3 * scaling.y;
    r.b4 = position.y;

    r.c1 = m.c1 * scaling.z;
    r.c2 = m.c2 * scaling.z;
    r.c3 = m.c3 * scaling.z;
    r.c4= position.z;

    r.d1 = 0.0;
    r.d2 = 0.0;
    r.d3 = 0.0;
    r.d4 = 1.0;

    return r;
}
コード例 #2
0
ファイル: Mesh.cpp プロジェクト: Greasiness/Rad
void Mesh::CalcInterpolatedRotation(aiQuaternion& Out, double AnimationTime, const aiNodeAnim* pNodeAnim)
{
	// we need at least two values to interpolate...
	if (pNodeAnim->mNumRotationKeys == 1) {
		Out = pNodeAnim->mRotationKeys[0].mValue;
		return;
	}

	uint RotationIndex = FindRotation(AnimationTime, pNodeAnim);
	uint NextRotationIndex = (RotationIndex + 1);
	assert(NextRotationIndex < pNodeAnim->mNumRotationKeys);
	float DeltaTime = (float)(pNodeAnim->mRotationKeys[NextRotationIndex].mTime - pNodeAnim->mRotationKeys[RotationIndex].mTime);
	double Factor = (AnimationTime - (double)pNodeAnim->mRotationKeys[RotationIndex].mTime) / DeltaTime;
	assert(Factor >= 0.0f && Factor <= 1.0f);
	const aiQuaternion& StartRotationQ = pNodeAnim->mRotationKeys[RotationIndex].mValue;
	const aiQuaternion& EndRotationQ = pNodeAnim->mRotationKeys[NextRotationIndex].mValue;
	aiQuaternion::Interpolate(Out, StartRotationQ, EndRotationQ, Factor);
	Out = Out.Normalize();
}
コード例 #3
0
ファイル: main.cpp プロジェクト: Jasper-Bekkers/sunshine
// Angle in degrees
void convertToAxisAngle(aiQuaternion q, aiVector3D &axis, float &deg)
{
	q.Normalize();
	
	float s = sqrtf(1.f - q.w * q.w);
	deg = (2.f * acosf(q.w)) * 180.f / 3.14159265358979f;

	if(s < 0.0001)
	{
		axis.x = q.x;
		axis.y = q.y;
		axis.z = q.z;
	}
	else
	{
		float rcp = 1.f / s;
		axis.x = q.x * rcp;
		axis.y = q.y * rcp;
		axis.z = q.z * rcp;
	}
}