本文整理汇总了C++中ogre::GpuProgramParametersSharedPtr::getConstantDefinitionIterator方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr::getConstantDefinitionIterator方法的具体用法?C++ GpuProgramParametersSharedPtr::getConstantDefinitionIterator怎么用?C++ GpuProgramParametersSharedPtr::getConstantDefinitionIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::GpuProgramParametersSharedPtr
的用法示例。
在下文中一共展示了GpuProgramParametersSharedPtr::getConstantDefinitionIterator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateProperties
bool OgreMaterialProperties::CreateProperties()
{
Ogre::MaterialPtr matPtr = material_->GetMaterial();
if (matPtr.isNull())
return false;
// Material
Ogre::Material::TechniqueIterator tIter = matPtr->getTechniqueIterator();
while(tIter.hasMoreElements())
{
// Technique
Ogre::Technique *tech = tIter.getNext();
Ogre::Technique::PassIterator pIter = tech->getPassIterator();
while(pIter.hasMoreElements())
{
// Pass
Ogre::Pass *pass = pIter.getNext();
if (!pass)
continue;
if(pass->hasVertexProgram())
{
// Vertex program
const Ogre::GpuProgramPtr &verProg = pass->getVertexProgram();
if (!verProg.isNull())
{
Ogre::GpuProgramParametersSharedPtr verPtr = pass->getVertexProgramParameters();
if (verPtr->hasNamedParameters())
{
// Named parameters (constants)
Ogre::GpuConstantDefinitionIterator mapIter = verPtr->getConstantDefinitionIterator();
while(mapIter.hasMoreElements())
{
QString paramName = mapIter.peekNextKey().c_str();
const Ogre::GpuConstantDefinition ¶mDef = mapIter.getNext();
// Filter names that end with '[0]'
int found = paramName.indexOf("[0]");
if (found != -1)
continue;
// Ignore auto parameters
bool is_auto_param = false;
Ogre::GpuProgramParameters::AutoConstantIterator autoConstIter = verPtr->getAutoConstantIterator();
while(autoConstIter.hasMoreElements())
{
Ogre::GpuProgramParameters::AutoConstantEntry autoConstEnt = autoConstIter.getNext();
if (autoConstEnt.physicalIndex == paramDef.physicalIndex)
{
is_auto_param = true;
break;
}
}
if (is_auto_param)
continue;
if (!paramDef.isFloat())
continue;
size_t count = paramDef.elementSize * paramDef.arraySize;
QVector<float> paramValue;
QVector<float>::iterator iter;
paramValue.resize(count);
verPtr->_readRawConstants(paramDef.physicalIndex, count, &*paramValue.begin());
QTextStream vector_string;
QString string;
vector_string.setString(&string, QIODevice::WriteOnly);
for(iter = paramValue.begin(); iter != paramValue.end(); ++iter)
vector_string << *iter << " ";
// Add QPROPERTY. Add to "VP" to the end of the parameter name in order to identify VP parameters.
QMap<QString, QVariant> typeValuePair;
typeValuePair[GpuConstantTypeToString(paramDef.constType)] = *vector_string.string();
setProperty(paramName.append(" VP").toLatin1(), QVariant(typeValuePair));
}
}
}
}
if(pass->hasFragmentProgram())
{
// Fragment program
const Ogre::GpuProgramPtr fragProg = pass->getFragmentProgram();
if (!fragProg.isNull())
{
Ogre::GpuProgramParametersSharedPtr fragPtr = pass->getFragmentProgramParameters();
if (!fragPtr.isNull())
{
if (fragPtr->hasNamedParameters())
{
// Named parameters (constants)
Ogre::GpuConstantDefinitionIterator mapIter = fragPtr->getConstantDefinitionIterator();
while(mapIter.hasMoreElements())
{
QString paramName = mapIter.peekNextKey().c_str();
const Ogre::GpuConstantDefinition ¶mDef = mapIter.getNext();
//.........这里部分代码省略.........
示例2: ToOgreMaterial
Ogre::MaterialPtr OgreMaterialProperties::ToOgreMaterial()
{
// Make clone from the original and uset that for creating the new material.
Ogre::MaterialPtr matPtr = material_->GetMaterial();
Ogre::MaterialPtr matPtrClone = matPtr->clone(objectName().toStdString() + "Clone");
// Material
if (!matPtrClone.isNull())
{
// Technique
Ogre::Material::TechniqueIterator tIter = matPtrClone->getTechniqueIterator();
while(tIter.hasMoreElements())
{
Ogre::Technique *tech = tIter.getNext();
Ogre::Technique::PassIterator pIter = tech->getPassIterator();
while(pIter.hasMoreElements())
{
// Pass
Ogre::Pass *pass = pIter.getNext();
if (!pass)
continue;
if (pass->hasVertexProgram())
{
// Vertex program
const Ogre::GpuProgramPtr &verProg = pass->getVertexProgram();
if (!verProg.isNull())
{
Ogre::GpuProgramParametersSharedPtr verPtr = pass->getVertexProgramParameters();
if (verPtr->hasNamedParameters())
{
// Named parameters (constants)
Ogre::GpuConstantDefinitionIterator mapIter = verPtr->getConstantDefinitionIterator();
int constNum = 0;
while(mapIter.hasMoreElements())
{
QString paramName(mapIter.peekNextKey().c_str());
const Ogre::GpuConstantDefinition ¶mDef = mapIter.getNext();
// Filter names that end with '[0]'
if (paramName.lastIndexOf("[0]") != -1)
continue;
if (!paramDef.isFloat())
continue;
size_t size = paramDef.elementSize * paramDef.arraySize;
QVector<float> newParamValue;
QVector<float>::iterator it;
newParamValue.resize(size);
// Find the corresponding property value.
QVariant val = property(paramName.append(" VP").toLatin1());
if (!val.isValid() || val.isNull())
continue;
TypeValuePair typeValuePair = val.toMap();
QString newValueString(typeValuePair.begin().value().toByteArray());
newValueString.trimmed();
// fill the float vector with new values
it = newParamValue.begin();
int i = 0, j = 0;
bool ok = true;
while(j != -1 && ok)
{
j = newValueString.indexOf(' ', i);
QString newValue = newValueString.mid(i, j == -1 ? j : j - i);
if (!newValue.isEmpty())
{
*it = newValue.toFloat(&ok);
++it;
}
i = j + 1;
}
// Set the new value.
///\todo use the exact count rather than just 4 values if needed.
if (size == 16)
{
Ogre::Matrix4 matrix(newParamValue[0], newParamValue[1], newParamValue[2], newParamValue[3],
newParamValue[4], newParamValue[5], newParamValue[6], newParamValue[7],
newParamValue[8], newParamValue[9], newParamValue[10], newParamValue[11],
newParamValue[12], newParamValue[13], newParamValue[14], newParamValue[15]);
#if OGRE_VERSION_MINOR <= 6 && OGRE_VERSION_MAJOR <= 1
verPtr->_writeRawConstant(paramDef.physicalIndex, matrix);
#else
verPtr->_writeRawConstant(paramDef.physicalIndex, matrix, size);
#endif
}
else
{
Ogre::Vector4 vector(newParamValue[0], newParamValue[1], newParamValue[2], newParamValue[3]);
verPtr->_writeRawConstant(paramDef.physicalIndex, vector);
}
}
}
}
}
//.........这里部分代码省略.........