Exemplo n.º 1
0
	Matrix4* BMaxObject::GetRenderMatrix(Matrix4& mxWorld, int nRenderNumber /*= 0*/)
	{
		mxWorld.identity();

		// order of rotation: roll * pitch * yaw , where roll is applied first. 
		bool bIsIdentity = true;

		float fScaling = GetScaling();
		if (fScaling != 1.f)
		{
			Matrix4 matScale;
			ParaMatrixScaling((Matrix4*)&matScale, fScaling, fScaling, fScaling);
			mxWorld = (bIsIdentity) ? matScale : matScale.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		float fYaw = GetYaw();
		if (fYaw != 0.f)
		{
			Matrix4 matYaw;
			ParaMatrixRotationY((Matrix4*)&matYaw, fYaw);
			mxWorld = (bIsIdentity) ? matYaw : matYaw.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		if (GetPitch() != 0.f)
		{
			Matrix4 matPitch;
			ParaMatrixRotationX(&matPitch, GetPitch());
			mxWorld = (bIsIdentity) ? matPitch : matPitch.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		if (GetRoll() != 0.f)
		{
			Matrix4 matRoll;
			ParaMatrixRotationZ(&matRoll, GetRoll());
			mxWorld = (bIsIdentity) ? matRoll : matRoll.Multiply4x3(mxWorld);
			bIsIdentity = false;
		}

		// world translation
		Vector3 vPos = GetRenderOffset();
		mxWorld._41 += vPos.x;
		mxWorld._42 += vPos.y;
		mxWorld._43 += vPos.z;

		return &mxWorld;
	}
Exemplo n.º 2
0
void ParaEngine::CPainter::ScaleMatrix(float x, float y, float z)
{
	Matrix4 mat;
	mat.makeScale(x, y, z);
	m_curMatrix = mat.Multiply4x3(m_curMatrix);
	engine->transformChanged();
}
Exemplo n.º 3
0
void ParaEngine::CPainter::RotateMatrix(float angle, float x, float y, float z)
{
	Matrix4 mat;
	mat.makeRot(Quaternion(Vector3(x, y, z), angle), Vector3::ZERO);
	m_curMatrix = mat.Multiply4x3(m_curMatrix);
	engine->transformChanged();
}
Exemplo n.º 4
0
void ParaEngine::CBoneChain::RotateBoneChain(const Vector3& vAxis, Bone* allBones, int nMaxBoneNum, float fAngle, const AnimIndex& CurrentAnim, const AnimIndex& BlendingAnim, float blendingFactor, IAttributeFields* pAnimInstance /*= NULL*/)
{
	for (int i = 0; i < m_nBoneCount; i++)
	{
		int nBoneID = m_boneChain[i].nBoneID;
		if (nBoneID < nMaxBoneNum && nBoneID >= 0)
		{
			Bone & bone = allBones[nBoneID];
			bone.calcMatrix(allBones, CurrentAnim, BlendingAnim, blendingFactor, pAnimInstance);
			// just rotate one bone at most. 
			Matrix4 mAfterRot(Quaternion(vAxis, fAngle));
			if (bone.bUsePivot)
			{
				Matrix4 M;
				// use pivot point
				M.makeTrans(bone.pivot*-1.0f);
				mAfterRot = M.Multiply4x3(mAfterRot);
				mAfterRot.offsetTrans(bone.pivot);
			}
			bone.mat = mAfterRot.Multiply4x3(bone.mat);
			bone.mrot = mAfterRot.Multiply4x3(bone.mrot);
			break;
		}
	}
}
Exemplo n.º 5
0
void ParaEngine::CPainter::MultiplyMatrix(const Matrix4& mat)
{
	m_curMatrix = mat.Multiply4x3(m_curMatrix);
	engine->transformChanged();
}