当前位置: 首页>>代码示例>>C++>>正文


C++ ParameterPtr::get方法代码示例

本文整理汇总了C++中ParameterPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ ParameterPtr::get方法的具体用法?C++ ParameterPtr::get怎么用?C++ ParameterPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ParameterPtr的用法示例。


在下文中一共展示了ParameterPtr::get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: generateLocalSplitParameters

//-----------------------------------------------------------------------------
void ProgramProcessor::generateLocalSplitParameters(Function* func, GpuProgramType progType,
												   MergeParameterList& mergedParams, 
												   ShaderParameterList& splitParams, LocalParameterMap& localParamsMap)
{
	// No split params created.
	if (splitParams.size() == 0)	
		return;	

	// Create the local parameters + map from source to local.
	for (unsigned int i=0; i < splitParams.size(); ++i)
	{
		ParameterPtr srcParameter   = splitParams[i];
		ParameterPtr localParameter = func->resolveLocalParameter(srcParameter->getSemantic(), srcParameter->getIndex(), "lsplit_" + srcParameter->getName(), srcParameter->getType());

		localParamsMap[srcParameter.get()] = localParameter;		
	}	

	int invocationCounter = 0;

	// Establish link between the local parameter to the merged parameter.
	for (unsigned int i=0; i < mergedParams.size(); ++i)
	{
		MergeParameter& curMergeParameter = mergedParams[i];

		for (unsigned int p=0; p < curMergeParameter.getSourceParameterCount(); ++p)
		{
			ParameterPtr srcMergedParameter    = curMergeParameter.getSourceParameter(p);
			LocalParameterMap::iterator itFind = localParamsMap.find(srcMergedParameter.get());

			// Case the source parameter is split parameter.
			if (itFind != localParamsMap.end())
			{
				// Case it is the vertex shader -> assign the local parameter to the output merged parameter.
				if (progType == GPT_VERTEX_PROGRAM)
				{
					FunctionInvocation* curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_VS_POST_PROCESS, invocationCounter++);
					
					curFuncInvocation->pushOperand(itFind->second, Operand::OPS_IN, curMergeParameter.getSourceParameterMask(p));
					curFuncInvocation->pushOperand(curMergeParameter.getDestinationParameter(Operand::OPS_OUT, i), Operand::OPS_OUT, curMergeParameter.getDestinationParameterMask(p));		
					func->addAtomInstance(curFuncInvocation);		
				}
				else if (progType == GPT_FRAGMENT_PROGRAM)
				{
					FunctionInvocation* curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_PS_PRE_PROCESS, invocationCounter++);
					
					curFuncInvocation->pushOperand(curMergeParameter.getDestinationParameter(Operand::OPS_IN, i), Operand::OPS_IN, curMergeParameter.getDestinationParameterMask(p));		
					curFuncInvocation->pushOperand(itFind->second, Operand::OPS_OUT, curMergeParameter.getSourceParameterMask(p));
					func->addAtomInstance(curFuncInvocation);		
				}
			}
		}
	}				
}
开发者ID:changsin,项目名称:ogre,代码行数:54,代码来源:OgreShaderProgramProcessor.cpp

示例2: resolveLocalParameter

//-----------------------------------------------------------------------------
ParameterPtr Function::resolveLocalParameter(Parameter::Semantic semantic, int index,
										   const String& name,
										   GpuConstantType type)
{
	ParameterPtr param;

	param = getParameterByName(mLocalParameters, name);
	if (param.get() != NULL)
	{
		if (param->getType() == type &&
			param->getSemantic() == semantic &&
			param->getIndex() == index)
		{
			return param;
		}
		else 
		{
			OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
				"Can not resolve local parameter due to type mismatch. Function <" + getName() + ">", 			
				"Function::resolveLocalParameter" );
		}		
	}
		
	param = ParameterPtr(OGRE_NEW Parameter(type, name, semantic, index, Parameter::SPC_UNKNOWN));
	addParameter(mLocalParameters, param);
			
	return param;
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:29,代码来源:OgreShaderFunction.cpp

示例3: replaceParametersReferences

