Skip to content

Commit

Permalink
#5585: Expose more stage methods
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Apr 11, 2021
1 parent 59f4ba1 commit ec3548e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
7 changes: 6 additions & 1 deletion install/scripts/materialtest.py
Expand Up @@ -72,7 +72,12 @@
print('Material has now {0} stages'.format(newMaterial.getNumStages()))

for stage in newMaterial.getAllStages():
print('Stage of type {0} iterated'.format(stage.getType()))
print('Stage type: {0}'.format(stage.getType()))
print('Stage flags: {0}'.format(stage.getStageFlags()))
print('Stage clamp type: {0}'.format(stage.getClampType()))
print('Stage texgen type: {0}'.format(stage.getTexGenType()))
print('Stage texgen param #1: {0}'.format(stage.getTexGenParam(0)))
print('Stage texgen expression #1: {0}'.format(stage.getTexGenExpressionString(0)))

newMaterial.removeStage(stageIndex)

Expand Down
13 changes: 13 additions & 0 deletions plugins/script/interfaces/ShaderSystemInterface.cpp
Expand Up @@ -305,10 +305,23 @@ void ShaderSystemInterface::registerInterface(py::module& scope, py::dict& globa
.value("IGNORE_DEPTH", IShaderLayer::FLAG_IGNORE_DEPTH)
.export_values();

// Texgen enum
py::enum_<IShaderLayer::TexGenType>(stage, "TexGenType")
.value("NORMAL", IShaderLayer::TEXGEN_NORMAL)
.value("REFLECT", IShaderLayer::TEXGEN_REFLECT)
.value("SCREEN", IShaderLayer::TEXGEN_SCREEN)
.value("SKYBOX", IShaderLayer::TEXGEN_SKYBOX)
.value("WOBBLESKY", IShaderLayer::TEXGEN_WOBBLESKY)
.export_values();

// Shader Stage
stage.def(py::init<const IShaderLayer::Ptr&>());
stage.def("getType", &ScriptMaterialStage::getType);
stage.def("getStageFlags", &ScriptMaterialStage::getStageFlags);
stage.def("getClampType", &ScriptMaterialStage::getClampType);
stage.def("getTexGenType", &ScriptMaterialStage::getTexGenType);
stage.def("getTexGenParam", &ScriptMaterialStage::getTexGenParam);
stage.def("getTexGenExpressionString", &ScriptMaterialStage::getTexGenExpressionString);

// Expose the MaterialVisitor interface

Expand Down
21 changes: 21 additions & 0 deletions plugins/script/interfaces/ShaderSystemInterface.h
Expand Up @@ -28,6 +28,27 @@ class ScriptMaterialStage
{
return _layer ? _layer->getStageFlags() : 0;
}

ClampType getClampType()
{
return _layer ? _layer->getClampType() : CLAMP_REPEAT;
}

IShaderLayer::TexGenType getTexGenType()
{
return _layer ? _layer->getTexGenType() : IShaderLayer::TEXGEN_NORMAL;
}

float getTexGenParam(std::size_t index)
{
return _layer && index < 2 ? _layer->getTexGenParam(index) : 0;
}

std::string getTexGenExpressionString(std::size_t index)
{
return _layer && index < 2 && _layer->getTexGenExpression(index) ?
_layer->getTexGenExpression(index)->getExpressionString() : std::string();
}
};

/**
Expand Down

0 comments on commit ec3548e

Please sign in to comment.