• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ Var类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Var的典型用法代码示例。如果您正苦于以下问题:C++ Var类的具体用法?C++ Var怎么用?C++ Var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: BinaryFactor

Factor BinaryFactor( const Var &n, Real field ) {
    DAI_ASSERT( n.states() == 2 );
    Real buf[2];
    buf[0] = std::exp(-field);
    buf[1] = std::exp(field);
    return Factor(n, &buf[0]);
}
开发者ID:DerThorsten,项目名称:libdai,代码行数:7,代码来源:createfg.cpp


示例2: createFactorIsing

Factor createFactorIsing( const Var &n, Real h ) {
    DAI_ASSERT( n.states() == 2 );
    Real buf[2];
    buf[0] = std::exp(-h);
    buf[1] = std::exp(h);
    return Factor(n, &buf[0]);
}
开发者ID:Nick11,项目名称:V3DSfMToolkit,代码行数:7,代码来源:factor.cpp


示例3: processVert

void DepthOutHLSL::processVert(  Vector<ShaderComponent*> &componentList, 
                                 const MaterialFeatureData &fd )
{
   ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );

   // Grab the output vert.
   Var *outPosition = (Var*)LangElement::find( "hpos" );

   // Grab our output depth.
   Var *outDepth = connectComp->getElement( RT_TEXCOORD );
   outDepth->setName( "depth" );
   outDepth->setStructName( "OUT" );
   outDepth->setType( "float" );

   output = new GenOp( "   @ = @.z / @.w;\r\n", outDepth, outPosition, outPosition );
}
开发者ID:adhistac,项目名称:ee-client-2-0,代码行数:16,代码来源:depthHLSL.cpp


示例4: name

Var* TerrainFeatHLSL::_getDetailIdStrengthParallax()
{
   String name( String::ToString( "detailIdStrengthParallax%d", getProcessIndex() ) );

   Var *detailInfo = (Var*)LangElement::find( name );
   if ( !detailInfo )
   {
      detailInfo = new Var;
      detailInfo->setType( "float3" );
      detailInfo->setName( name );
      detailInfo->uniform = true;
      detailInfo->constSortPos = cspPotentialPrimitive;
   }

   return detailInfo;
}
开发者ID:93i,项目名称:Torque3D,代码行数:16,代码来源:terrFeatureHLSL.cpp


示例5: readDouble

static void readDouble(const File& file,
                       const string& name,
                       const array<size_t, dimension>& start,
                       const array<size_t, dimension>& count,
                       Type* values,
                       PropertyType Type::*property,
                       const Converter& converter) {
    size_t size = accumulate(count.begin(), count.end(), 1, [](size_t n, size_t m) { return n*m; });
    vector<double> v(size);
    const Var var(file.var(name));
    var.get(start, count, v.data());
    size_t n = 0;
    for (auto it = v.begin(); it != v.end(); ++it, ++n) {
        values[n].*property = converter(*it);
    }
}
开发者ID:snakamura,项目名称:volare,代码行数:16,代码来源:msm.cpp


示例6: getInTexCoord

