本文整理汇总了C++中ogre::GpuProgramParametersSharedPtr::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ GpuProgramParametersSharedPtr::isNull方法的具体用法?C++ GpuProgramParametersSharedPtr::isNull怎么用?C++ GpuProgramParametersSharedPtr::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::GpuProgramParametersSharedPtr
的用法示例。
在下文中一共展示了GpuProgramParametersSharedPtr::isNull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setUpBaseParameters
void setUpBaseParameters(const Ogre::GpuProgramParametersSharedPtr& params)
{
assert(params.isNull()==false);
struct AutoParamPair { Ogre::String name; Ogre::GpuProgramParameters::AutoConstantType type; };
//A list of auto params that might be present in the shaders generated
static const AutoParamPair AUTO_PARAMS[] = {
{ "vpWidth", Ogre::GpuProgramParameters::ACT_VIEWPORT_WIDTH },
{ "vpHeight", Ogre::GpuProgramParameters::ACT_VIEWPORT_HEIGHT },
{ "worldView", Ogre::GpuProgramParameters::ACT_WORLDVIEW_MATRIX },
{ "invProj", Ogre::GpuProgramParameters::ACT_INVERSE_PROJECTION_MATRIX },
{ "invView", Ogre::GpuProgramParameters::ACT_INVERSE_VIEW_MATRIX },
{ "flip", Ogre::GpuProgramParameters::ACT_RENDER_TARGET_FLIPPING },
{ "lightDiffuseColor", Ogre::GpuProgramParameters::ACT_LIGHT_DIFFUSE_COLOUR },
{ "lightSpecularColor", Ogre::GpuProgramParameters::ACT_LIGHT_SPECULAR_COLOUR },
{ "lightFalloff", Ogre::GpuProgramParameters::ACT_LIGHT_ATTENUATION },
{ "lightPos", Ogre::GpuProgramParameters::ACT_LIGHT_POSITION_VIEW_SPACE },
{ "lightDir", Ogre::GpuProgramParameters::ACT_LIGHT_DIRECTION_VIEW_SPACE },
{ "spotParams", Ogre::GpuProgramParameters::ACT_SPOTLIGHT_PARAMS },
{ "farClipDistance", Ogre::GpuProgramParameters::ACT_FAR_CLIP_DISTANCE },
{ "shadowViewProjMat", Ogre::GpuProgramParameters::ACT_TEXTURE_VIEWPROJ_MATRIX }
};
int numParams = sizeof(AUTO_PARAMS) / sizeof(AutoParamPair);
for (int i=0; i<numParams; i++)
{
if (params->_findNamedConstantDefinition(AUTO_PARAMS[i].name))
{
params->setNamedAutoConstant(AUTO_PARAMS[i].name, AUTO_PARAMS[i].type);
}
}
}
示例2: notifyMaterialRender
//!
//! Callback when instance of this class is registered as Ogre::CompositorListener.
//!
//! \param pass_id Id to identifiy current compositor pass.
//! \param mat Material this pass is currently using.
//!
void BadPrintingNode::notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr &mat)
{
Ogre::TexturePtr inputTexture = getTextureValue("Input Map");
if (inputTexture.isNull())
return;
// watercolor pass
if (pass_id == 0000) {
// set shader parameters
Ogre::GpuProgramParametersSharedPtr fpParams = getShaderParameters(mat);
if (!fpParams.isNull()) {
// setShaderParameter(fpParams, "speed1", (Ogre::Real)(getDoubleValue("Speed1") / 100.0));
// setShaderParameter(fpParams, "speed2", (Ogre::Real)(getDoubleValue("Speed2") / 100.0));
// setShaderParameter(fpParams, "speed1", (Ogre::Real)(getDoubleValue("Speed1") / 100.0));
// setShaderParameter(fpParams, "scratchIntensity", (Ogre::Real)(getDoubleValue("ScratchIntensity") / 100.0));
// setShaderParameter(fpParams, "is", (Ogre::Real)(getDoubleValue("IS") / 100.0));
}
// set texture name
setTexture(mat, inputTexture, 0);
}
if (pass_id == 0001) {
// set shader parameters
Ogre::GpuProgramParametersSharedPtr fpParams = getShaderParameters(mat);
if (!fpParams.isNull()) {
// setShaderParameter(fpParams, "speed1", (Ogre::Real)(getDoubleValue("Speed1") / 100.0));
// setShaderParameter(fpParams, "speed2", (Ogre::Real)(getDoubleValue("Speed2") / 100.0));
// setShaderParameter(fpParams, "speed1", (Ogre::Real)(getDoubleValue("Speed1") / 100.0));
// setShaderParameter(fpParams, "scratchIntensity", (Ogre::Real)(getDoubleValue("ScratchIntensity") / 100.0));
// setShaderParameter(fpParams, "is", (Ogre::Real)(getDoubleValue("IS") / 100.0));
}
// set texture name
setTexture(mat, inputTexture, 0);
}
}
示例3: update
void OGKSceneManager::update(Ogre::Real timeElapsed)
{
if(mTransitionTimeRemaining > 0.f) {
mTransitionTimeRemaining -= timeElapsed;
if(mTransitionTimeRemaining <= 0.f) {
OGKLOG("Transition completed");
if(mPreviousScene) mPreviousScene->onExit();
if(mActiveScene) mActiveScene->onEnterTransitionDidFinish();
if(mOverlay) mOverlay->hide();
}
else if(mPreviousScene) {
mPreviousScene->update(timeElapsed);
if(mRenderTexture) {
//OGKLOG("updating render texture");
mRenderTexture->update();
}
if(mTransitionTextureUnitState) {
Ogre::Real fadeAmt = MIN(1.0,MAX(0.0,mTransitionTimeRemaining) / mTransitionTime);
//OGKLOG("updating fade amt " + Ogre::StringConverter::toString(fadeAmt) );
#ifdef OGRE_IS_IOS
// Retrieve the shader parameters
Ogre::GpuProgramParametersSharedPtr pParams = mTransitionMaterial->getTechnique(0)->getPass(0)->getFragmentProgramParameters();
if ( !pParams.isNull() ) {
if ( pParams->_findNamedConstantDefinition( "quadAlpha" ) ) {
pParams->setNamedConstant( "quadAlpha", fadeAmt );
}
}
#else
mTransitionTextureUnitState->setAlphaOperation(Ogre::LBX_SOURCE1, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, fadeAmt);
#endif
#ifdef INCLUDE_RTSHADER_SYSTEM
Ogre::RTShader::ShaderGenerator::getSingletonPtr()->invalidateMaterial(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME, kTransitionMaterialName);
#endif
}
}
}
if(mActiveScene) mActiveScene->update(timeElapsed);
}
示例4: frameRenderingQueued
bool frameRenderingQueued(const FrameEvent& evt)
{
Real seconds = (Real)(Root::getSingleton().getTimer()->getMilliseconds()) / 1000.0;
Pass* renderPass = mOgreEnt->getSubEntity(0)->getMaterial()->getTechnique(0)->getPass(0);
if (renderPass->hasFragmentProgram())
{
Ogre::GpuProgramParametersSharedPtr pParams = renderPass->getFragmentProgramParameters();
if ( pParams.isNull() )
{
//printf("SAD PANDA!");
}
else
{
if ( pParams->_findNamedConstantDefinition( "ColourMe[0]" ) )
{
Vector4 constParam = Ogre::Vector4(0.5, 0.1, 0.0, 1.0);
renderPass->getFragmentProgramParameters()->setNamedConstant("ColourMe[0]", constParam);
Vector4 timeParam = Ogre::Vector4(
Ogre::Math::Sin(seconds)*0.5, 0.0, Ogre::Math::Cos(seconds)*0.5, 0.0);
renderPass->getFragmentProgramParameters()->setNamedConstant("ColourMe[1]", timeParam);
}
const Ogre::GpuConstantDefinition* atom_counter_def;
if ( (atom_counter_def = &pParams->getConstantDefinition("atom_counter")) )
{
//TODO lock buffer, retrieve counter value similar to compute above
//const uint* counter = pParams->getUnsignedIntPointer(atom_counter_def->physicalIndex);
//const uint* counter2 = ;
//std::cout << "FOUND THE ATOMS: " << *counter << " " << std::endl; //<< *counter2 << std::endl;
}
}
}
// renderPass->getFragmentProgramParameters()->getConstantDefinition("atom_counter").getValue();
return SdkSample::frameRenderingQueued(evt);
}
示例5: _updateShaders
void GrassLayerBase::_updateShaders()
{
if (shaderNeedsUpdate) {
shaderNeedsUpdate = false;
//Proceed only if there is no custom vertex shader and the user's computer supports vertex shaders
const RenderSystemCapabilities *caps = Root::getSingleton().getRenderSystem()->getCapabilities();
if (caps->hasCapability(RSC_VERTEX_PROGRAM) && geom->getShadersEnabled()) {
//Calculate fade range
float farViewDist = geom->getDetailLevels().front()->getFarRange();
float fadeRange = farViewDist / 1.2247449f;
//Note: 1.2247449 ~= sqrt(1.5), which is necessary since the far view distance is measured from the centers
//of pages, while the vertex shader needs to fade grass completely out (including the closest corner)
//before the page center is out of range.
//Generate a string ID that identifies the current set of vertex shader options
StringUtil::StrStreamType tmpName;
tmpName << "GrassVS_";
if (animate)
tmpName << "anim_";
if (blend)
tmpName << "blend_";
if (lighting)
tmpName << "lighting_";
tmpName << renderTechnique << "_";
tmpName << fadeTechnique << "_";
if (fadeTechnique == FADETECH_GROW || fadeTechnique == FADETECH_ALPHAGROW)
tmpName << maxHeight << "_";
tmpName << farViewDist << "_";
tmpName << "vp";
const String vsName = tmpName.str();
//Generate a string ID that identifies the material combined with the vertex shader
const String matName = material->getName() + "_" + vsName;
//Check if the desired material already exists (if not, create it)
MaterialPtr tmpMat = MaterialManager::getSingleton().getByName(matName);
if (tmpMat.isNull()) {
//Clone the original material
tmpMat = material->clone(matName);
//Disable lighting
tmpMat->setLightingEnabled(false);
//tmpMat->setReceiveShadows(false);
//Check if the desired shader already exists (if not, compile it)
String shaderLanguage = ShaderHelper::getShaderLanguage();
HighLevelGpuProgramPtr vertexShader = HighLevelGpuProgramManager::getSingleton().getByName(vsName);
if (vertexShader.isNull()) {
//Generate the grass shader
String vertexProgSource;
if (!shaderLanguage.compare("hlsl") || !shaderLanguage.compare("cg")) {
vertexProgSource = "void main( \n"
" float4 iPosition : POSITION, \n"
" float4 iColor : COLOR, \n"
" float2 iUV : TEXCOORD0, \n"
" out float4 oPosition : POSITION, \n"
" out float4 oColor : COLOR, \n"
" out float2 oUV : TEXCOORD0, \n";
if (lighting)
vertexProgSource += " uniform float4 objSpaceLight, \n"
" uniform float4 lightDiffuse, \n"
" uniform float4 lightAmbient, \n";
if (animate)
vertexProgSource += " uniform float time, \n"
" uniform float frequency, \n"
" uniform float4 direction, \n";
if (fadeTechnique == FADETECH_GROW || fadeTechnique == FADETECH_ALPHAGROW)
vertexProgSource += " uniform float grassHeight, \n";
if (renderTechnique == GRASSTECH_SPRITE || lighting)
vertexProgSource += " float4 iNormal : NORMAL, \n";
vertexProgSource += " uniform float4x4 worldViewProj, \n"
" uniform float3 camPos, \n"
" uniform float fadeRange ) \n"
"{ \n"
" oColor.rgb = iColor.rgb; \n"
" float4 position = iPosition; \n"
" float dist = distance(camPos.xz, position.xz); \n";
if (lighting) {
vertexProgSource += " float3 light = normalize(objSpaceLight.xyz - (iPosition.xyz * objSpaceLight.w)); \n"
" float diffuseFactor = max(dot(float4(0,1,0,0), light), 0); \n"
" oColor = (lightAmbient + diffuseFactor * lightDiffuse) * iColor; \n";
} else {
vertexProgSource += " oColor.rgb = iColor.rgb; \n";
}
if (fadeTechnique == FADETECH_ALPHA || fadeTechnique == FADETECH_ALPHAGROW)
vertexProgSource +=
//Fade out in the distance
" oColor.a = 2.0f - (2.0f * dist / fadeRange); \n";
else
//.........这里部分代码省略.........
示例6: 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();
//.........这里部分代码省略.........
示例7: 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);
}
}
}
}
}
//.........这里部分代码省略.........