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

C++ X3DAttributes类代码示例

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

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



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

示例1:

int X3DXIOTNodeHandler::startTransform(const X3DAttributes &attr)
{
#ifdef _DEBUG
	std::cout << "Start Transform" << std::endl;
#endif
	
	// Get all the X3D tranformation data
	SFVec3f translation;
	SFRotation rotation;

	int index = attr.getAttributeIndex(ID::translation);
	if (index != -1)
	{
		attr.getSFVec3f(index,translation);
	}
	index = attr.getAttributeIndex(ID::rotation);
	if (index != -1)
	{
		attr.getSFRotation(index,rotation);
	}

	assert(m_currentLeaf);
	if (m_currentLeaf)
	{
		ccGLMatrix mat;
		mat.initFromParameters(rotation.angle,
								CCVector3(rotation.x,rotation.y,rotation.z),
								CCVector3(translation.x,translation.y,translation.z));
		m_currentLeaf->setGLTransformation(mat);
	}

	return CONTINUE;
}
开发者ID:imight,项目名称:trunk,代码行数:33,代码来源:X3DXIOTNodeHandler.cpp


示例2: createUniqueName

std::string OgreNodeHandler::createUniqueName(const X3DAttributes &attr, const std::string& prefix)
{
	if (attr.isDEF())
		return attr.getDEF();

	string result;
	result.append(prefix);
	result.append(StringConverter::toString(++_objCount));
	return result;
}
开发者ID:151706061,项目名称:MEPP,代码行数:10,代码来源:OgreNodeHandler.cpp


示例3: startColor

int OgreNodeHandler::startColor(const X3DAttributes &attr)
{
	if(!_currentGeometry)
		throw std::runtime_error("Color currently only supported for IndexedFaceSets");
	int index = attr.getAttributeIndex(ID::color);
	if (index != -1)
		_currentGeometry->setColors(attr.getMFColor(index));
	else
		throw std::runtime_error("No color given within Color node");
	return 1;
}
开发者ID:151706061,项目名称:MEPP,代码行数:11,代码来源:OgreNodeHandler.cpp


示例4: startNormal

int OgreNodeHandler::startNormal(const X3DAttributes &attr)
{
	if(!_currentGeometry)
		throw std::runtime_error("Normal currently only supported for IndexedFaceSets");
	int index = attr.getAttributeIndex(ID::vector);
	if (index != -1)
		_currentGeometry->setNormals(attr.getMFVec3f(index));
	else
		throw std::runtime_error("No points given within Coordinate node");
	return 1;
}
开发者ID:151706061,项目名称:MEPP,代码行数:11,代码来源:OgreNodeHandler.cpp


示例5: startShape

int OgreNodeHandler::startShape(const X3DAttributes &attr) {
  std::cout << "Start Shape" << std::endl;
  if (attr.isUSE()) {
	  _currentEntity = _sceneManager->getEntity(attr.getUSE())->clone(createUniqueName(attr, "shapeUSE"));
  } else  {
	  // We can not create a entity yet, because Ogre does not
	  // allow an entity without a mesh. So we create the entity as
	  // soon as we have a mesh
	  _shapeName = attr.isDEF() ? attr.getDEF() : createUniqueName(attr, "shape");
  }

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


示例6: startIndexedLineSet

int OgreNodeHandler::startIndexedLineSet(const X3DAttributes &attr) {
  
  _currentGeometry = new IndexedGeometry(createUniqueName(attr, "indexedLineSet"));

  int index = attr.getAttributeIndex(ID::coordIndex);
  if (index != -1)
	  _currentGeometry->setCoordIndex(attr.getMFInt32(index));

  index = attr.getAttributeIndex(ID::colorPerVertex);
  _currentGeometry->setColorPerVertex(index != -1 ? attr.getSFBool(index) : true);

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


示例7: startSphere

int OgreNodeHandler::startSphere(const X3DAttributes &attr) {
  std::cout << "Start Sphere\n";

  int index = attr.getAttributeIndex(ID::radius);
  float radius = index == -1 ? 1.0 : attr.getSFFloat(index);

  const string name = createUniqueName(attr, "sphere");
  GeomUtils::createSphere(name , radius, 20, 20, true, false);

  _currentMesh = MeshManager::getSingleton().getByName(name);
  _currentEntity = _sceneManager->createEntity(_shapeName, name);
  return 1;
}
开发者ID:151706061,项目名称:MEPP,代码行数:13,代码来源:OgreNodeHandler.cpp


示例8: startBox

    virtual int startBox(const X3DAttributes& attr)
    {
        testEvent(14, "start Box");
        int index = attr.getAttributeIndex(ID::size);
        assert(index != -1);

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


示例9: ccPointCloud

int X3DXIOTNodeHandler::startCoordinate(const X3DAttributes &attr)
{
	int index = attr.getAttributeIndex(ID::point);
	if (index == -1)
	{
		//TODO: warn user instead
		//throw std::runtime_error("No points given within Coordinate node");
		return SKIP_CHILDREN;
	}

	MFVec3f points;
	attr.getMFVec3f(index,points);

	unsigned count = points.size();
	if (count == 0)
		return SKIP_CHILDREN;

	ccPointCloud* cloud = new ccPointCloud(attr.isDEF() ? attr.getDEF().c_str() : 0);
	if (!cloud->reserve(count))
	{
		//not enough memory!
		delete cloud;
		return SKIP_CHILDREN;
	}

	for (MFVec3f::const_iterator it=points.begin(); it!=points.end(); ++it)
		cloud->addPoint(CCVector3(it->x,it->y,it->z));

	assert(m_currentLeaf);
	m_currentLeaf->addChild(cloud);

	//cloud = parent vertices?
	if (m_currentLeaf->isKindOf(CC_MESH))
	{
		ccGenericMesh* mesh = ccHObjectCaster::ToGenericMesh(m_currentLeaf);
		if (mesh->getAssociatedCloud()==0)
		{
			mesh->setAssociatedCloud(cloud);
			cloud->setVisible(false);
		}
	}

	m_currentLeaf = cloud;

	return CONTINUE;
}
开发者ID:markgenemei,项目名称:trunk,代码行数:46,代码来源:X3DXIOTNodeHandler.cpp


示例10: 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


示例11: startTransform

int OgreNodeHandler::startTransform(const X3DAttributes &attr) {
  std::cout << "Start Transform" << std::endl;
  // Get all the X3D tranformation data
  SFVec3f translation;
  SFRotation rotation;

  int index = attr.getAttributeIndex(ID::translation);
  if (index != -1)
  {
	  translation = attr.getSFVec3f(index);
  }
  index = attr.getAttributeIndex(ID::rotation);
  if (index != -1)
  {
	  rotation = attr.getSFRotation(index);
  }

  SceneNode* node = _nodeStack.top()->createChildSceneNode(createUniqueName(attr, "transform"));
  node->resetToInitialState();
  node->translate(translation.x, translation.y, translation.z);
  node->rotate(Vector3(rotation.x, rotation.y, rotation.z), Radian(rotation.angle));
  _nodeStack.push(node);
  return 1;
}
开发者ID:151706061,项目名称:MEPP,代码行数:24,代码来源:OgreNodeHandler.cpp


示例12: 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


示例13: startIndexedFaceSet

int OgreNodeHandler::startIndexedFaceSet(const X3DAttributes &attr) {
	std::cout << "Start IndexedFaceSet" << std::endl;
  
  _currentGeometry = new IndexedGeometry(createUniqueName(attr, "indexedFaceSet"));

  int index = attr.getAttributeIndex(ID::coordIndex);
  if (index != -1)
	  _currentGeometry->setCoordIndex(attr.getMFInt32(index));
  
  index = attr.getAttributeIndex(ID::normalIndex);
  if (index != -1)
	  _currentGeometry->setNormalIndex(attr.getMFInt32(index));

  index = attr.getAttributeIndex(ID::normalPerVertex);
  _currentGeometry->setNormalPerVertex(index != -1 ? attr.getSFBool(index) : true);


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


示例14: ccMesh

int X3DXIOTNodeHandler::startIndexedFaceSet(const X3DAttributes &attr)
{
	std::cout << "Start IndexedFaceSet" << std::endl;

	ccMesh* mesh = new ccMesh(0);
	unsigned realFaceNumber=0;

	if (attr.isDEF())
		mesh->setName(attr.getDEF().c_str());

	//Vertices indexes
	int vertIndex = attr.getAttributeIndex(ID::coordIndex);
	if (vertIndex != -1)
	{
		MFInt32 streamIndexes;
		attr.getMFInt32(vertIndex,streamIndexes);

		int triIndexes[3];
		int pos=0;
		for (MFInt32::const_iterator it = streamIndexes.begin(); it != streamIndexes.end(); ++it)
		{
			if (*it == -1) //end of polygon
			{
				if (pos<3)
				{
					//incomplete dataset?
					//TODO: warn user
				}
				pos = 0;
				++realFaceNumber;
			}
			else //new vertex index
			{
				if (pos<3)
				{
					triIndexes[pos]=*it;
				}
				else
				{
					//FIXME: simplistic fan triangulation (hum, hum)
					triIndexes[1]=triIndexes[2];
					triIndexes[2]=*it;
				}
				++pos;
			}

			//new face
			if (pos==3)
			{
				//we check that we are at the end of the polygon (we don't handle non triangular meshes yet!)
				if (it+1 == streamIndexes.end() || *(it+1)==-1)
				{
					//we must reserve some more space for storage!
					if (mesh->size() == mesh->maxSize())
					{
						if (!mesh->reserve(mesh->maxSize() + 100))
						{
							delete mesh;
							return ABORT; //not enough memory!
						}
					}
					mesh->addTriangle(triIndexes[0],triIndexes[1],triIndexes[2]);
				}
				else
				{
					//TODO: we don't handle non triangle faces yet!
				}
			}
		}

		if (mesh->size() < mesh->maxSize())
		{
			//unhandled type of mesh
			if (mesh->size()==0)
			{
				delete mesh;
				return SKIP_CHILDREN;
			}
			mesh->resize(mesh->size());
		}
	}

	//Normals (per face)
	int normIndex = attr.getAttributeIndex(ID::normalIndex);
	if (normIndex != -1)
	{
		//per-triangle normals!
		if (mesh->size() == realFaceNumber)
		{
			if (mesh->reservePerTriangleNormalIndexes())
			{
				MFInt32 perFaceNormIndexes;
				attr.getMFInt32(normIndex,perFaceNormIndexes);
				for (unsigned i=0;i<perFaceNormIndexes.size();++i)
					mesh->addTriangleNormalIndexes(i,i,i);

				mesh->showTriNorms(true);
			}
			else
			{
//.........这里部分代码省略.........
开发者ID:imight,项目名称:trunk,代码行数:101,代码来源:X3DXIOTNodeHandler.cpp


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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ X3aResultList类代码示例发布时间:2022-05-31
下一篇:
C++ X类代码示例发布时间: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