void TerrainBaseMapFeatHLSL::processPix(  Vector<ShaderComponent*> &componentList, 
                                          const MaterialFeatureData &fd )
{
   // grab connector texcoord register
   Var *texCoord = getInTexCoord( "texCoord", "float3", true, componentList );

   // create texture var
   Var *diffuseMap = new Var;
   diffuseMap->setType( "sampler2D" );
   diffuseMap->setName( "baseTexMap" );
   diffuseMap->uniform = true;
   diffuseMap->sampler = true;
   diffuseMap->constNum = Var::getTexUnitNum();     // used as texture unit num here

   MultiLine *meta = new MultiLine;

   Var *baseColor = new Var;
   baseColor->setType( "float4" );
   baseColor->setName( "baseColor" );
   if (mIsDirect3D11)
   {
      diffuseMap->setType("SamplerState");
      Var *diffuseTex = new Var;
      diffuseTex->setType("Texture2D");
      diffuseTex->setName("baseTexture");
      diffuseTex->uniform = true;
      diffuseTex->texture = true;
      diffuseTex->constNum = diffuseMap->constNum;
      meta->addStatement(new GenOp("   @ = @.Sample( @, @.xy );\r\n", new DecOp(baseColor), diffuseTex, diffuseMap, texCoord));
   }
   else
   {
      meta->addStatement(new GenOp("   @ = tex2D( @, @.xy );\r\n", new DecOp(baseColor), diffuseMap, texCoord));
   }

   meta->addStatement(new GenOp("   @ = toLinear(@);\r\n", baseColor, baseColor));

   ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;

   if (fd.features.hasFeature(MFT_isDeferred))
   {
      target= ShaderFeature::RenderTarget1;
   }

   meta->addStatement( new GenOp( "   @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
   output = meta;
}
开发者ID:J0linar,项目名称:Torque3D,代码行数:47,代码来源:terrFeatureHLSL.cpp


示例7: blockCurrentSol

void Engine::blockCurrentSol() {
	if (outputs.size() == 0) NOT_SUPPORTED;
	Clause& c = *Reason_new(outputs.size());
	bool root_failure = true;
	for (int i = 0; i < outputs.size(); i++) {
		Var *v = (Var*) outputs[i];
		if (v->getType() == BOOL_VAR) {
			c[i] = ((BoolView*) outputs[i])->getValLit();
		} else {
			c[i] = ((IntVar*) outputs[i])->getValLit();
		}
		if (!sat.isRootLevel(var(c[i]))) root_failure = false;
		assert(sat.value(c[i]) == l_False);
	}
	if (root_failure) sat.btToLevel(0);
	sat.confl = &c;
}
开发者ID:geoffchu,项目名称:chuffed,代码行数:17,代码来源:engine.c


示例8: name

Var* TerrainFeatGLSL::_getInDetailCoord( Vector<ShaderComponent*> &componentList )
{
   String name( String::ToString( "outDetCoord%d", getProcessIndex() ) );
   Var *inDet = (Var*)LangElement::find( name );
   
   if ( !inDet )
   {
      ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
      
      inDet = connectComp->getElement( RT_TEXCOORD );
      inDet->setName( name );
      inDet->setType( "vec4" );
      inDet->mapsToSampler = true;
   }
   
   return inDet;
}
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:17,代码来源:terrFeatureGLSL.cpp


示例9: print

// class PathExpressionPrinter
void PathExpressionPrinter::print(const Var &v) {
  simit_iassert(v.defined()) << "attempting to print undefined var";
  std::string name;
  if (util::contains(names, v)) {
    name = names.at(v);
  }
  else {
    if (v.getName() != "") {
      name = nameGenerator.getName(v.getName());
    }
    else {
      name = nameGenerator.getName("e");
    }
    names[v] = name;
  }
  os << name;
}
开发者ID:simit-lang,项目名称:simit,代码行数:18,代码来源:path_expressions.cpp


示例10: name

Var* TerrainFeatGLSL::_getNormalMapTex()
{
   String name( String::ToString( "normalMap%d", getProcessIndex() ) );
   Var *normalMap =  (Var*)LangElement::find( name );
   
   if ( !normalMap )
   {
      normalMap = new Var;
      normalMap->setType( "sampler2D" );
      normalMap->setName( name );
      normalMap->uniform = true;
      normalMap->sampler = true;
      normalMap->constNum = Var::getTexUnitNum();
   }
   
   return normalMap;
}
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:17,代码来源:terrFeatureGLSL.cpp


示例11: qDebug

void Var::append(Var var)
{
	if(Type=="list")
    {
		if(var.getType()=="list")
        {
			for(int i=0;i<var.size();i++)
				List.append(var[i]);
        }
		else
        {
			List.append(var);
        }
    }
	else
		qDebug()<<"Var::append - type is not list; Name = "<<Name<<"Type = "<<Type;
}
开发者ID:Aspenka,项目名称:SSD,代码行数:17,代码来源:var.cpp


示例12: DecOp

Var* GBufferConditionerGLSL::_unconditionInput( Var *conditionedInput, MultiLine *meta )
{
   Var *retVar = new Var;
   retVar->setType("vec4");
   retVar->setName("_gbUnconditionedInput");
   LangElement *outputDecl = new DecOp( retVar );

   switch(mNormalStorageType)
   {
      case CartesianXYZ:
         meta->addStatement( new GenOp( "   // g-buffer unconditioner: vec4(normal.xyz, depth)\r\n" ) );
         meta->addStatement( new GenOp( "   @ = vec4(@, @.a);\r\n", outputDecl, 
            _posnegDecode(new GenOp("@.xyz", conditionedInput)), conditionedInput ) );
         break;

      case CartesianXY:
         meta->addStatement( new GenOp( "   // g-buffer unconditioner: vec4(normal.xy, depth Hi + z-sign, depth Lo)\r\n" ) );
         meta->addStatement( new GenOp( "   @ = vec4(@, @.a);\r\n", outputDecl, 
            _posnegDecode(new GenOp("@.xyz", conditionedInput)), conditionedInput ) );
         meta->addStatement( new GenOp( "   @.z *= sqrt(1.0 - dot(@.xy, @.xy));\r\n", retVar, retVar, retVar ) );
         break;

      case Spherical:
         meta->addStatement( new GenOp( "   // g-buffer unconditioner: vec4(normal.theta, normal.phi, depth Hi, depth Lo)\r\n" ) );
         meta->addStatement( new GenOp( "   vec2 spGPUAngles = @;\r\n", _posnegDecode(new GenOp("@.xy", conditionedInput)) ) );
         meta->addStatement( new GenOp( "   vec2 sincosTheta;\r\n" ) );
         meta->addStatement( new GenOp( "   sincosTheta.x = sin(spGPUAngles.x * 3.14159265358979323846);\r\n" ) );
         meta->addStatement( new GenOp( "   sincosTheta.y = cos(spGPUAngles.x * 3.14159265358979323846);\r\n" ) );
         meta->addStatement( new GenOp( "   vec2 sincosPhi = vec2(sqrt(1.0 - spGPUAngles.y * spGPUAngles.y), spGPUAngles.y);\r\n" ) );
         meta->addStatement( new GenOp( "   @ = vec4(sincosTheta.y * sincosPhi.x, sincosTheta.x * sincosPhi.x, sincosPhi.y, @.a);\r\n", outputDecl, conditionedInput ) );
         break;
   }

   // Recover depth from encoding
   if(mNormalStorageType != CartesianXYZ)
   {
      const U64 maxValPerChannel = 1 << mBitsPerChannel;
      meta->addStatement( new GenOp( "   \r\n   // Decode depth\r\n" ) );
      meta->addStatement( new GenOp( avar( "   @.w = dot( @.zw, vec2(1.0, 1.0/%llu.0));\r\n", maxValPerChannel - 1 ), 
         retVar, conditionedInput ) );
   }


   AssertFatal( retVar != NULL, avar( "Cannot uncondition input from buffer format: %s", GFXStringTextureFormat[getBufferFormat()] ) );
   return retVar; 
}
开发者ID:fr1tz,项目名称:alux3d,代码行数:46,代码来源:gBufferConditionerGLSL.cpp


示例13: setValue

void ParseHandler::setValue(const Var& value)
{
	Var parent = _stack.top();

	if ( parent.type() == typeid(Array::Ptr) )
	{
		Array::Ptr arr = parent.extract<Array::Ptr>();
		arr->add(value);
	}
	else if ( parent.type() == typeid(Object::Ptr) )
	{
		poco_assert_dbg(!_key.empty());
		Object::Ptr obj = parent.extract<Object::Ptr>();
		obj->set(_key, value);
		_key.clear();
	}
}
开发者ID:12307,项目名称:poco,代码行数:17,代码来源:ParseHandler.cpp


示例14: writeVarLargeEncodingExpression

static void writeVarLargeEncodingExpression(Var& var, FILE* fp)
{
    const char* varname = var.name().c_str();

    fprintf(fp, "\tstream->writeFully(&__size_%s,4);\n", varname);
    if (var.nullAllowed()) {
        fprintf(fp, "\tif (%s != NULL) ", varname);
    } else {
        fprintf(fp, "\t");
    }
    if (var.writeExpression() != "") {
        fprintf(fp, "%s", var.writeExpression().c_str());
    } else {
        fprintf(fp, "stream->writeFully(%s, __size_%s)", varname, varname);
    }
    fprintf(fp, ";\n");
}
开发者ID:lcweik,项目名称:emulator,代码行数:17,代码来源:ApiGen.cpp


示例15: foreach

std::vector<std::map<size_t, int> > AnyPositionCnfCompress::createCounts(size_t &gndFactor, VarSet &superVarSet) {
	// create zero entries for each position
	map<long, map<size_t, int> > countMap;
	foreach (const dai::BipartiteGraph::Neighbor &tmpVar, _cfg.nbF(gndFactor)) {
		Var liftedVar = _varRepr[_varColorVec[tmpVar]];
		size_t pos = find(_cfg.factor(gndFactor).sigma().begin(), _cfg.factor(gndFactor).sigma().end(), tmpVar.iter) - _cfg.factor(gndFactor).sigma().begin();
		countMap[liftedVar.label()][pos] = 0;
	}

	vector<map<size_t, int> > counts;
	size_t posCount;
	size_t negCount;
	for (vector<Var>::const_iterator iter = superVarSet.begin(); iter < superVarSet.end(); iter++) {
		posCount = 0;
		negCount = 0;

		foreach(const dai::BipartiteGraph::Neighbor tmpFac, _cfg.nbV(_cfg.findVar(*iter))) {
			if (_facRepr[_facColorVec[tmpFac]] == gndFactor) {
				size_t pos = find(_cfg.factor(tmpFac).sigma().begin(), _cfg.factor(tmpFac).sigma().end(), tmpFac.dual) - _cfg.factor(tmpFac).sigma().begin();
				double res = log(_cfg.factor(tmpFac).states() - _zeroStates[tmpFac]) /  log(2);
				size_t nrPosLiterals = size_t(res);
				bool sign = (pos < nrPosLiterals);
				if (sign) {
					posCount++;
				} else {
					negCount++;
				}
			}
		}
		map<size_t, int>::iterator posIter=countMap[iter->label()].begin();

		if (posCount > 0) {
			posIter->second = posCount;
		}

		if (negCount > 0) {
			for (size_t j=0;j<posCount; j++, posIter++) {}
			posIter->second = negCount;
		}

		counts.push_back(countMap[iter->label()]);
	}

	return counts;
}
开发者ID:fhadiji,项目名称:liftandrelax,代码行数:45,代码来源:AnyPositionCnfCompress.cpp


示例16: getInTexCoord

void SpecularMapGLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
{
   // Get the texture coord.
   Var *texCoord = getInTexCoord( "out_texCoord", "vec2", true, componentList );

   // create texture var
   Var *specularMap = new Var;
   specularMap->setType( "sampler2D" );
   specularMap->setName( "specularMap" );
   specularMap->uniform = true;
   specularMap->sampler = true;
   specularMap->constNum = Var::getTexUnitNum();
   LangElement *texOp = new GenOp( "texture2D(@, @)", specularMap, texCoord );

   Var *specularColor = new Var( "specularColor", "vec4" );

   output = new GenOp( "   @ = @;\r\n", new DecOp( specularColor ), texOp );
}
开发者ID:Adrellias,项目名称:Torque3D-DaveWork,代码行数:18,代码来源:pixSpecularGLSL.cpp


示例17: QFile

void Var::importFromJsonFile(QString filePath)
{
	QFile* file = new QFile(filePath);
	if(!file->open(QIODevice::ReadOnly))
    {
        qDebug()<<"Var::Var(QString filePath) - path is incorrect"<<filePath;
    }
	QString json = file->readAll();
	QJsonDocument parser = QJsonDocument::fromJson(json.toUtf8());
	Var var = fromQVariant(parser.toVariant());
	setType(var.getType());
	if(var.getType()=="list")
		List=var.List;		
	if(var.getType()=="map")
		Map=var.Map;		
	if(var.getType()=="string")
		String=var.String;		
}
开发者ID:Aspenka,项目名称:SSD,代码行数:18,代码来源:var.cpp


示例18: testEraseRanges

void testEraseRanges(Var< IntSet > set, int nElems, int nTests)
{
	for (int i = 1; i < (int)sqrt(nTests); i++)
	{
		int elem = (int)((double) nElems * (rand() / (double)RAND_MAX)); 

		set.domain().insert(elem);
	}
	
	std::set<int> toErase;
	for (int i = 1; i <= nElems; i++)
	{
		toErase.insert(i);
	}
	
	for (int i = 1; i < (int)sqrt(nTests); i++)
	{
		/*
		int startPos = (int)((double) set.domain().possSize() * (rand() / (double)RAND_MAX));
		int finishPos = min((int)((double) (set.domain().possSize() - startPos) * (rand() / (double)RAND_MAX)),10);
		
		CurSetFD<int>::PIterator b = set.domain().beginPoss();
		
		while (startPos-- > 0)
			b++;
		
		CurSetFD<int>::PIterator start = b;
		
		while (finishPos-- > 0)
			b++;
		
		CurSetFD<int>::PIterator finish = b;
		*/
		
		int start = max(1,(int)((double) nElems * (rand() / (double)RAND_MAX)));
		int finish = min(start + min((int)((double) nElems * (rand() / (double)RAND_MAX)),(int)(nElems / sqrt(nTests))),nElems);
		
		std::set<int>::iterator b = toErase.find(start), e = toErase.find(finish);
		
		timer.resume();
		Detail::setEraseRange(set.domain(), b, e);
		timer.pause();
	}
}
开发者ID:marcovc,项目名称:casper,代码行数:44,代码来源:test.cpp


示例19: while

Var Var::fromXML(QXmlStreamReader& xml)
{
	while (xml.tokenType() != QXmlStreamReader::StartElement && !xml.atEnd() && !xml.hasError())
    {
		xml.readNext();
    }
	QString root = xml.name().toString();
	setParam("map",root);
	while (!(xml.tokenType() == QXmlStreamReader::EndElement && xml.name() == root) && !xml.atEnd() && !xml.hasError())
    {
        xml.readNext();
		if (xml.tokenType() == QXmlStreamReader::StartElement)
        {
            Var el;
			el.fromXML(xml);
			if(getType()=="map")
            {
                if(!Map.contains(el.getName()))
                {
                    Map.insert(el.getName(),el);
                }
				else
                {
                    setType("list");
					List<<Map.value(el.getName());
                }
            }
			if(getType()=="list")
            {
                List<<el;
            }
        }
		if (xml.tokenType() == QXmlStreamReader::Characters)
        {
            QString text=xml.text().toString();
			if(!text.startsWith('\n'))
            {
                setType("string");
				String = text;
            }
        }
    }
	return *this;
}
开发者ID:Aspenka,项目名称:SSD,代码行数:44,代码来源:var.cpp


示例20: AssertFatal

void ParallaxFeatGLSL::processPix(  Vector<ShaderComponent*> &componentList, 
											 const MaterialFeatureData &fd )
{
   AssertFatal( GFX->getPixelShaderVersion() >= 2.0, 
      "ParallaxFeatGLSL::processPix - We don't support SM 1.x!" );
	
   MultiLine *meta = new MultiLine;
	
   // Order matters... get this first!
   Var *texCoord = getInTexCoord( "texCoord", "vec2", true, componentList );
	
   ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
	
   // We need the negative tangent space view vector
   // as in parallax mapping we step towards the camera.
   Var *negViewTS = (Var*)LangElement::find( "negViewTS" );
   if ( !negViewTS )
   {
      Var *inNegViewTS = (Var*)LangElement::find( "outNegViewTS" );
      if ( !inNegViewTS )
      {
         inNegViewTS = connectComp->getElement( RT_TEXCOORD );
         inNegViewTS->setName( "outNegViewTS" );
         inNegViewTS->setStructName( "IN" );
         inNegViewTS->setType( "vec3" );
      }
		
      negViewTS = new Var( "negViewTS", "vec3" );
      meta->addStatement( new GenOp( "   @ = normalize( @ );\r\n", new DecOp( negViewTS ), inNegViewTS ) );
   }
	
   // Get the rest of our inputs.
   Var *parallaxInfo = _getUniformVar( "parallaxInfo", "float", cspPotentialPrimitive );
   Var *normalMap = getNormalMapTex();
	
   // Call the library function to do the rest.
   meta->addStatement( new GenOp( "   @.xy += parallaxOffset( @, @.xy, @, @ );\r\n", 
      texCoord, normalMap, texCoord, negViewTS, parallaxInfo ) );
   
   // TODO: Fix second UV maybe?
	
   output = meta;
}
开发者ID:fr1tz,项目名称:terminal-overload,代码行数:43,代码来源:bumpGLSL.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ VarDecl类代码示例发布时间:2022-05-31
下一篇:
C++ Values类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap