当前位置: 首页>>代码示例>>C++>>正文


C++ MFMatrix类代码示例

本文整理汇总了C++中MFMatrix的典型用法代码示例。如果您正苦于以下问题:C++ MFMatrix类的具体用法?C++ MFMatrix怎么用?C++ MFMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MFMatrix类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Game_Update

void Game_Update()
{
	// calculate a spinning world matrix
	MFMatrix world;
	world.SetTranslation(MakeVector(0, -5, 50));

	static float rotation = 0.0f;
	rotation += MFSystem_TimeDelta();
	world.RotateY(rotation);

	// set world matrix to the model
	MFModel_SetWorldMatrix(pModel, world);

	// advance the animation
	MFAnimation *pAnim = MFModel_GetAnimation(pModel);
	if(pAnim)
	{
		float start, end;
		MFAnimation_GetFrameRange(pAnim, &start, &end);
	
		static float time = 0.f;
		time += MFSystem_TimeDelta();// * 500;
		while(time >= end)
			time -= end;
		MFAnimation_SetFrame(pAnim, time);
	}
}
开发者ID:FujiGameJam,项目名称:fuji,代码行数:27,代码来源:main.cpp

示例2: MFRenderer_ClearScreen

void EditorScreen::Draw()
{
	GHScreen::DrawScreens();	

	MFRenderer_ClearScreen(MFRCF_Depth);

	MFMatrix mat;
	mat.LookAt(MakeVector(2.0,1.5,-1.0), MakeVector(1.0,0.3f,1.0f));
	MFView_SetCameraMatrix(mat);
//	pScene->Draw();
}
开发者ID:KingDwag,项目名称:feedback-editor,代码行数:11,代码来源:Editor.cpp

示例3: HitNote

void Fretboard::HitNote(int note)
{
	float fretboardWidth = 7.0f;
	float columnWidth = fretboardWidth / 5.0f;
	float halfFB = fretboardWidth*0.5f;

	MFMatrix mat;
	mat.SetTranslation(MakeVector(-halfFB + (float)note*columnWidth + columnWidth*0.5f, 0.f, 0.f));

	MFParticleSystem_SetWorldMatrix(pEmitter, mat);
	MFParticleSystem_BurstEmit(pEmitter, 100);
}
开发者ID:KingDwag,项目名称:feedback-editor,代码行数:12,代码来源:Track.cpp

示例4: Game_Update

