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; }
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; }
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; }