MF_API const MFStateBlock* MFView_GetViewState() { if(!pCurrentView->pStateBlock) { pCurrentView->pStateBlock = MFStateBlock_CreateTemporary(256); MFStateBlock_SetMatrix(pCurrentView->pStateBlock, MFSCM_Projection, MFView_GetViewToScreenMatrix()); MFStateBlock_SetMatrix(pCurrentView->pStateBlock, MFSCM_Camera, pCurrentView->isOrtho ? MFMatrix::identity : pCurrentView->cameraMatrix); } return pCurrentView->pStateBlock; }
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); }
//--------------------------------------------------------------------------------------------------------------------- MFInitStatus MFPrimitive_InitModule(int moduleId, bool bPerformInitialisation) { MFVertexElement elements[4]; // write declaration elements[0].stream = 0; elements[0].type = MFVET_Position; elements[0].index = 0; elements[0].componentCount = 3; elements[0].format = MFVDF_Float3; elements[1].stream = 0; elements[1].type = MFVET_Normal; elements[1].index = 0; elements[1].componentCount = 3; elements[1].format = MFVDF_Float3; elements[2].stream = 0; elements[2].type = MFVET_Colour; elements[2].index = 0; elements[2].componentCount = 4; elements[2].format = MFVDF_UByte4N_BGRA; elements[3].stream = 0; elements[3].type = MFVET_TexCoord; elements[3].index = 0; elements[3].componentCount = 2; elements[3].format = MFVDF_Float2; pDecl = MFVertex_CreateVertexDeclaration(elements, 4); MFDebug_Assert(pDecl, "Failed to create vertex declaration.."); pIdentity = MFStateBlock_Create(128); MFStateBlock_SetMatrix(pIdentity, MFSCM_World, MFMatrix::identity); return MFIS_Succeeded; }
//--------------------------------------------------------------------------------------------------------------------- MF_API void MFSetMatrix(const MFMatrix &mat) { if(pEntity == pIdentity) pEntity = MFStateBlock_CreateTemporary(128); MFStateBlock_SetMatrix(pEntity, MFSCM_World, mat); }