void Game_Update()
{
	static float rotation = 0.0f;
	rotation += MFSystem_GetTimeDelta();

	// spin the prism
	MFMatrix world;
	world.SetTranslation(MakeVector(0, 0.3f, 3));
	world.RotateY(rotation * 2.3f);
	MFStateBlock_SetMatrix(pPrismStateBlock, MFSCM_World, world);

	// spin the box
	world.SetTranslation(MakeVector(0, 0, 5));
	world.RotateYPR(rotation, rotation * 2.0f, rotation * 0.5f);
	MFStateBlock_SetMatrix(pBoxStateBlock, MFSCM_World, world);
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例5: MFMat_Standard_CreateInstancePlatformSpecific

void MFMat_Standard_CreateInstancePlatformSpecific(MFMaterial *pMaterial)
{
	MFMat_Standard_Data_D3D11 *pData = (MFMat_Standard_Data_D3D11*)pMaterial->pInstanceData;

	MFMatrix mat = pData->textureMatrix;
	mat.Transpose();

	pData->cbMaterial.mTexMatrix[0] = mat.GetXAxis();
	pData->cbMaterial.mTexMatrix[1] = mat.GetYAxis();
	pData->cbMaterial.vMeshColour = MFVector::white;
	pData->cbMaterial.gModelColour = MFVector::white;
	pData->cbMaterial.gColourMask = MakeVector(1.0f, 0.0f, 1.0f, 0.0f);

	D3D11_BUFFER_DESC desc;
	MFZeroMemory(&desc, sizeof(desc));
	desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	desc.ByteWidth = sizeof(pData->cbMaterial);
	desc.Usage = D3D11_USAGE_DEFAULT;
	//desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;

	g_pd3dDevice->CreateBuffer(&desc, NULL, &pData->pConstantBuffer);

	MFRenderer_D3D11_SetDebugName(pData->pConstantBuffer, pMaterial->pName);
}
开发者ID:TurkeyMan,项目名称:fuji,代码行数:24,代码来源:MFMat_Standard_D3D11.cpp

示例6: MFRendererXB_SetTextureMatrix

void MFRendererXB_SetTextureMatrix(const MFMatrix &textureMatrix)
{
	MFMatrix texMat = textureMatrix;
	texMat.SetZAxis3(texMat.GetTrans());
	pd3dDevice->SetTransform(D3DTS_TEXTURE0, (D3DMATRIX*)&texMat);
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:6,代码来源:MFRenderer_XB.cpp

示例7: Game_Draw

void Game_Draw()
{
	MFCALLSTACK;

	MFRenderer_SetClearColour(0.f, 0.f, 0.2f, 1.f);
	MFRenderer_ClearScreen();

	// Set identity camera (no camera)
	MFView_Push();
	MFView_SetAspectRatio(MFDisplay_GetNativeAspectRatio());
	MFView_SetProjection();

	MFMaterial_SetMaterial(MFMaterial_GetStockMaterial(MFMat_White));

	// set the world matrix to identity
	MFMatrix world = MFMatrix::identity;

	// move the box into the scene (along the z axis)
	world.Translate(MakeVector(0, 0, 5));

	// increment rotation
	static float rotation = 0.0f;
	rotation += MFSystem_TimeDelta();

	// rotate the box
	world.RotateYPR(rotation, rotation * 2.0f, rotation * 0.5f);

	// begin rendering the box
	MFPrimitive(PT_TriList);
	MFSetMatrix(world);

	// begin rendering 12 triangles (12 * 3 vertices)
	MFBegin(3 * 12);

	// draw a bunch of triangles
	MFSetColour(1,0,0,1);
	MFSetPosition(-1,-1, -1);
	MFSetPosition(-1, 1, -1);
	MFSetPosition( 1, 1, -1);
	MFSetPosition(-1,-1, -1);
	MFSetPosition( 1, 1, -1);
	MFSetPosition( 1,-1, -1);

	MFSetColour(0,1,0,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition( 1,-1,1);
	MFSetPosition( 1, 1,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition( 1, 1,1);
	MFSetPosition(-1, 1,1);

	MFSetColour(0,0,1,1);
	MFSetPosition( 1,-1,1);
	MFSetPosition( 1,-1,-1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition( 1,-1,1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition( 1, 1,1);

	MFSetColour(1,0,1,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition(-1, 1,1);
	MFSetPosition(-1, 1,-1);
	MFSetPosition(-1,-1,1);
	MFSetPosition(-1, 1,-1);
	MFSetPosition(-1,-1,-1);

	MFSetColour(1,1,0,1);
	MFSetPosition(-1, 1,1);
	MFSetPosition( 1, 1,1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition(-1, 1,1);
	MFSetPosition( 1, 1,-1);
	MFSetPosition(-1, 1,-1);

	MFSetColour(0,1,1,1);
	MFSetPosition(-1,-1,1);
	MFSetPosition(-1,-1,-1);
	MFSetPosition( 1,-1,-1);
	MFSetPosition(-1,-1,1);
	MFSetPosition( 1,-1,-1);
	MFSetPosition( 1,-1,1);

	MFEnd();

	MFRect disp;
	MFDisplay_GetDisplayRect(&disp);
	MFView_SetOrtho(&disp);
	pUI->Draw();

	MFView_Pop();
}
开发者ID:,项目名称:,代码行数:92,代码来源:

示例8: Multiply

MFMatrix& MFMatrix::Scale(const MFVector& scale)
{
	MFMatrix mat;
	mat.SetScale(scale);
	return Multiply(mat);
}
开发者ID:FujiGameJam,项目名称:fuji,代码行数:6,代码来源:MFMatrix.cpp

示例9:

MFMatrix& MFMatrix::RotateZ(float angle)
{
	MFMatrix rot;
	rot.SetRotationZ(angle);
	return Multiply3x3(rot);
}
开发者ID:FujiGameJam,项目名称:fuji,代码行数:6,代码来源:MFMatrix.cpp

示例10: GetNextToken

const char *ParseFrame(const char *pText, const MFMatrix &mat, int parentID)
{
	char frameName[64];
	const char *pName = GetNextToken(pText, &pText, frameName);

	MFMatrix worldMatrix = mat;

	F3DBone *pBone = NULL;

	if(!MFString_CaseCmpN(pName, "bn_", 3) || !MFString_CaseCmpN(pName, "z_", 2))
	{
		int boneID = pModel->GetSkeletonChunk()->bones.size();
		pBone = &pModel->GetSkeletonChunk()->bones[boneID];

		F3DBone *pParent = parentID == -1 ? NULL : &pModel->GetSkeletonChunk()->bones[parentID];
		parentID = boneID;

		MFString_Copy(pBone->name, pName);
		MFString_Copy(pBone->parentName, pParent ? pParent->name : "");

		pBone->worldMatrix = mat;
	}

	if(MFString_Compare(pName, "{"))
		SkipToken(pText, "{");

	const char *pTok = GetNextToken(pText, &pText);

	while(MFString_Compare(pTok, "}"))
	{
		if(!MFString_Compare(pTok, "Frame"))
		{
			pText = ParseFrame(pText, worldMatrix, parentID);
		}
		else if(!MFString_Compare(pTok, "FrameTransformMatrix"))
		{
			SkipToken(pText, "{");

			MFMatrix localMatrix;
			GetFloatArray(pText, (float*)&localMatrix, 16, &pText);

			worldMatrix.Multiply(localMatrix, worldMatrix);

			if(pBone)
			{
				pBone->boneMatrix = localMatrix;
				pBone->worldMatrix = worldMatrix;
			}

			SkipToken(pText, ";");
			SkipToken(pText, "}");
		}
		else if(!MFString_Compare(pTok, "Mesh"))
		{
			gMeshChunks.push(XMeshChunk::Create(worldMatrix, pText, pName));
			SkipSection(pText);
		}
		else
		{
			MFDebug_Warn(4, MFStr("Unexpected token '%s'\n", pTok));
			SkipSection(pText);
		}

		pTok = GetNextToken(pText, &pText);
	}

	return pText;
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:68,代码来源:ReadX.cpp

示例11: MFParticleSystem_AddParticle

MF_API void MFParticleSystem_AddParticle(MFParticleEmitter *pEmitter)
{
	MFParticleEmitterParameters *pE = &pEmitter->params;
	MFParticleSystem *pParticleSystem = pE->pParticleSystem;

	MFParticle *pNew = NULL;
	if(pParticleSystem->particles.GetLength() < pParticleSystem->params.maxActiveParticles)
		pNew = pParticleSystem->particles.Create();

	if(pNew)
	{
		MFParticleParameters *pP = &pParticleSystem->params;

		pNew->colour = pP->colour;
		pNew->life = pP->life;
		pNew->rot = 0.0f;
		pNew->size = pP->size;

		switch(pE->type)
		{
			case MFET_Point:
				pNew->pos = pE->position.GetTrans();
				break;

			case MFET_Sphere:
			case MFET_Disc:
			{
				MFVector offset;

				do
				{
					offset = MakeVector(MFRand_Range(-pE->radius, pE->radius), MFRand_Range(-pE->radius, pE->radius), MFRand_Range(-pE->radius, pE->radius));
				}
				while(offset.MagSquared3() > pE->radius*pE->radius);

				if(pE->type == MFET_Disc)
				{
					// flatten it on to the disc
					float dist = offset.Dot3(pE->position.GetYAxis());
					offset -= pE->position.GetYAxis()*dist;
				}

				pNew->pos = pE->position.GetTrans() + offset;

				break;
			}
		}

		switch(pE->behaviour)
		{
			case MFEB_Direction:
				pNew->velocity.Normalise3(pE->startVector);
				break;
			case MFEB_TargetAttract:
				pNew->velocity.Normalise3(pE->startVector - pE->position.GetTrans());
				break;
			case MFEB_TargetRepel:
				pNew->velocity.Normalise3(pE->position.GetTrans() - pE->startVector);
				break;
		}

		pNew->velocity *= pE->velocity + MFRand_Range(-pE->velocityScatter, pE->velocityScatter);

		if(pE->directionScatter)
		{
			MFVector scatter;

			do
			{
				scatter = MakeVector(MFRand_Range(-1, 1), MFRand_Range(-1, 1), MFRand_Range(-1, 1));

				float dist = scatter.Dot3(pE->position.GetYAxis());
				scatter -= pE->position.GetYAxis()*dist;
			}
			while(scatter.MagSquared3() < 0.000001f);

			scatter.Normalise3();

			MFMatrix scatterMat;
			scatterMat.SetRotation(scatter, MFRand_Unit()*pE->directionScatter);

			pNew->velocity = ApplyMatrixH(pNew->velocity, scatterMat);
		}
	}
}
开发者ID:RemedyGameJam,项目名称:fuji,代码行数:85,代码来源:MFParticleSystem_Null.cpp

示例12: transformGeometry

void CPUSkinningAlgorithm::transformGeometry(
    SkinnedGeometry           *skinGeo,
    Skeleton                  *skel,
    CPUSkinningDataAttachment *data)
{
    const SkinnedGeometry::MFPropIndicesType *mfOrigIdx   =
        skinGeo->getMFPropIndices();
    const SkinnedGeometry::MFPropertiesType  *mfOrigProps =
        skinGeo->getMFProperties();
    SkinnedGeometry::MFPropertiesType        *mfProps     =
        data->editMFProperties();

    const GeoVec4fProperty *jointIdxProp    =
        dynamic_cast<const GeoVec4fProperty *>(
            (*mfOrigProps)[skinGeo->getJointIndexProperty()]);
    const GeoVec4fProperty *jointWeightProp =
        dynamic_cast<const GeoVec4fProperty *>(
            (*mfOrigProps)[skinGeo->getJointWeightProperty()]);

    if(skinGeo->getIndex(skinGeo->getJointIndexProperty ()) !=
       skinGeo->getIndex(skinGeo->getJointWeightProperty())   )
    {
        SWARNING << "CPUSkinningAlgorithm::transformGeometry: "
                 << "Multi indexed geometry not supported!"
                 << std::endl;
        return;
    }

    mfProps->resize(mfOrigProps->size(), NULL);

    const MFMatrix *mfJointMat       = NULL;
    const MFMatrix *mfJointNormalMat = NULL;

    // if the geometry has a non-identity bind shape matrix
    // premultiply joint matrices with bind shape matrix and store in data
    // attachment
    if(skinGeo->getBindShapeMatrix().equals(Matrix::identity(), Eps) == false)
    {
        mfJointMat               = skel->getMFJointMatrices ();
        MFMatrix *mfJointBindMat = data->editMFJointMatrices();

        mfJointBindMat->resize(mfJointMat->size());

        for(UInt32 i = 0; i < mfJointMat->size(); ++i)
        {
            (*mfJointBindMat)[i] = (*mfJointMat)[i];
            (*mfJointBindMat)[i].mult(skinGeo->getBindShapeMatrix());
        }

        mfJointMat = data->getMFJointMatrices();

        if(skel->getCalcNormalMatrices() == true)
        {
            mfJointNormalMat               = skel->getMFJointNormalMatrices ();
            MFMatrix *mfJointNormalBindMat = data->editMFJointNormalMatrices();

            mfJointNormalBindMat->resize(mfJointNormalMat->size());

            for(UInt32 i = 0; i < mfJointNormalMat->size(); ++i)
            {
                (*mfJointNormalBindMat)[i] = (*mfJointNormalMat)[i];
                (*mfJointNormalBindMat)[i].mult(skinGeo->getBindShapeMatrix());
            }

            mfJointNormalMat = data->getMFJointNormalMatrices();
        }
        else
        {
            mfJointNormalMat = data->getMFJointMatrices();
        }
    }
    else
    {
        mfJointMat = skel->getMFJointMatrices();

        if(skel->getCalcNormalMatrices() == true)
        {
            mfJointNormalMat = skel->getMFJointNormalMatrices();
        }
        else
        {
            mfJointNormalMat = skel->getMFJointMatrices();
        }
    }

    // transform all properties

    for(UInt16 i = 0; i < mfProps->size(); ++i)
    {
        // do not transform the vertex joint indices/weights
        if(i == skinGeo->getJointIndexProperty () ||
           i == skinGeo->getJointWeightProperty()   )
        {
            continue;
        }

        GeoIntegralProperty *origPropIdx = (*mfOrigIdx  )[i];
        GeoVectorProperty   *origProp    = (*mfOrigProps)[i];
        GeoVectorProperty   *prop        = (*mfProps    )[i];

//.........这里部分代码省略.........
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:101,代码来源:OSGCPUSkinningAlgorithm.cpp

示例13: MFDebug_Assert

MF_API MFMatrix *MFAnimation_CalculateMatrices(MFAnimation *pAnimation, MFMatrix *pLocalToWorld)
{
	MFAnimationBone *pAnims = pAnimation->pTemplate->pBones;
	MFModelBone *pBones = pAnimation->pBones;
	MFMatrix *pMats = pAnimation->pMatrices;

	float t = pAnimation->blendLayer.frameTime;
	MFDebug_Assert(t >= pAnimation->pTemplate->startTime && t <= pAnimation->pTemplate->endTime, "Frame time outside animation range...");

	// find the frame number for each bone
	for(uint32 a=0; a<pAnimation->numBones; a++)
	{
		int map = pAnimation->pBoneMap[a];

		if(map != -1)
		{
			float *pTimes = pAnims[map].pTime;
			int lastFrames = pAnims[map].numFrames-1;

			if(t == pTimes[lastFrames])
			{
				pAnimation->blendLayer.pCurFrames[a].tweenStart = lastFrames;
				pAnimation->blendLayer.pCurFrames[a].tweenEnd = lastFrames;
				pAnimation->blendLayer.pCurFrames[a].tween = 0;
			}
			else
			{
				// TODO: change this to a binary search...
				for(int b=0; b<lastFrames; b++)
				{
					float t1 = pTimes[b];
					float t2 = pTimes[b+1];

					if(t >= pTimes[b] && t < pTimes[b+1])
					{
						pAnimation->blendLayer.pCurFrames[a].tweenStart = b;
						pAnimation->blendLayer.pCurFrames[a].tweenEnd = b+1;
						pAnimation->blendLayer.pCurFrames[a].tween = (t-t1) / (t2-t1);
						break;
					}
				}
			}
		}
	}

	// calculate the matrix for each bone
	for(uint32 a=0; a<pAnimation->numBones; a++)
	{
		int map = pAnimation->pBoneMap[a];

		if(map != -1)
		{
			MFMatrix &m1 = pAnims[map].pFrames[pAnimation->blendLayer.pCurFrames[a].tweenStart].key;
			MFMatrix &m2 = pAnims[map].pFrames[pAnimation->blendLayer.pCurFrames[a].tweenEnd].key;

			gWorkingMats[a].Tween(m1, m2, pAnimation->blendLayer.pCurFrames[a].tween);
		}
		else
		{
			gWorkingMats[a] = pBones[a].boneMatrix;
		}
	}

	// build the animation matrix for each bone...
	// TODO: this could be much faster
	for(uint32 a=0; a<pAnimation->numBones; a++)
	{
		MFMatrix boneMat = MFMatrix::identity;

		int b = (int)a;
		do
		{
			boneMat.Multiply(gWorkingMats[b]);
			b = pBones[b].parent;
		}
		while(b != -1);

//		pMats[a].Multiply(boneMat, pBones[a].invWorldMatrix);
		pMats[a].Multiply(pBones[a].invWorldMatrix, boneMat);

		if(pLocalToWorld)
			pMats[a].Multiply(*pLocalToWorld);
	}

	return pAnimation->pMatrices;
}
开发者ID:throbbingrobotheroes,项目名称:fuji,代码行数:86,代码来源:MFAnimation.cpp

示例14: MFView_Push

void Fretboard::Draw(float time, dBChart *pSong, int track)
{
	MFCALLSTACKc;

	MFView_Push();

	MFRect rect;
	MFView_GetViewport(&rect);

	float aspect = rect.width / rect.height;
	aspect = MFClamp(0.82f, aspect, 2.0f);
	MFView_SetAspectRatio(aspect);

	if(viewPoint == 0)
	{
		// incoming
		MFView_ConfigureProjection(MFDEGREES(65.0f)/aspect, 1.0f, 100.0f);

		// Setup the Camera in 3D space.
		MFMatrix cameraMatrix;
		MFVector start = MakeVector( 0, 8, 3 );
		MFVector dir = MakeVector( 0, 5, -8 );
		dir = (dir-start) * (1.0f/1.777777777f);
		cameraMatrix.LookAt(start + dir*aspect, MakeVector(0.0f, 0.0f, 5.0f));
		MFView_SetCameraMatrix(cameraMatrix);
	}
	else if(viewPoint == 1)
	{
		// overhead
		MFView_ConfigureProjection(MFDEGREES(45.0f), 1.0f, 100.0f);
/*
		float aspect = MFDisplay_GetNativeAspectRatio();
		MFView_SetAspectRatio(aspect);

		MFRect projRect;
		projRect.y = 15;
		projRect.height = -30;
		projRect.x = -projRect.y * aspect;
		projRect.width = -projRect.height * aspect;
		MFView_SetOrtho(&projRect);
*/

		// Setup the Camera in 3D space.
		MFMatrix cameraMatrix;
		cameraMatrix.LookAt(MakeVector(0, 30, 10), MakeVector(0, 0, 10), MakeVector(0, 0, 1));
		MFView_SetCameraMatrix(cameraMatrix);
	}
	else if(viewPoint == 2)
	{
		// overhead
		MFView_ConfigureProjection(MFDEGREES(45.0f), 1.0f, 100.0f);
/*
		float aspect = MFDisplay_GetNativeAspectRatio();
		MFView_SetAspectRatio(aspect);

		MFRect projRect;
		projRect.y = 15;
		projRect.height = -30;
		projRect.x = -projRect.y * aspect;
		projRect.width = -projRect.height * aspect;
		MFView_SetOrtho(&projRect);
*/

		// Setup the Camera in 3D space.
		MFMatrix cameraMatrix;
		cameraMatrix.LookAt(MakeVector(0, 20, 13), MakeVector(0, 0, 13), MakeVector(-1, 0, 0));
		MFView_SetCameraMatrix(cameraMatrix);
	}

	MFView_SetProjection();

	MFMaterial *pFB = pSong->pFretboard ? pSong->pFretboard : pFretboard;
	MFMaterial_SetMaterial(pFB);
	MFPrimitive(PT_TriStrip, 0);

	int start = -4;
	int end = 60;
	int fadeStart = end - 10;

	float fretboardRepeat = 15.0f;
	float fretboardWidth = 7.0f;

	float columnWidth = fretboardWidth / 5.0f;
	float ringBorder = 0.1f;

	// draw the fretboard...
	MFBegin(((end-start) / 4) * 2 + 2);
	MFSetColourV(MFVector::white);

	float halfFB = fretboardWidth*0.5f;

	float offset = time*scrollSpeed;
	float topTime = time + end/scrollSpeed;
	float bottomTime = time + start/scrollSpeed;

	int a;
	float textureOffset = fmodf(offset, fretboardRepeat);
	for(a=start; a<end; a+=4)
	{
		float z = (float)a;
//.........这里部分代码省略.........
开发者ID:KingDwag,项目名称:feedback-editor,代码行数:101,代码来源:Track.cpp


注:本文中的MFMatrix类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。