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


C++ X3DAttributes::getSFColor方法代码示例

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


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

示例1: startDirectionalLight

int OgreNodeHandler::startDirectionalLight(const X3DAttributes &attr) {
	Light* light = _sceneManager->createLight(createUniqueName(attr, "directionalLight"));
	light->setType(Ogre::Light::LT_DIRECTIONAL);

	// Get the X3D values;
	SFVec3f direction;
	SFColor color;

	int index = attr.getAttributeIndex(ID::direction);
	if (index != -1)
	{
		direction = attr.getSFVec3f(index);
	}
	else
		direction.z = -1;

	index = attr.getAttributeIndex(ID::color);
	if (index != -1)
	{
		color = attr.getSFColor(index);
	}
	else
		color.r = color.g = color.b = 1;

	index = attr.getAttributeIndex(ID::intensity);
	float intensity = (index == -1) ? 1 : attr.getSFFloat(index);

	index = attr.getAttributeIndex(ID::on);
	bool on = (index == -1) ? true : attr.getSFBool(index);

	// Set the Ogre values
	light->setDirection(direction.x, direction.y, direction.z);

	Ogre::ColourValue colourValue(color.r,  color.g, color.b);
	colourValue *= intensity;

	light->setDiffuseColour(colourValue);
	light->setSpecularColour(colourValue);
	light->setVisible(on);
	_nodeStack.top()->attachObject(light);  
	return 1;
}
开发者ID:151706061,项目名称:MEPP,代码行数:42,代码来源:OgreNodeHandler.cpp

示例2: startMaterial

    virtual int startMaterial(const X3DAttributes& attr)
    {
        testEvent(11, "start Material");
        int index = attr.getAttributeIndex(ID::diffuseColor);
        assert(index != -1);

        SFColor diffuseColor;
        attr.getSFColor(index, diffuseColor);
        assert(diffuseColor.r == 1.0);
        assert(diffuseColor.g == 0.0);
        assert(diffuseColor.b == 0.0);
        cout << "Diffuse Color is: " << diffuseColor.r << " " << diffuseColor.g << " " << diffuseColor.b << endl;

        index = attr.getAttributeIndex(ID::transparency);
        assert(index != -1);
        float transparency = attr.getSFFloat(index);
        assert(transparency == 0.1f);

        return CONTINUE;
    }
开发者ID:RobH616,项目名称:trunk,代码行数:20,代码来源:dist_test.cpp

示例3: startMaterial

int OgreNodeHandler::startMaterial(const X3DAttributes &attr) {
  std::cout << "Start Material" << std::endl; 
  if (!_currentMaterial.isNull())
  {
	  Pass* pass = _currentMaterial->getTechnique(0)->getPass(0);
	  int index = attr.getAttributeIndex(ID::ambientIntensity);
	  float ambientIntensity = (index == -1) ? 0.2f : attr.getSFFloat(index);
	  index = attr.getAttributeIndex(ID::transparency);
	  float transparency = (index == -1) ? 0.0f : attr.getSFFloat(index);
	  
	  SFColor diffuseColor;
	  index = attr.getAttributeIndex(ID::diffuseColor);
	  if (index != -1)
	  {
		  diffuseColor = attr.getSFColor(index);
	  }
	  else 
	  {
		  diffuseColor.r = diffuseColor.g = diffuseColor.b = 0.8;
	  }

	  SFColor specularColor;
	  index = attr.getAttributeIndex(ID::specularColor);
	  if (index != -1)
	  {
		  specularColor = attr.getSFColor(index);
	  }

  	  SFColor emissiveColor;    
	  index = attr.getAttributeIndex(ID::emissiveColor);
	  if (index != -1)
	  {
		  emissiveColor = attr.getSFColor(index);
	  }
	  
	  index = attr.getAttributeIndex(ID::shininess);
	  float shininess = (index == -1) ? 0.2f : attr.getSFFloat(index);
	  shininess = Math::Clamp(shininess * 128.0f, 0.0f, 128.0f);

	  pass->setAmbient(ambientIntensity * diffuseColor.r,
					   ambientIntensity * diffuseColor.g,
					   ambientIntensity * diffuseColor.b);
	  pass->setDiffuse(diffuseColor.r,
					   diffuseColor.g,
					   diffuseColor.b,
					   1.0f - transparency);
	  pass->setSpecular(specularColor.r,
					   specularColor.g,
					   specularColor.b,
					   1.0f - transparency);
	  
	  pass->setSelfIllumination(emissiveColor.r,
								emissiveColor.g,
								emissiveColor.b);

	  pass->setShininess( shininess );
      pass->setLightingEnabled(true);
  }

  return 1;
}
开发者ID:151706061,项目名称:MEPP,代码行数:61,代码来源:OgreNodeHandler.cpp


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