bool HKWidgetRenderer::SetProperty(const char *pProperty, const char *pValue, HKWidget *pWidget)
{
	if(!MFString_CaseCmp(pProperty, "background_image"))
	{
		if(pImage)
			MFMaterial_Destroy(pImage);
		pImage = MFMaterial_Create(pValue);
		if(pImage)
		{
			int texW, texH;
			MFTexture *pTex = MFMaterial_GetParameterT(pImage, MFMatStandard_Texture, MFMatStandard_Tex_DifuseMap);
			MFTexture_GetTextureDimensions(pTex, &texW, &texH);

			texWidth = (float)texW;
			texHeight = (float)texH;

			if(pWidget && (pWidget->bAutoWidth || pWidget->bAutoHeight))
			{
				if(pWidget->bAutoWidth && pWidget->bAutoHeight)
					pWidget->Resize(MakeVector(texWidth, texHeight));
				else if(pWidget->bAutoWidth)
					pWidget->UpdateWidth(texWidth);
				else
					pWidget->UpdateHeight(texHeight);
			}
		}
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_align"))
	{
		imageAlignment = (HKWidget::Justification)HKWidget_GetEnumValue(pValue, HKWidget::sJustifyKeys);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_colour"))
	{
		colour = HKWidget_GetColourFromString(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_padding"))
	{
		padding = HKWidget_GetVectorFromString(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "background_9-cell-margin"))
	{
		margin9Cell = MFString_AsciiToFloat(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "border_width"))
	{
		border = HKWidget_GetVectorFromString(pValue);
		return true;
	}
	else if(!MFString_CaseCmp(pProperty, "border_colour"))
	{
		borderColour = HKWidget_GetColourFromString(pValue);
		return true;
	}
	return false;
}
Exemple #2
0
void MFModel_CreateMeshChunk(MFMeshChunk *pMeshChunk)
{
	MFCALLSTACK;

	MFMeshChunk_Generic *pMC = (MFMeshChunk_Generic*)pMeshChunk;

	pMC->pMaterial = MFMaterial_Create((char*)pMC->pMaterial);

	HRESULT hr;

	MFDebug_Assert(sizeof(MeshChunkD3DRuntimeData) <= sizeof(pMC->runtimeData), "MeshChunkD3DRuntimeData is larger than runtimeData!");
	MeshChunkD3DRuntimeData &runtimeData = (MeshChunkD3DRuntimeData&)pMC->runtimeData;

	// create D3D interfaces
	hr = MFModelD3D9_CreateVertexDeclaration(pMC->pVertexFormat, &runtimeData.vertexDecl);
	MFDebug_Assert(SUCCEEDED(hr), "Failed to create vertex declaration..");

	hr = pd3dDevice->CreateVertexBuffer(pMC->pVertexFormat->pStreams[0].streamStride*pMC->numVertices, 0, 0, D3DPOOL_MANAGED, &runtimeData.vertexBuffer, NULL);
	MFDebug_Assert(SUCCEEDED(hr), "Failed to create vertex buffer..");
	if(pMC->pVertexFormat->numVertexStreams > 1)
	{
		hr = pd3dDevice->CreateVertexBuffer(pMC->pVertexFormat->pStreams[1].streamStride*pMC->numVertices, 0, 0, D3DPOOL_MANAGED, &runtimeData.animBuffer, NULL);
		MFDebug_Assert(SUCCEEDED(hr), "Failed to create animation buffer..");
	}
	hr = pd3dDevice->CreateIndexBuffer(sizeof(uint16)*pMC->numIndices, 0, D3DFMT_INDEX16, D3DPOOL_MANAGED, &runtimeData.indexBuffer, NULL);
	MFDebug_Assert(SUCCEEDED(hr), "Failed to create index buffer..");

	void *pData;

	// fill vertex buffer
	hr = runtimeData.vertexBuffer->Lock(0, 0, &pData, 0);
	MFDebug_Assert(SUCCEEDED(hr), "Failed to lock vertex buffer..");

	MFCopyMemory(pData, pMC->ppVertexStreams[0], pMC->pVertexFormat->pStreams[0].streamStride*pMC->numVertices);

	runtimeData.vertexBuffer->Unlock();

	// fill animation buffer
	if(pMC->pVertexFormat->numVertexStreams > 1)
	{
		hr = runtimeData.animBuffer->Lock(0, 0, &pData, 0);
		MFDebug_Assert(SUCCEEDED(hr), "Failed to lock animation buffer..");

		MFCopyMemory(pData, pMC->ppVertexStreams[1], pMC->pVertexFormat->pStreams[1].streamStride*pMC->numVertices);

		runtimeData.animBuffer->Unlock();
	}

	// fill index buffer
	hr = runtimeData.indexBuffer->Lock(0, 0, &pData, 0);
	MFDebug_Assert(SUCCEEDED(hr), "Failed to lock index buffer..");

	MFCopyMemory(pData, pMC->pIndexData, sizeof(uint16)*pMC->numIndices);

	runtimeData.indexBuffer->Unlock();
}
MF_API MFParticleSystem* MFParticleSystem_Create(MFParticleParameters *pParticleParams)
{
	MFParticleSystem *pSystem = (MFParticleSystem*)MFHeap_Alloc(sizeof(MFParticleSystem));

	pSystem->params = *pParticleParams;

	if(!pParticleParams->pMaterial)
		pSystem->pMaterial = MFMaterial_Create("_None");
	else
	{
		pSystem->pMaterial = MFMaterial_Create(pParticleParams->pMaterial);

//		int additive = MFMaterial_GetParameterIndexFromName(pSystem->pMaterial, "additive");
		MFMaterial_SetParameterI(pSystem->pMaterial, MFMatStandard_ZWrite, 0, 0);
	}

	pSystem->particles.Init("ParticleSystem", pSystem->params.maxActiveParticles);

	return pSystem;
}
Exemple #4
0
void dBFrame::SetMaterial(const char *pMaterial)
{
	if(pMaterial)
	{
		pMat = MFMaterial_Create(pMaterial);
		MFVector colour = MakeVector(0.2f, 0.5f, 1, 1);
		SetCornerColours(colour, colour, colour, colour);
//		int zread = MFMaterial_GetParameterIndexFromName(pMat, "zread");
//		size_t off = 0;
//		MFMaterial_SetParameter(pMat, zread, 0, &off);
	}
	else if(pMat)
	{
		MFMaterial_Release(pMat);
		pMat = NULL;
	}
}
Exemple #5
0
void Fretboard::LoadFretboard(const char *pImage)
{
	if(pFretboard)
		MFMaterial_Release(pFretboard);

	pFretboard = MFMaterial_Create(MFStr("Fretboards/%s", pImage));

	if(pFretboard)
	{
		int zRead = MFMaterial_GetParameterIndexFromName(pFretboard, "zread");
		int zWrite = MFMaterial_GetParameterIndexFromName(pFretboard, "zwrite");
		int off = 0;

		MFMaterial_SetParameterI(pFretboard, zRead, 0, 0);
		MFMaterial_SetParameterI(pFretboard, zWrite, 0, 0);
	}
}
Exemple #6
0
void Game_Init()
{
	// create the renderer with a single layer that clears before rendering
	MFRenderLayerDescription layers[] = { { "Prism" }, { "Box" } };
	pRenderer = MFRenderer_Create(layers, 2, NULL, NULL);
	MFRenderer_SetCurrent(pRenderer);

	pDefaultStates = MFStateBlock_CreateDefault();
	MFRenderer_SetGlobalStateBlock(pRenderer, pDefaultStates);

	// configure prism layer
	MFRenderLayer *pLayer = MFRenderer_GetLayer(pRenderer, 0);
	MFRenderLayer_SetClear(pLayer, MFRCF_All, MakeVector(0.f, 0.f, 0.0f, 1.f));

	// create a render target for the layer
	MFRenderTarget *pRenderTarget = MFRenderTarget_CreateSimple("Prism", 256, 256);
	pPrismRenderTarget = MFMaterial_Create("Prism_RenderTarget0");
	MFRenderLayer_SetLayerRenderTarget(pLayer, pRenderTarget);
	MFRenderTarget_Release(pRenderTarget); // the render layer now has a reference, it will be destroyed with the renderer

	// configure box layer
	pLayer = MFRenderer_GetLayer(pRenderer, 1);
	MFRenderLayer_SetClear(pLayer, MFRCF_All, MakeVector(0.f, 0.f, 0.2f, 1.f));

	// configure the box layer as the default render layer
	MFRenderLayerSet layerSet;
	MFZeroMemory(&layerSet, sizeof(layerSet));
	layerSet.pSolidLayer = pLayer;
	MFRenderer_SetRenderLayerSet(pRenderer, &layerSet);

	// build a vertex buffer
	BuildVertexBuffers();

	// create some state blocks
	pPrismStateBlock = MFStateBlock_Create(128);
	pBoxStateBlock = MFStateBlock_Create(128);
}
Exemple #7
0
void EditorScreen::Select()
{
	gpHelp = new HelpScreen;
	gpMsgBox = new MessageBoxScreen;
	gpStringBox = new StringBoxScreen;
	gpListBox = new ListBoxScreen;
	gpComboBox = new ComboBoxScreen;
	gpFileSelector = new FileSelectorScreen;

//	pScene = dBScene::Create("s_testscene");

	gEditor.pMetronome = MFMaterial_Create("metronome");

	// load sounds
	gEditor.pStepSound = MFSound_Create("Sounds/row");
	gEditor.pChangeSound = MFSound_Create("Sounds/prompt");
	gEditor.pSaveSound = MFSound_Create("Sounds/save");
	gEditor.pClapSound = MFSound_Create("Sounds/claps");
	gEditor.pHighTickSound = MFSound_Create("Sounds/hightick");
	gEditor.pLowTickSound = MFSound_Create("Sounds/lowtick");

	if(gConfig.editor.lastOpenedChart[0])
	{
		gEditor.pSong = dBChart::LoadChart(gConfig.editor.lastOpenedChart);
		gEditor.offset = 0;
		gEditor.currentBPM = gEditor.pSong->GetStartBPM();
	}
	else
		gEditor.pSong = dBChart::Create();

	gGame.pTrack = new Fretboard;
	gGame.pTrack2 = new Fretboard;

	if(gConfig.editor.editorFretboard[0])
	{
		gGame.pTrack->LoadFretboard(gConfig.editor.editorFretboard);
		gGame.pTrack2->LoadFretboard(gConfig.editor.editorFretboard);
	}
	else
	{
		int image = MFRand()%10;
		MFFindData fd;
		MFFind *pFind = MFFileSystem_FindFirst("theme:Fretboards/*", &fd);
		if(pFind)
		{
			bool more = true;
			while(fd.pFilename[0] == '.' && more)
				more = MFFileSystem_FindNext(pFind, &fd);
			if(!more)
			{
				MFFileSystem_FindClose(pFind);
				pFind = NULL;
			}
		}
		if(pFind)
		{
			while(image--)
			{
				if(!MFFileSystem_FindNext(pFind, &fd))
				{
					MFFileSystem_FindClose(pFind);
					pFind = MFFileSystem_FindFirst("theme:Fretboards/*", &fd);
					while(fd.pFilename[0] == '.')
						MFFileSystem_FindNext(pFind, &fd);
				}
			}

			const char *pFilename = MFStr_GetFileNameWithoutExtension(fd.pFilename);
			gGame.pTrack->LoadFretboard(pFilename);
			gGame.pTrack2->LoadFretboard(pFilename);
		}
	}

	eventSuggestions.LoadEventSuggestions("game:events.txt");

	gGame.Push();
	gEdit.Push();
	gpHelp->Push();
}
Exemple #8
0
MFInitStatus MFMaterial_InitModule()
{
	MFCALLSTACK;

	gMaterialRegistry.Init("Material Registry", gDefaults.material.maxMaterialTypes);
	gMaterialDefList.Init("Material Definitions List", gDefaults.material.maxMaterialDefs);
	gMaterialList.Init("Material List", gDefaults.material.maxMaterials);

	DebugMenu_AddItem("Material Browser", "Fuji Options", &matBrowser);

	MFMat_Standard_Register();
	MFMat_Effect_Register();

	if(MFFileSystem_Exists("Materials.ini") && MFMaterial_AddDefinitionsFile("Materials", "Materials"))
	{
		MFDebug_Warn(3, "Failed to load Materials.ini");
	}
	
#if MF_RENDERER == MF_DRIVER_D3D11 || defined(MF_RENDERPLUGIN_D3D11)
	// HACK?
	MFTexture *pSysLogoLargeTexture = MFTexture_Create("_None");
	MFTexture *pSysLogoSmallTexture = MFTexture_Create("_None");
#else
	// create the logo textures from raw data
	MFTexture *pSysLogoLargeTexture = MFTexture_CreateFromRawData("SysLogoLarge", SysLogo256_data, SysLogo256_width, SysLogo256_height, (MFImageFormat)SysLogo256_format, SysLogo256_flags);
	MFTexture *pSysLogoSmallTexture = MFTexture_CreateFromRawData("SysLogoSmall", SysLogo64_data, SysLogo64_width, SysLogo64_height, (MFImageFormat)SysLogo64_format, SysLogo64_flags);
#endif

	// create standard materials
	pNoneMaterial = MFMaterial_Create("_None");
	pWhiteMaterial = MFMaterial_Create("_White");
	pSysLogoLarge = MFMaterial_Create("SysLogoLarge");
	pSysLogoSmall = MFMaterial_Create("SysLogoSmall");

	// disable backface cullign on the default materials
	MFMaterial_SetParameterI(pNoneMaterial, MFMatStandard_CullMode, 0, MFMatStandard_Cull_None);
	MFMaterial_SetParameterI(pWhiteMaterial, MFMatStandard_CullMode, 0, MFMatStandard_Cull_None);

	// release a reference to the logo textures
	MFTexture_Destroy(pSysLogoLargeTexture);
	MFTexture_Destroy(pSysLogoSmallTexture);

#if defined(_PSP)
	// create PSP specific stock materials
	MFTexture *pConnectedTexture = MFTexture_CreateFromRawData("connected", connected_data, connected_width, connected_height, (MFImageFormat)connected_format, connected_flags);
	MFTexture *pDisconnectedTexture = MFTexture_CreateFromRawData("disconnected", disconnected_data, disconnected_width, disconnected_height, (MFImageFormat)disconnected_format, disconnected_flags);
	MFTexture *pPowerTexture = MFTexture_CreateFromRawData("power", power_data, power_width, power_height, (MFImageFormat)power_format, power_flags);
	MFTexture *pChargingTexture = MFTexture_CreateFromRawData("charging", charging_data, charging_width, charging_height, (MFImageFormat)charging_format, charging_flags);
	MFTexture *pUSBTexture = MFTexture_CreateFromRawData("usb_icon", usb_icon_data, usb_icon_width, usb_icon_height, (MFImageFormat)usb_icon_format, usb_icon_flags);

	pConnected = MFMaterial_Create("connected");
	pDisconnected = MFMaterial_Create("disconnected");
	pPower = MFMaterial_Create("power");
	pCharging = MFMaterial_Create("charging");
	pUSB = MFMaterial_Create("usb_icon");

	MFTexture_Destroy(pConnectedTexture);
	MFTexture_Destroy(pDisconnectedTexture);
	MFTexture_Destroy(pPowerTexture);
	MFTexture_Destroy(pChargingTexture);
	MFTexture_Destroy(pUSBTexture);
#endif

	return MFAIC_Succeeded;
}
Exemple #9
0
Fretboard::Fretboard()
{
	pFretboard = NULL;

	// create materials
	MFTexture *pFretTex = MFTexture_Find("frets");
	if(!pFretTex)
		pFretTex = MFTexture_CreateBlank("frets", MFVector::one);
	pFrets = MFMaterial_Create("frets");
	MFTexture_Release(pFretTex);

	int zRead = MFMaterial_GetParameterIndexFromName(pFrets, "zread");
	int zWrite = MFMaterial_GetParameterIndexFromName(pFrets, "zwrite");
	int additive = MFMaterial_GetParameterIndexFromName(pFrets, "additive");

	pEdge = MFMaterial_Create("edge");
	pBar = MFMaterial_Create("bar");

	pRing = MFMaterial_Create("ring");

	pColourRing[0] = MFMaterial_Create("green");
	pColourRing[1] = MFMaterial_Create("red");
	pColourRing[2] = MFMaterial_Create("yellow");
	pColourRing[3] = MFMaterial_Create("blue");
	pColourRing[4] = MFMaterial_Create("orange");

	pButtonMat[0] = MFMaterial_Create("button-green");
	pButtonMat[1] = MFMaterial_Create("button-red");
	pButtonMat[2] = MFMaterial_Create("button-yellow");
	pButtonMat[3] = MFMaterial_Create("button-blue");
	pButtonMat[4] = MFMaterial_Create("button-orange");
	pButtonRing[0] = MFMaterial_Create("button-green-ring");
	pButtonRing[1] = MFMaterial_Create("button-red-ring");
	pButtonRing[2] = MFMaterial_Create("button-yellow-ring");
	pButtonRing[3] = MFMaterial_Create("button-blue-ring");
	pButtonRing[4] = MFMaterial_Create("button-orange-ring");

	MFParticleParameters params;
	params.colour = MakeVector(1, 0, 1, 1);
	params.force.Set(0.f, 0.f, 0.f);
	params.life = .3f;
	params.size = .15f;
	params.fadeDelay = 0.2f;
	params.rotationRate = 2.f;
	params.scaleRate = -.1f;
	params.maxActiveParticles = 1000;
	params.pMaterial = "Notes/sparkles";
	pParticles = MFParticleSystem_Create(&params);

	MFParticleEmitterParameters emitter;
	emitter.position.SetTranslation(MakeVector(0, 0, 0));
	emitter.startVector.Set(0, 1.f, 0);
	emitter.pParticleSystem = pParticles;
	emitter.type = MFET_Disc;
	emitter.behaviour = MFEB_Direction;
	emitter.radius = 0.25f;
	emitter.velocity = 3.f;
	emitter.velocityScatter = 1.f;
	emitter.directionScatter = .3f;
	emitter.emitRate = 100.f;
	pEmitter = MFParticleSystem_CreateEmitter(&emitter);

	MFMaterial_SetParameterI(pFrets, zRead, 0, 0);
	MFMaterial_SetParameterI(pFrets, zWrite, 0, 0);
	MFMaterial_SetParameterI(pEdge, zRead, 0, 0);
	MFMaterial_SetParameterI(pEdge, zWrite, 0, 0);
	MFMaterial_SetParameterI(pBar, zRead, 0, 0);
	MFMaterial_SetParameterI(pBar, zWrite, 0, 0);
	MFMaterial_SetParameterI(pRing, zWrite, 0, 0);
	for(int a=0; a<5; ++a)
		MFMaterial_SetParameterI(pColourRing[a], additive, 0, 1);

	// load models
	pButton = MFModel_Create("Notes/button");
}