本文整理汇总了C++中ogre::GpuProgramParametersSharedPtr::_writeRawConstant方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr::_writeRawConstant方法的具体用法?C++ GpuProgramParametersSharedPtr::_writeRawConstant怎么用?C++ GpuProgramParametersSharedPtr::_writeRawConstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::GpuProgramParametersSharedPtr
的用法示例。
在下文中一共展示了GpuProgramParametersSharedPtr::_writeRawConstant方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
}
}
//.........这里部分代码省略.........