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