//-----------------------------------------------------------------------------
void ProgramProcessor::replaceParametersReferences(MergeParameterList& mergedParams, ParameterOperandMap& paramsRefMap)
{
	for (unsigned int i=0; i < mergedParams.size(); ++i)
	{
		MergeParameter& curMergeParameter = mergedParams[i];
		int paramBitMaskOffset = 0;

		for (unsigned int j=0; j < curMergeParameter.getSourceParameterCount(); ++j)
		{
			ParameterPtr	  curSrcParam  = curMergeParameter.getSourceParameter(j);
			ParameterOperandMap::iterator itParamRefs = paramsRefMap.find(curSrcParam.get());

			// Case the source parameter has some references
			if (itParamRefs != paramsRefMap.end())
			{
				OperandPtrVector& srcParamRefs = itParamRefs->second;
				ParameterPtr dstParameter;

				// Case the source parameter is fully contained within the destination merged parameter.
				if (curMergeParameter.getSourceParameterMask(j) == Operand::OPM_ALL)
				{
					dstParameter = curMergeParameter.getDestinationParameter(Operand::OPS_INOUT, i);

					for (unsigned int op=0; op < srcParamRefs.size(); ++op)
					{
						Operand*  srcOperandPtr = srcParamRefs[op];
						int       dstOpMask;

						if (srcOperandPtr->getMask() == Operand::OPM_ALL)
						{
							// Case the merged parameter contains only one source - no point in adding special mask.
							if (curMergeParameter.getSourceParameterCount() == 1)
							{
								dstOpMask = Operand::OPM_ALL;
							}
							else
							{
								dstOpMask = getParameterMaskByType(curSrcParam->getType()) << paramBitMaskOffset;							
							}
						}
						else
						{
							dstOpMask = srcOperandPtr->getMask() << paramBitMaskOffset;
						}

						// Replace the original source operand with a new operand the reference the new merged parameter.						
						*srcOperandPtr = Operand(dstParameter, srcOperandPtr->getSemantic(), dstOpMask);
					}
				}
			}	


			// Update the bit mask offset. 
			paramBitMaskOffset += getParameterFloatCount(curSrcParam->getType());			
		}
	}
}
开发者ID:changsin,项目名称:ogre,代码行数:58,代码来源:OgreShaderProgramProcessor.cpp

示例4: createCpuSubPrograms

//-----------------------------------------------------------------------
bool FFPTransform::createCpuSubPrograms(ProgramSet* programSet)
{
	Program* vsProgram = programSet->getCpuVertexProgram();
	
	// Resolve World View Projection Matrix.
	UniformParameterPtr wvpMatrix = vsProgram->resolveAutoParameterInt(GpuProgramParameters::ACT_WORLDVIEWPROJ_MATRIX, 0);
	if (wvpMatrix.get() == NULL)
		return false;
		
	Function* vsEntry = vsProgram->getEntryPointFunction();
	assert(vsEntry != NULL);

	// Resolve input position parameter.
	ParameterPtr positionIn = vsEntry->resolveInputParameter(Parameter::SPS_POSITION, 0, Parameter::SPC_POSITION_OBJECT_SPACE, GCT_FLOAT4);	
	if (positionIn.get() == NULL)
		return false;
	

	// Resolve output position parameter.
	ParameterPtr positionOut = vsEntry->resolveOutputParameter(Parameter::SPS_POSITION, 0, Parameter::SPC_POSITION_PROJECTIVE_SPACE, GCT_FLOAT4);
	if (positionOut.get() == NULL)
		return false;
	

	// Add dependency.
	vsProgram->addDependency(FFP_LIB_TRANSFORM);

	FunctionInvocation* transformFunc = OGRE_NEW FunctionInvocation(FFP_FUNC_TRANSFORM,  FFP_VS_TRANSFORM, 0); 

	transformFunc->pushOperand(wvpMatrix, Operand::OPS_IN);
	transformFunc->pushOperand(positionIn, Operand::OPS_IN);
	transformFunc->pushOperand(positionOut, Operand::OPS_OUT);

	vsEntry->addAtomInstace(transformFunc);

	return true;
}
开发者ID:dodong471520,项目名称:pap,代码行数:38,代码来源:OgreShaderFFPTransform.cpp

示例5: resolveInputParameter

