Exemplo n.º 1
0
//-------------------------------------------------------------------------------
void MaterialViewer::onClickApply(MyGUI::WidgetPtr)
{
    //Update properties.
    MyGUI::EnumeratorWidgetPtr iter = mWindow->getEnumerator();
    while (iter.next())
    {
        MyGUI::Widget *widget = iter.current();
        if (widget->getUserString("type") == "MaterialProperty") 
            mMaterialSettings[widget->getUserString("property")] = dynamic_cast<MyGUI::Edit*>(widget)->getOnlyText();
    }
    MyGUI::ComboBoxPtr list = GlbVar.gui->findWidget<MyGUI::ComboBox>("cmb_materialType");
    mMaterialType = list->getItemNameAt(list->getIndexSelected());
    
    //Compile.
    compileMaterial();
}
Exemplo n.º 2
0
void FMaterial::sendMaterialInformationToGPU(const Matrix4& staticMesh_ModelMatrix)
{
	_shaderMaterialPtr->bind();
	sendPerFrameUniforms(staticMesh_ModelMatrix);

	if (!_compiled)
	{
		compileMaterial();
	}
	else
	{
		//If already compiled only bind the textures again (dont resend the samplers to the shader)
		int i = 0; //Set a valid active texture slot
		for (auto const &it : _texturesInMaterialMap)
		{
			it.second->bindTexture(i);
			i++;
		}
	}
}
Exemplo n.º 3
0
//-------------------------------------------------------------------------------
void MaterialViewer::init()
{
    //Create the mesh.
    mNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode("materialcube-node");
    mEntity = GlbVar.ogreSmgr->createEntity("materialcube-entity", "Mesh_Cube.mesh");
    mNode->attachObject(mEntity);

    //Camera.
    mCameraYawNode = GlbVar.ogreSmgr->getRootSceneNode()->createChildSceneNode("materialviewercamera-yawnode");
    mCameraPitchNode = mCameraYawNode->createChildSceneNode("materialviewercamera-pitchnode");
    mCameraDist = 3;

    //Some test settings.
    mMaterialType = "BaseNormalMapParallax";
    mMaterialSettings["diffuse_tex"] = "WhiteTile1.png";
    mMaterialSettings["normal_tex"] = "WhiteTile_NM.png";
    mMaterialSettings["glow_tex"] = "WhiteLight_GW.png";

    mMaterialSettings["ambient"] = "0.7 0.7 0.7 1";
    mMaterialSettings["diffuse"] = "0.9 0.9 0.9 1";
    mMaterialSettings["specular"] = "0.8 0.8 0.8 1";
    mMaterialSettings["scaleBias"] = "0.04 0.02";
    mMaterialSettings["glow_amount"] = "0.5";

    //First compile.
    compileMaterial();

    //Load the layout.
    MyGUI::LayoutManager::getInstance().loadLayout("MaterialViewer.layout");
    mWindow = GlbVar.gui->findWidget<MyGUI::Window>("win_materialViewer");

    //Callbacks.
    MyGUI::ButtonPtr button = GlbVar.gui->findWidget<MyGUI::Button>("but_applyMaterial");
    button->eventMouseButtonClick += MyGUI::newDelegate(this, &MaterialViewer::onClickApply);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_saveMaterial");
    button->eventMouseButtonClick += MyGUI::newDelegate(this, &MaterialViewer::onClickSave);

    button = GlbVar.gui->findWidget<MyGUI::Button>("but_createLight");
    button->eventMouseButtonClick += MyGUI::newDelegate(this, &MaterialViewer::onClickCreateLight);

    //Update the editboxes.
    MyGUI::EnumeratorWidgetPtr iter = mWindow->getEnumerator();
    while (iter.next())
    {
        MyGUI::Widget *widget = iter.current();
        if (widget->getUserString("type") == "MaterialProperty") 
            dynamic_cast<MyGUI::Edit*>(widget)->setOnlyText(mMaterialSettings[widget->getUserString("property")]);
    }
    GlbVar.gui->findWidget<MyGUI::Edit>("edt_lightColour")->setOnlyText("0.7 0.7 0.7");

    //Populate the material type list.
    MyGUI::ComboBoxPtr list = GlbVar.gui->findWidget<MyGUI::ComboBox>("cmb_materialType");
    list->insertItemAt(0, "Base");
    list->insertItemAt(1, "BaseNormalMap");
    list->insertItemAt(2, "BaseNormalMapParallax");
    list->insertItemAt(3, "BaseGlow");
    list->insertItemAt(4, "BaseNormalMapGlow");
    list->insertItemAt(5, "BaseNormalMapParallaxGlow");
    list->insertItemAt(6, "BaseTransparent");
    list->setIndexSelected(2);
}