make BrickColor materials use RTShaderLib
This commit is contained in:
parent
935b547a16
commit
7fb505164b
|
|
@ -39,6 +39,10 @@ class MainWindow : public QMainWindow
|
|||
void selectInstance(QTreeWidgetItem *item, int column);
|
||||
void run();
|
||||
void pause();
|
||||
|
||||
#ifndef NDEBUG
|
||||
void dbg_pointlight();
|
||||
#endif
|
||||
protected:
|
||||
void widgetItemPrepare(QTreeWidgetItem* item, RNR::Instance* instance);
|
||||
void recurseTreeAddInstance(QTreeWidgetItem* parent, RNR::Instance* instance);
|
||||
|
|
|
|||
|
|
@ -111,6 +111,11 @@ void MainWindow::createToolbar()
|
|||
|
||||
QAction* run_action = toolbar->addAction(QIcon("content/textures/studio/icons/run.png"), "", this, SLOT(run()));
|
||||
QAction* pause_action = toolbar->addAction(QIcon("content/textures/studio/icons/pause.png"), "", this, SLOT(pause()));
|
||||
|
||||
#ifndef NDEBUG
|
||||
toolbar->addSeparator();
|
||||
QAction* pointlight = toolbar->addAction(QIcon("content/textures/studio/icons/PointLight.png"), "Debug: Add PointLight to Instance", this, SLOT(dbg_pointlight()));
|
||||
#endif
|
||||
}
|
||||
|
||||
void MainWindow::run()
|
||||
|
|
@ -123,6 +128,13 @@ void MainWindow::pause()
|
|||
this->ogreWidget->world->getRunService()->pause();
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void MainWindow::dbg_pointlight()
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent* event)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ add_library(Engine STATIC
|
|||
Header/App/V8/DataModel/DataModel.hpp
|
||||
Header/App/V8/DataModel/ForceField.hpp
|
||||
Header/App/V8/DataModel/PartInstance.hpp
|
||||
Header/App/V8/DataModel/Light.hpp
|
||||
Header/App/V8/DataModel/FaceInstance.hpp
|
||||
Header/App/V8/DataModel/RunService.hpp
|
||||
Header/App/V8/DataModel/Workspace.hpp
|
||||
|
|
@ -41,6 +42,7 @@ add_library(Engine STATIC
|
|||
Source/App/V8/DataModel/DataModel.cpp
|
||||
Source/App/V8/DataModel/ForceField.cpp
|
||||
Source/App/V8/DataModel/PartInstance.cpp
|
||||
Source/App/V8/DataModel/Light.cpp
|
||||
Source/App/V8/DataModel/FaceInstance.cpp
|
||||
Source/App/V8/DataModel/RunService.cpp
|
||||
Source/App/V8/DataModel/Workspace.cpp
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
#include <App/V8/Tree/Instance.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
class Light : public Instance
|
||||
{
|
||||
private:
|
||||
float m_brightness;
|
||||
Ogre::Vector3 m_color;
|
||||
bool m_enabled;
|
||||
bool m_shadows;
|
||||
public:
|
||||
Light();
|
||||
};
|
||||
}
|
||||
|
|
@ -83,6 +83,8 @@ namespace RNR
|
|||
{ 1032, std::string("Hot pink"), Ogre::Vector3(255.0/255.0, 0/255.0, 191.0/255.0) }
|
||||
};
|
||||
|
||||
static bool bc_prep = false;
|
||||
|
||||
BrickColor::BrickColor(int color_id, std::string color_name, Ogre::Vector3 color)
|
||||
{
|
||||
this->color_id = color_id;
|
||||
|
|
@ -92,13 +94,22 @@ namespace RNR
|
|||
|
||||
void BrickColor::buildMaterial()
|
||||
{
|
||||
color_material = Ogre::MaterialManager::getSingletonPtr()->getByName("materials/partinstanced");
|
||||
color_material = color_material->clone(Ogre::String("tmp_part/") + Ogre::StringConverter::toString(color_id));
|
||||
if(!bc_prep)
|
||||
{
|
||||
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->createScheme("rtshader");
|
||||
|
||||
bc_prep = true;
|
||||
}
|
||||
Ogre::MaterialPtr part_material = Ogre::MaterialManager::getSingletonPtr()->getByName("materials/partinstanced");
|
||||
color_material = part_material->clone(Ogre::String("tmp_part/") + Ogre::StringConverter::toString(color_id));
|
||||
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->cloneShaderBasedTechniques(*part_material, *color_material);
|
||||
Ogre::Technique* mat_tech = color_material->getTechnique(0);
|
||||
mat_tech->setLightingEnabled(true);
|
||||
mat_tech->setShadingMode(Ogre::ShadeOptions::SO_PHONG);
|
||||
Ogre::Pass* mat_pass = mat_tech->getPass(0);
|
||||
Ogre::TextureUnitState* part_texunit = mat_pass->getTextureUnitState(0);
|
||||
part_texunit->setColourOperationEx(Ogre::LayerBlendOperationEx::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, Ogre::ColourValue(color_val.x, color_val.y, color_val.z));
|
||||
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->validateScheme(mat_tech->getSchemeName());
|
||||
|
||||
}
|
||||
|
||||
Ogre::Vector3 BrickColor::color(int brickcolor)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
#include <App/V8/DataModel/Light.hpp>
|
||||
|
||||
namespace RNR
|
||||
{
|
||||
Light::Light()
|
||||
{
|
||||
m_brightness = 1.f;
|
||||
m_enabled = true;
|
||||
m_shadows = true;
|
||||
m_color = Ogre::Vector3(1.f,1.f,1.f);
|
||||
}
|
||||
}
|
||||
|
|
@ -36,7 +36,11 @@ namespace RNR
|
|||
Ogre::Vector3 part_size = child_part->getSize();
|
||||
for(int i = 0; i < m_partEntity->getNumSubEntities(); i++)
|
||||
{
|
||||
m_partEntity->setMaterial(BrickColor::material(child_part->getBrickColor()));
|
||||
/*
|
||||
Ogre::SubMesh* surface = m_partEntity->getMesh()->getSubMesh(i);
|
||||
surface->setMaterial();
|
||||
|
||||
Ogre::TextureUnitState* texture = surface->getMaterial()->getTechnique(0)->getPass(0)->getTextureUnitState(0);
|
||||
|
||||
Ogre::Vector2 uvs;
|
||||
|
|
@ -52,7 +56,7 @@ namespace RNR
|
|||
else if(surf_name == "BackMaterial")
|
||||
uvs = Ogre::Vector2(part_size.x, part_size.z);
|
||||
else if(surf_name == "FrontMaterial")
|
||||
uvs = Ogre::Vector2(-part_size.x, part_size.z);
|
||||
uvs = Ogre::Vector2(-part_size.x, part_size.z);*/
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue