Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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;
}