//-----------------------------------------------------------------------------
ParameterPtr Function::resolveInputParameter(Parameter::Semantic semantic,
										int index,
										const Parameter::Content content,
										GpuConstantType type)
{
	ParameterPtr param;

	// Check if desired parameter already defined.
	param = getParameterByContent(mInputParameters, content, type);
	if (param.get() != NULL)
		return param;

	// Case we have to create new parameter.
	if (index == -1)
	{
		index = 0;

		// Find the next available index of the target semantic.
		ShaderParameterIterator it;

		for (it = mInputParameters.begin(); it != mInputParameters.end(); ++it)
		{
			if ((*it)->getSemantic() == semantic)
			{
				index++;
			}
		}
	}
	else
	{
		// Check if desired parameter already defined.
		param = getParameterBySemantic(mInputParameters, semantic, index);
		if (param.get() != NULL && param->getContent() == content)
		{
			if (param->getType() == type)
			{
				return param;
			}
			else 
			{
				OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, 
					"Can not resolve parameter - semantic: " + StringConverter::toString(semantic) + " - index: " + StringConverter::toString(index) + " due to type mismatch. Function <" + getName() + ">", 			
					"Function::resolveInputParameter" );
			}
		}
	}

	

	// No parameter found -> create new one.
	switch (semantic)
	{
	case Parameter::SPS_POSITION:	
		assert(type == GCT_FLOAT4);
		param = ParameterFactory::createInPosition(index);
		break;
			
	case Parameter::SPS_BLEND_WEIGHTS:			
		assert(type == GCT_FLOAT4);
		param = ParameterFactory::createInWeights(index);
		break;
			
	case Parameter::SPS_BLEND_INDICES:
		assert(type == GCT_FLOAT4);
		param = ParameterFactory::createInIndices(index);
		break;
			
	case Parameter::SPS_NORMAL:
		assert(type == GCT_FLOAT3);
		param = ParameterFactory::createInNormal(index);
		break;
			
	case Parameter::SPS_COLOR:
		assert(type == GCT_FLOAT4);
		param = ParameterFactory::createInColor(index);
		break;
						
	case Parameter::SPS_TEXTURE_COORDINATES:		
		param = ParameterFactory::createInTexcoord(type, index, content);				
		break;
			
	case Parameter::SPS_BINORMAL:
		assert(type == GCT_FLOAT3);
		param = ParameterFactory::createInBiNormal(index);
		break;
			
	case Parameter::SPS_TANGENT:
		assert(type == GCT_FLOAT3);
		param = ParameterFactory::createInTangent(index);
		break;
	case Parameter::SPS_UNKNOWN:
        break;
	}

	if (param.get() != NULL)
		addInputParameter(param);

	return param;
}
开发者ID:Ali-il,项目名称:gamekit,代码行数:100,代码来源:OgreShaderFunction.cpp

示例6: addFunctionInvocations

//-----------------------------------------------------------------------
bool FFPColour::addFunctionInvocations(ProgramSet* programSet)
{
	Program* vsProgram = programSet->getCpuVertexProgram();
	Program* psProgram = programSet->getCpuFragmentProgram();
	Function* vsMain   = vsProgram->getEntryPointFunction();
	Function* psMain   = psProgram->getEntryPointFunction();	
	FunctionInvocation* curFuncInvocation = NULL;	
	int internalCounter;

	
	// Create vertex shader colour invocations.
	ParameterPtr vsDiffuse;
	ParameterPtr vsSpecular;
	internalCounter = 0;	
	if (mVSInputDiffuse.get() != NULL)
	{
		vsDiffuse = mVSInputDiffuse;
	}
	else
	{
		vsDiffuse = vsMain->resolveLocalParameter(Parameter::SPS_COLOR, 0, Parameter::SPC_COLOR_DIFFUSE, GCT_FLOAT4);
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_CONSTRUCT, FFP_VS_COLOUR, internalCounter++);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(vsDiffuse, Operand::OPS_OUT);
		vsMain->addAtomInstace(curFuncInvocation);
	}

	if (mVSOutputDiffuse.get() != NULL)
	{
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_VS_COLOUR, internalCounter++);
		curFuncInvocation->pushOperand(vsDiffuse, Operand::OPS_IN);
		curFuncInvocation->pushOperand(mVSOutputDiffuse, Operand::OPS_OUT);
		vsMain->addAtomInstace(curFuncInvocation);
	}
	
	if (mVSInputSpecular.get() != NULL)
	{
		vsSpecular = mVSInputSpecular;		
	}
	else
	{
		vsSpecular = vsMain->resolveLocalParameter(Parameter::SPS_COLOR, 1, Parameter::SPC_COLOR_SPECULAR, GCT_FLOAT4);

		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_CONSTRUCT, FFP_VS_COLOUR, internalCounter++);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(vsSpecular, Operand::OPS_OUT);
		vsMain->addAtomInstace(curFuncInvocation);
	}

	if (mVSOutputSpecular.get() != NULL)
	{
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_ASSIGN, FFP_VS_COLOUR, internalCounter++);
		curFuncInvocation->pushOperand(vsSpecular, Operand::OPS_IN);
		curFuncInvocation->pushOperand(mVSOutputSpecular, Operand::OPS_OUT);
		vsMain->addAtomInstace(curFuncInvocation);
	}
	
	

	// Create fragment shader colour invocations.
	ParameterPtr psDiffuse;
	ParameterPtr psSpecular;
	internalCounter = 0;
	
	// Handle diffuse colour.
	if (mPSInputDiffuse.get() != NULL)
	{
		psDiffuse = mPSInputDiffuse;				
	}
	else
	{
		psDiffuse = psMain->resolveLocalParameter(Parameter::SPS_COLOR, 0, Parameter::SPC_COLOR_DIFFUSE, GCT_FLOAT4);
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_CONSTRUCT, FFP_PS_COLOUR_BEGIN, internalCounter++);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(1.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(psDiffuse, Operand::OPS_OUT);
		psMain->addAtomInstace(curFuncInvocation);
	}

	// Handle specular colour.
	if (mPSInputSpecular.get() != NULL)
	{
		psSpecular = mPSInputSpecular;		
	}
	else
	{
		psSpecular = psMain->resolveLocalParameter(Parameter::SPS_COLOR, 1, Parameter::SPC_COLOR_SPECULAR, GCT_FLOAT4);
		curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_CONSTRUCT, FFP_PS_COLOUR_BEGIN, internalCounter++);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
		curFuncInvocation->pushOperand(ParameterFactory::createConstParamFloat(0.0), Operand::OPS_IN);
