Example #1
0
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);
	}
}
Example #2
0
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);
}
Example #3
0
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);
}
Example #4
0
void Game_Update()
{
	if(!bShowModel)
	{
		if(MFInput_WasPressed(Key_Up, IDD_Keyboard) && menuIndex > 0)
			--menuIndex;
		else if(MFInput_WasPressed(Key_Down, IDD_Keyboard) && menuIndex < (int)models.size()-1)
			++menuIndex;
		else if(MFInput_WasPressed(Key_Return, IDD_Keyboard) && models.size() > 0)
		{
			bShowModel = true;

			// load model
			pModel = MFModel_CreateWithAnimation(models[menuIndex].CStr());
		}
	}
	else
	{
		if(MFInput_WasPressed(Key_Escape, IDD_Keyboard))
		{
			if(pModel)
			{
				MFModel_Destroy(pModel);
				pModel = NULL;
			}

			models.clear();
			Scan("data:");

			if(models.size() <= (size_t)menuIndex)
				menuIndex = models.size() ? (int)models.size() - 1 : 0;
			bShowModel = false;
			return;
		}

		if(pModel)
		{
			if(MFInput_Read(Mouse_LeftButton, IDD_Mouse) > 0.f)
			{
				yaw += -MFInput_Read(Mouse_XDelta, IDD_Mouse) * 0.02f;
				pitch += -MFInput_Read(Mouse_YDelta, IDD_Mouse) * 0.015f;
			}
			if(MFInput_Read(Mouse_MiddleButton, IDD_Mouse) > 0.f)
			{
				zoom *= 1.f + -MFInput_Read(Mouse_YDelta, IDD_Mouse) * 0.02f;
			}

			// calculate a spinning world matrix
			MFMatrix world;
			world.SetTranslation(MakeVector(0, -0.25f, 1) * zoom);
			world.RotateY(yaw);
			world.RotateX(pitch);

			// 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);
			}
		}
	}
}