Esempio n. 1
0
        //no fog at the moment
        //protected void processFog(XmlElement XMLNode)
        //{
        //    // Process attributes
        //    float linearStart = getAttribReal(XMLNode, "linearStart", 0.0f);
        //    float linearEnd = getAttribReal(XMLNode, "linearEnd", 1.0f);
        //    FogMode mode = FogMode.FOG_NONE;
        //    String sMode = getAttrib(XMLNode, "mode");
        //    // only linear atm
        //    if (sMode == "none")
        //        mode = FogMode.FOG_NONE;
        //    else if (sMode == "exp")
        //        mode = FogMode.FOG_EXP;
        //    else if (sMode == "exp2")
        //        mode = FogMode.FOG_EXP2;
        //    else if (sMode == "linear")
        //        mode = FogMode.FOG_LINEAR;
        //    XmlElement pElement;
        //    // Process colourDiffuse (?)
        //    ColourValue colourDiffuse = ColourValue.White;
        //    pElement = (XmlElement)XMLNode.SelectSingleNode("colourDiffuse");
        //    if (pElement != null)
        //        colourDiffuse = parseColour(pElement);
        //    // Setup the fog
        //    mSceneMgr.SetFog(mode, colourDiffuse, 0.001f, linearStart, linearEnd);
        //}
        // no processLight at the moment
        //protected void processLight(XmlElement XMLNode, SceneNode pParent)
        //{
        //    // Process attributes
        //    String name = getAttrib(XMLNode, "name");
        //    // Create the light
        //    Light pLight = mSceneMgr.CreateLight(name);
        //    if (pParent != null)
        //        pParent.AttachObject(pLight);
        //    String sValue = getAttrib(XMLNode, "type");
        //    if (sValue == "point")
        //        pLight.Type = Light.LightTypes.LT_POINT;
        //    else if (sValue == "directional")
        //        pLight.Type = Light.LightTypes.LT_DIRECTIONAL;
        //    else if (sValue == "spotLight")
        //        pLight.Type = Light.LightTypes.LT_SPOTLIGHT;
        //    // only set if Lamp is Spotlight (Blender)
        //    bool castShadow = true;
        //    if (XMLNode.HasAttribute("castShadow"))
        //    {
        //        castShadow = getAttribBool(XMLNode, "castShadow", true);
        //    }
        //    else if (XMLNode.HasAttribute("castShadows"))
        //    {
        //        castShadow = getAttribBool(XMLNode, "castShadows", true);
        //    }
        //    pLight.CastShadows = castShadow;
        //    XmlElement pElement;
        //    // Process normal (?)
        //    pElement = (XmlElement)XMLNode.SelectSingleNode("normal");
        //    if (pElement != null)
        //        pLight.Direction = parseVector3(pElement);
        //    // Process colourDiffuse (?)
        //    pElement = (XmlElement)XMLNode.SelectSingleNode("colourDiffuse");
        //    if (pElement != null)
        //        pLight.DiffuseColour = parseColour(pElement);
        //    // Process colourSpecular (?)
        //    pElement = (XmlElement)XMLNode.SelectSingleNode("colourSpecular");
        //    if (pElement != null)
        //        pLight.SpecularColour = parseColour(pElement);
        //    // Process lightRange (?)
        //    pElement = (XmlElement)XMLNode.SelectSingleNode("lightRange");
        //    if (pElement != null)
        //        processLightRange(pElement, pLight);
        //    // Process lightAttenuation (?)
        //    pElement = (XmlElement)XMLNode.SelectSingleNode("lightAttenuation");
        //    if (pElement != null)
        //        processLightAttenuation(pElement, pLight);
        //}
        //protected void processLightAttenuation(XmlElement XMLNode, Mogre.Light pLight)
        //{
        //    // Process attributes
        //    float range = getAttribReal(XMLNode, "range");
        //    float constant = getAttribReal(XMLNode, "constant");
        //    float linear = getAttribReal(XMLNode, "linear");
        //    float quadratic = getAttribReal(XMLNode, "quadratic");
        //    // Setup the light attenuation
        //    pLight.SetAttenuation(range, constant, linear, quadratic);
        //}
        //protected void processLightRange(XmlElement XMLNode, Mogre.Light pLight)
        //{
        //    // Process attributes
        //    float inner = getAttribReal(XMLNode, "inner");
        //    float outer = getAttribReal(XMLNode, "outer");
        //    float falloff = getAttribReal(XMLNode, "falloff", 1.0f);
        //    // Setup the light range
        //    pLight.SetSpotlightRange(new Radian(inner), new Radian(outer), falloff);
        //}
        protected void processNode(XmlElement XMLNode, SceneNode pParent)
        {
            // Construct the node's name
            String name = m_sPrependNode + getAttrib(XMLNode, "name");

            // Create the scene node
            SceneNode pNode;
            if (name.Length == 0)
            {
                // Let Ogre choose the name
                if (pParent != null)
                    pNode = pParent.CreateChildSceneNode();
                else
                    pNode = mAttachNode.CreateChildSceneNode();
            }
            else
            {
                // Provide the name
                if (pParent != null)
                    pNode = pParent.CreateChildSceneNode(name);
                else
                    pNode = mAttachNode.CreateChildSceneNode(name);
            }

            // Process other attributes
            XmlElement pElement;

            // Process position (?)
            pElement = (XmlElement)XMLNode.SelectSingleNode("position");
            if (pElement != null)
            {
                pNode.Position = parseVector3(pElement);
                pNode.SetInitialState();
            }

            // Process quaternion (?)
            pElement = (XmlElement)XMLNode.SelectSingleNode("quaternion");
            if (pElement != null)
            {
                pNode.Orientation = parseQuaternion(pElement);
                pNode.SetInitialState();
            }

            // Process rotation (?)
            pElement = (XmlElement)XMLNode.SelectSingleNode("rotation");
            if (pElement != null)
            {
                pNode.Orientation = parseRotation(pElement);
                pNode.SetInitialState();
            }

            // Process scale (?)
            pElement = (XmlElement)XMLNode.SelectSingleNode("scale");
            if (pElement != null)
            {
                pNode.Scale = parseVector3(pElement);
                pNode.SetInitialState();
            }

            // Process entity (*)
            pElement = (XmlElement)XMLNode.SelectSingleNode("entity");
            if (pElement != null)
            {
                processEntity(pElement, pNode);
            }

            // Process light (*)
            pElement = (XmlElement)XMLNode.SelectSingleNode("light");
            //if (pElement != null)
            //{
            //    processLight(pElement, pNode);
            //}

            // Process plane (*)
            pElement = (XmlElement)XMLNode.SelectSingleNode("plane");
            while (pElement != null)
            {
                processPlane(pElement, pNode);
                pElement = (XmlElement)pElement.NextSibling;
            }

            // Process camera (*)
            pElement = (XmlElement)XMLNode.SelectSingleNode("camera");
            if (pElement != null)
            {
                processCamera(pElement, pNode);
            }

            // Process userDataReference (?)
            pElement = (XmlElement)XMLNode.SelectSingleNode("userData");
            if (pElement != null)
                processUserDataReference(pElement, pNode);

            // Process childnodes
            pElement = (XmlElement)XMLNode.SelectSingleNode("node");
            while (pElement != null)
            {
                processNode(pElement, pNode);
                pElement = (XmlElement)pElement.NextSibling;
            }
        }