//.........这里部分代码省略.........
开发者ID:gbruce,项目名称:ogre3d_trunk,代码行数:101,代码来源:OgreShaderFFPColour.cpp

示例7: set

bool CalculusUnambiguousRangeParameter::set(const uint &value)
{
  ParameterPtr p = _depthCamera.getParam(MOD_F);
  
  CalculusModulationFrequencyParameter *mfp = dynamic_cast<CalculusModulationFrequencyParameter *>(p.get());
  
  if(!mfp)
    return false;
  
  float modulationFrequency1Minimum = mfp->getOptimalMinimum(), modulationFrequency1Maximum = mfp->getOptimalMaximum();
  
  FrameRate r;
  
  if(!_depthCamera._getFrameRate(r))
    return false;
  
  // No need of dealiasing?
  if(value <= (uint)(4095*SPEED_OF_LIGHT/1E6f/2/(1 << 12)/modulationFrequency1Minimum))
  {
    float modulationFrequency1 = 4095*SPEED_OF_LIGHT/1E6f/2/(1 << 12)/value;
    
    if(!_depthCamera._set(TG_EN, false) || 
      !_depthCamera._setFrameRate(r) ||
      !mfp->set(modulationFrequency1) ||
      !_depthCamera._set(DEALIAS_EN, false) ||// Disable dealiasing explicitly)
      !_depthCamera._set(ALT_FRM_EN, false) ||
      !_depthCamera._set(SCRATCH2, value) || // Save the value in a register
      !_depthCamera._set(TG_EN, true))
      return false;
      
    _value = value;
    
    return true;
  }
  else
  {
    int rangeExtensionRatio = ceil(log2(value/(SPEED_OF_LIGHT/(2*modulationFrequency1Maximum*1E6))));
    
    if(rangeExtensionRatio > 6)
    {
      logger(LOG_ERROR) << "CalculusUnambiguousRangeParameter: Desired unambiguous range is too large." << std::endl;
      return false;
    }
    
    if(!_depthCamera._set(TG_EN, false) ||
      !_depthCamera._set(ALT_FRM_EN, true) ||
      !mfp->set(modulationFrequency1Maximum) ||
      !_depthCamera._set(ALT_FREQ_SEL, rangeExtensionRatio - 1) ||
      !_depthCamera._setFrameRate(r) ||
      !_depthCamera._set(DEALIAS_EN, true) ||
      //!UnsignedIntegerParameter::set(value) || // Save the value in a register
      !_depthCamera._set(TG_EN, true))
      return false;
    
    _value = value;
    
    return true;
  }
}
开发者ID:3dtof,项目名称:voxelsdk,代码行数:59,代码来源:ToFCalculusCamera.cpp


注:本文中的ParameterPtr::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。