Esempio n. 1
0
        public override ValueSpecification createValueFromString(string str)
        {
            ValueSpecification valueSpec = null;

            if (type == "real" || type == "double")
            {
                valueSpec = new LiteralReal(str);
            }
            else if (type == "integer")
            {
                valueSpec = new LiteralInteger(str);
            }
            else if (type == "string")
            {
                valueSpec = new LiteralString(str);
            }
            else if (type == "boolean")
            {
                valueSpec = new LiteralBoolean(str);
            }

            /*else if (type =="color")
             *  valueSpec = new Color(str);
             * else if (type =="Vector3")
             *  valueSpec = new Vector3(str);*/
            else if (type == "rotation")
            {
                valueSpec = new RotationVector(str);
            }
            else if (type == "shape")
            {
                //valueSpec = (UnityShapeSpecification)ScriptableObject.CreateInstance("UnityShapeSpecification");
                //((UnityShapeSpecification)valueSpec).instantiate(str);
            }
            else if (type == "point")
            {
                //valueSpec = (UnityPointSpecification)ScriptableObject.CreateInstance("UnityPointSpecification");
                //((UnityPointSpecification)valueSpec).instantiate(str);
            }

            /*else if (type =="path")
             *  valueSpec = new PathSpecification(str);
             * else if (type =="sound")
             *  valueSpec = new UnitySoundSpecification(str);
             * else if (type =="animation")
             *  valueSpec = new UnityAnimationSpecification(str);*/
            else
            {
                Console.WriteLine("Default : value is string");
                valueSpec = new LiteralString(str);
            }
            return(valueSpec);
        }
 public override ValueSpecification createValueFromString(string str)
 {
     ValueSpecification valueSpec = null;
     if (type == "real" || type == "double" || type == "float")
     {
         valueSpec = new LiteralReal(str);
     }
     else if (type == "integer")
     {
         valueSpec = new LiteralInteger(str);
     }
     else if (type == "string")
     {
         valueSpec = new LiteralString(str);
     }
     else if (type == "boolean")
     {
         valueSpec = new LiteralBoolean(str);
     }
     /*else if (type =="color")
         valueSpec = new Color(str);
     else if (type =="Vector3")
         valueSpec = new Vector3(str);*/
     else if (type == "rotation")
     {
         valueSpec = new RotationVector(str);
     }
     else if (type == "shape")
     {
         //valueSpec = (UnityShapeSpecification)ScriptableObject.CreateInstance("UnityShapeSpecification");
         //((UnityShapeSpecification)valueSpec).instantiate(str);
     }
     else if (type == "point")
     {
         //valueSpec = (UnityPointSpecification)ScriptableObject.CreateInstance("UnityPointSpecification");
         //((UnityPointSpecification)valueSpec).instantiate(str);
     }
     /*else if (type =="path")
         valueSpec = new PathSpecification(str);
     else if (type =="sound")
         valueSpec = new UnitySoundSpecification(str);
     else if (type =="animation")
         valueSpec = new UnityAnimationSpecification(str);*/
     else
     {
         Console.WriteLine("Default : value is string");
         valueSpec = new LiteralString(str);
     }
     return valueSpec;
 }
Esempio n. 3
0
        protected void _readEntity(XElement node, Entity entity)
        {
            if (entity == null) return;

            //Debug.Log(" ------- > Reading Entity : " + entity.getFullName());

            Vector3 scaleFactor = new Vector3(1, 1, 1);
            //entity.setParent(entity.getParent());
            //point = entity.getReferentialPoint();

            foreach (XElement child in node.Elements())
            {
                if (child.Name.LocalName == "Entity" || child.Name.LocalName == "Area")
                {
                    Entity instance = _createEntity(child, entity);
                    //Debug.Log( "Reading Entity : " + child.Name );
                }
                else if (child.Name.LocalName == "Human")
                {
                    VirtualHuman human = _createHuman(child);
                    //if (human != null)
                        //agentPlateform.addAgent(human);
                }
                else if (child.Name.LocalName == "Organisation")
                {
                    OrganisationalEntity org = _createOrganisation(child);
                    agentPlateform.Organisations.Add(org);
                }
                else if (child.Name.LocalName == "Position" || child.Name.LocalName == "Location")
                {
                    Vector3 localPosition = new Vector3(0, 0, 0);
                    /*
                    XAttribute attr = (XAttribute) child.Attribute("x");
                    if(attr!=null) localPosition.x = float.Parse(attr.Value);

                    attr = (XAttribute) child.Attribute("y");
                    if(attr!=null) localPosition.y = float.Parse(attr.Value);

                    attr = (XAttribute) child.Attribute("z");
                    if(attr!=null) localPosition.z = float.Parse(attr.Value);
                    */
                    //Debug.Log( "Reading Position : " + child.Name );
                    entity.setLocalPosition(localPosition);
                    //Debug.Log( "Reading Position : " + child.Name );
                }
                else if (child.Name.LocalName == "Orientation")
                {
                    XAttribute angle = (XAttribute)child.Attribute("angle");
                    if (angle != null)
                    {
                        RotationVector rotationAngle = new RotationVector(0, 0, 0, 0);

                        XAttribute attr = (XAttribute)child.Attribute("x");
                        if (attr != null) rotationAngle.x = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("y");
                        if (attr != null) rotationAngle.y = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("z");
                        if (attr != null) rotationAngle.z = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("angle");
                        if (attr != null) rotationAngle.angle = float.Parse(attr.Value);

                        //Debug.Log( "Reading Rotation : " + child.Name );
                        entity.setLocalRotation(rotationAngle);
                        //Debug.Log( "Reading Rotation : " + child.Name );
                    }
                    else
                    {
                        Vector3 localPosition = new Vector3(0, 0, 0);

                        XAttribute attr = (XAttribute)child.Attribute("x");
                        if (attr != null) localPosition.x = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("y");
                        if (attr != null) localPosition.y = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("z");
                        if (attr != null) localPosition.z = float.Parse(attr.Value);

                        //Debug.Log( "Reading Orientation : " + child.Name );
                        entity.setLocalOrientation(localPosition);
                        //Debug.Log( "Reading Orientation : " + child.Name );
                    }
                }
                else if (child.Name.LocalName == "Topological")
                {
                    string name = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) name = attr.Value;

                    XElement posNode = null, oriNode = null;

                    foreach (XElement currentNode in child.Elements())
                    {
                        if (currentNode.Name.LocalName == "Position")
                            posNode = currentNode;
                        if (currentNode.Name.LocalName == "Orientation")
                            oriNode = currentNode;
                    }

                    Vector3 pos = new Vector3(0, 0, 0);

                    attr = (XAttribute)posNode.Attribute("x");
                    if (attr != null) pos.x = float.Parse(attr.Value);

                    attr = (XAttribute)posNode.Attribute("y");
                    if (attr != null) pos.y = float.Parse(attr.Value);

                    attr = (XAttribute)posNode.Attribute("z");
                    if (attr != null) pos.z = float.Parse(attr.Value);

                    //PointSpecification point = new PointSpecification();

                    //regarder creation de point, anim et autre par la VRApplication dans mascaret

                    //((UnityPointSpecification)point).instantiate(pos,(RotationVector)ScriptableObject.CreateInstance("RotationVector"));
                    //point.Parent=entity.ReferentialPoint;
                    //point.setLocalPosition(pos);
                    if (oriNode != null)
                    {
                        attr = (XAttribute)oriNode.Attribute("angle");
                        if (attr != null)
                        {
                            RotationVector rotationAngle = new RotationVector(0, 0, 0, 0);

                            XAttribute attr2 = (XAttribute)oriNode.Attribute("x");
                            if (attr2 != null) rotationAngle.x = float.Parse(attr2.Value);

                            attr2 = (XAttribute)oriNode.Attribute("y");
                            if (attr2 != null) rotationAngle.y = float.Parse(attr2.Value);

                            attr2 = (XAttribute)oriNode.Attribute("z");
                            if (attr2 != null) rotationAngle.z = float.Parse(attr2.Value);

                            attr2 = (XAttribute)oriNode.Attribute("angle");
                            if (attr2 != null) rotationAngle.angle = float.Parse(attr2.Value);

                            //point.setLocalRotation(rotationAngle);
                        }
                        else
                        {
                            Vector3 localPosition = new Vector3(0, 0, 0);

                            XAttribute attr2 = (XAttribute)child.Attribute("x");
                            if (attr2 != null) localPosition.x = float.Parse(attr2.Value);

                            attr2 = (XAttribute)child.Attribute("y");
                            if (attr2 != null) localPosition.y = float.Parse(attr2.Value);

                            attr2 = (XAttribute)child.Attribute("z");
                            if (attr2 != null) localPosition.z = float.Parse(attr2.Value);

                            //point.setLocalOrientation(localPosition);
                        }
                    }
                    //entity.getProperty(name).addValue(point);
                }
                else if (child.Name.LocalName == "Viewpoint")
                {
                    //Debug.Log( "Reading Viewpoint : " + child.Name );
                    string name = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) name = attr.Value;

                    XElement posNode = null, oriNode = null;

                    foreach (XElement currentNode in child.Elements())
                    {
                        if (currentNode.Name.LocalName == "Position")
                            posNode = currentNode;
                        if (currentNode.Name.LocalName == "Orientation")
                            oriNode = currentNode;
                    }

                    Vector3 pos = new Vector3(0, 0, 0);
                    /*
                    attr = (XAttribute) posNode.Attribute("x");
                    if(attr!=null) pos.x = float.Parse(attr.Value);

                    attr = (XAttribute) posNode.Attribute("y");
                    if(attr!=null) pos.y = float.Parse(attr.Value);

                    attr = (XAttribute) posNode.Attribute("z");
                    if(attr!=null) pos.z = float.Parse(attr.Value);
                    */
                    //PointSpecification viewPoint=(UnityPointSpecification)ScriptableObject.CreateInstance("UnityPointSpecification");
                    //((UnityPointSpecification)viewPoint).instantiate(pos, (RotationVector)ScriptableObject.CreateInstance("RotationVector"));
                    //viewPoint.Parent=entity.ReferentialPoint;

                    attr = (XAttribute)oriNode.Attribute("angle");
                    if (attr != null)
                    {
                        RotationVector rotationAngle = new RotationVector(0, 0, 0, 0);

                        XAttribute attr2 = (XAttribute)oriNode.Attribute("x");
                        if (attr2 != null) rotationAngle.x = float.Parse(attr2.Value);

                        attr2 = (XAttribute)oriNode.Attribute("y");
                        if (attr2 != null) rotationAngle.y = float.Parse(attr2.Value);

                        attr2 = (XAttribute)oriNode.Attribute("z");
                        if (attr2 != null) rotationAngle.z = float.Parse(attr2.Value);

                        attr2 = (XAttribute)oriNode.Attribute("angle");
                        if (attr2 != null) rotationAngle.angle = float.Parse(attr2.Value);

                        //viewPoint.setLocalRotation(rotationAngle);
                    }
                    else
                    {
                        Vector3 localPosition = new Vector3(0, 0, 0);

                        XAttribute attr2 = (XAttribute)oriNode.Attribute("x");
                        if (attr2 != null) localPosition.x = float.Parse(attr2.Value);

                        attr2 = (XAttribute)oriNode.Attribute("y");
                        if (attr2 != null) localPosition.y = float.Parse(attr2.Value);

                        attr2 = (XAttribute)oriNode.Attribute("z");
                        if (attr2 != null) localPosition.z = float.Parse(attr2.Value);

                        //viewPoint.setLocalOrientation(localPosition);
                    }
                    //Debug.Log(entity.name );
                    //entity.ViewPoints.Add(name,viewPoint);
                    //Debug.Log( "Reading Viewpoint : " + child.Name );
                }
                else if (child.Name.LocalName == "OrientationLC")
                {
                    ////Debug.Log( "Reading OrientationLC : " + child.Name );
                    XAttribute attr = (XAttribute)child.Attribute("angle");
                    if (attr != null)
                    {
                        RotationVector rotationAngle = new RotationVector(0, 0, 0, 0);

                        XAttribute attr2 = (XAttribute)child.Attribute("x");
                        if (attr2 != null) rotationAngle.x = float.Parse(attr2.Value);

                        attr2 = (XAttribute)child.Attribute("y");
                        if (attr2 != null) rotationAngle.y = float.Parse(attr2.Value);

                        attr2 = (XAttribute)child.Attribute("z");
                        if (attr2 != null) rotationAngle.z = float.Parse(attr2.Value);

                        attr2 = (XAttribute)child.Attribute("angle");
                        if (attr2 != null) rotationAngle.angle = float.Parse(attr2.Value);

                        entity.setLocalRotation(rotationAngle);
                    }
                    else
                    {
                        Vector3 localPosition = new Vector3(0, 0, 0);

                        XAttribute attr2 = (XAttribute)child.Attribute("x");
                        if (attr != null) localPosition.x = float.Parse(attr2.Value);

                        attr2 = (XAttribute)child.Attribute("y");
                        if (attr2 != null) localPosition.y = float.Parse(attr2.Value);

                        attr2 = (XAttribute)child.Attribute("z");
                        if (attr2 != null) localPosition.z = float.Parse(attr2.Value);

                        entity.setLocalOrientation(localPosition);
                    }
                    Vector3 ori = entity.getLocalOrientation();

                    //x = ori.x; y = ori.y; z = ori.z;
                    // TODO: ATTENTION problème, ici c'est un setGlobalOrientation sans doute
                    PointSpecification parentPoint = entity.Parent.ReferentialPoint;
                    parentPoint.localToGlobalOrientation(ori);
                    //Vector3 ori2(x,y,z);
                    entity.setLocalOrientation(ori);
                    ////Debug.Log( "Reading OrientationLC : " + child.Name );
                }

                else if (child.Name.LocalName == "Shape")
                {
                    //Debug.Log( "Reading Shape : " + child.Name );
                    string url = "";

                    XAttribute attr = (XAttribute)child.Attribute("url");
                    if (attr != null) url = attr.Value;
                    else
                    {
                        attr = (XAttribute)child.Attribute("value");
                        if (attr != null) url = attr.Value;
                    }
                    //Debug.Log ("==== Shape = " + url);

                    bool movable = false;
                    attr = (XAttribute)child.Attribute("movable");
                    if (attr != null)
                    {
                        movable = Boolean.Parse(attr.Value);
                    }
                    bool recursive = false;
                    attr = (XAttribute)child.Attribute("recursive");
                    if (attr != null)
                    {
                        recursive = Boolean.Parse(attr.Value);
                    }

                    /*
                     url += basedir;

                    if(url.Length==0)
                    {
                        attr = (XAttribute) child.Attribute("url");
                        if(attr!=null)
                            Debug.Log( "Fichier " + attr.Value + " non trouvé pour l'entity "+ entity.name);
                    }
                    */

                    string shader = "";
                    attr = (XAttribute)child.Attribute("shader");
                    if (attr != null)
                    {
                        shader = attr.Value;
                    }
                    string shapeName = "shape";
                    attr = (XAttribute)child.Attribute("name");
                    if (attr != null)
                    {
                        shapeName = attr.Value;
                    }
                    ShapeSpecification specif = MascaretApplication.Instance.VRComponentFactory.createShape(entity.name + "_" + shapeName, url, movable, recursive, shader);
                    //entity.getProperty(shapeName).addValue(specif);
                    entity.setActiveShape(shapeName);

                    specif.setEntity(entity);
                    entity.ActiveShape = specif;

                }

                else if (child.Name.LocalName == "Shapes")
                {
                    bool movable = false;
                    XAttribute attr = (XAttribute)child.Attribute("movable");
                    if (attr != null)
                    {
                        movable = Boolean.Parse(attr.Value);
                    }
                    bool recursive = false;
                    attr = (XAttribute)child.Attribute("recursive");
                    if (attr != null)
                    {
                        recursive = Boolean.Parse(attr.Value);
                    }

                    List<string> urls = new List<string>();
                    List<double> distances = new List<double>();

                    foreach (XElement shapeNode in child.Elements())
                    {
                        if (shapeNode.Name.LocalName == "Shape")
                        {
                            string url = "";
                            attr = (XAttribute)shapeNode.Attribute("url");
                            if (attr != null) url = attr.Value;

                            url += basedir;

                            if (url.Length == 0)
                            {
                            }

                            urls.Add(url);
                            double dist = 0;
                            attr = (XAttribute)shapeNode.Attribute("dist");
                            if (attr != null)
                            {
                                dist = Double.Parse(attr.Value);
                            }
                            distances.Add(dist);
                        }
                    }
                    string shapeName = "shape";
                    attr = (XAttribute)child.Attribute("name");
                    if (attr != null)
                    {
                        shapeName = attr.Value;
                    }
                    //ShapeSpecification specif=(UnityShapeSpecification)ScriptableObject.CreateInstance("UnityShapeSpecification");
                    //specif.instantiate(shapeName,distances,urls,movable,recursive,"");
                    //entity.getProperty(shapeName).addValue(specif);
                    //entity.set_DEP_current(specif);
                    //entity.setActiveShape(shapeName);
                }
                else if (child.Name.LocalName == "Scale")
                {
                    XAttribute attr = (XAttribute)child.Attribute("sx");
                    if (attr != null) scaleFactor.x = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("sy");
                    if (attr != null) scaleFactor.y = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("sz");
                    if (attr != null) scaleFactor.z = float.Parse(attr.Value);

                }
                else if (child.Name.LocalName == "Animation")
                {
                    string name = "";
                    string file = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) name = attr.Value;

                    attr = (XAttribute)child.Attribute("url");
                    if (attr != null) file = attr.Value + basedir;

                    //AnimationSpecification animation = (UnityAnimationSpecification)ScriptableObject.CreateInstance("UnityAnimationSpecification");
                    //animation.instantiate(name, file);
                    //entity.getProperty(name).addValue(animation);
                }
                else if (child.Name.LocalName == "Sound")
                {
                    string name = "";
                    string file = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) name = attr.Value;

                    attr = (XAttribute)child.Attribute("url");
                    if (attr != null) file = attr.Value + basedir;

                    double gain = 1.0;
                    double minDist = 1.0;
                    double maxDist = 100.0;

                    attr = (XAttribute)child.Attribute("gain");
                    if (attr != null) gain = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("minDistance");
                    if (attr != null) minDist = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("maxDistance");
                    if (attr != null) maxDist = float.Parse(attr.Value);

                    //SoundSpecification sound = (UnitySoundSpecification)ScriptableObject.CreateInstance("UnitySoundSpecification");
                    //((UnitySoundSpecification)sound).instantiate(name, file, gain,minDist,maxDist, false);
                    //entity.getProperty(name).addValue(sound);
                    //sound.attachTo(entity.ReferentialPoint);
                }
               /* else if (child.Name.LocalName == "Inline")
                {
                    XDocument parser = null;
                    try
                    {

                        XAttribute attr = (XAttribute)child.Attribute("url");
                        if (attr != null) parser = XDocument.Load(attr.Value + basedir);
                        _readEntity(parser.Root, entity);
                    }
                    catch (FileLoadException e)
                    {
                    }
                }*/
                else if ((child.Name.LocalName == "Attribute") || (child.Name.LocalName == "Relation"))
                {
                    Relation r = new Relation();
                    r.e = entity;

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) r.property = attr.Value;

                    attr = (XAttribute)child.Attribute("value");
                    if (attr != null) r.rValue = attr.Value;
                    relations.Add(r);
                }
                else if (child.Name.LocalName == "InternalOrientationAxe")
                {
                    //TODO: Pourquoi non utilisé ?
                    /*Axe _front = AxeFromNodeProperty(child, "frontAxe");
                    Axe _left = AxeFromNodeProperty(child, "leftAxe");
                    Axe _above = AxeFromNodeProperty(child, "aboveAxe");*/
                }
                else if (child.Name.LocalName == "InternalOrientationVector")
                {
                    //TODO:
                }
                else if (child.Name.LocalName == "State")
                {
                    _initializeStateMachine(child, entity);
                }

            }
            if (entity.ActiveShape != null)
            {
                entity.ActiveShape.setScale(scaleFactor);
            }
        }
Esempio n. 4
0
        protected void _readGeometryEntity(XElement node, Entity entity)
        {
            Vector3 scaleFactor = new Vector3(1, 1, 1);
            entity.setParent(entity.Parent);
            PointSpecification point;
            point = entity.ReferentialPoint;

            foreach (XElement child in node.Elements())
            {
                if (child.Name.LocalName == "Position" || child.Name.LocalName == "Location")
                {

                    XAttribute attr = (XAttribute)child.Attribute("entity");
                    if (attr != null)
                    {
                        string entityName = attr.Value;
                        //InstanceSpecification instance = MascaretApplication.Instance.getEnvironment().getInstance(entityName);
                        InstanceSpecification instance = environment.getInstance(entityName);
                        if (instance != null)
                        {
                            Entity entPos = instance as Entity;
                            if (entPos != null)
                            {
                                entPos.addChild(entity);

                                attr = (XAttribute)child.Attribute("point");
                                if (attr != null)
                                {
                                    string pointName = attr.Value;
                                    PointSpecification pt = entPos.getPoint(pointName);
                                    if (pt != null)
                                    {
                                        Vector3 pos = pt.getGlobalPosition();
                                        Vector3 ori = pt.getGlobalOrientation();
                                        point.setGlobalPosition(pos);
                                        point.setGlobalOrientation(ori);
                                    }

                                }
                                else
                                {
                                    Vector3 pos = entPos.getGlobalPosition();
                                    Vector3 ori = entPos.getGlobalOrientation();
                                    point.setGlobalPosition(pos);
                                    point.setGlobalOrientation(ori);
                                }
                            }

                        }

                    }
                    else
                    {/*
                    Vector3 localPosition = new Vector3(0,0,0);
                    attr = (XAttribute) child.Attribute("x");
                    if(attr!=null) localPosition.x = float.Parse(attr.Value);

                    attr = (XAttribute) child.Attribute("y");
                    if(attr!=null) localPosition.y = float.Parse(attr.Value);

                    attr = (XAttribute) child.Attribute("z");
                    if(attr!=null) localPosition.z = float.Parse(attr.Value);

                    point.setLocalPosition(localPosition);
                    */
                    }
                }
                else if (child.Name.LocalName == "Orientation")
                {

                    XAttribute attr = (XAttribute)child.Attribute("angle");
                    if (attr != null)
                    {
                        RotationVector rotationAngle = new RotationVector(0, 0, 0, 0);

                        attr = (XAttribute)child.Attribute("x");
                        if (attr != null) rotationAngle.x = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("y");
                        if (attr != null) rotationAngle.y = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("z");
                        if (attr != null) rotationAngle.z = float.Parse(attr.Value);

                        attr = (XAttribute)child.Attribute("angle");
                        if (attr != null) rotationAngle.angle = float.Parse(attr.Value);

                        point.setLocalRotation(rotationAngle);
                    }
                    else
                    {
                        /*
                        Vector3 localPosition = new Vector3(0,0,0);
                        attr = (XAttribute) child.Attribute("x");
                        if(attr!=null) localPosition.x = float.Parse(attr.Value);

                        attr = (XAttribute) child.Attribute("y");
                        if(attr!=null) localPosition.y = float.Parse(attr.Value);

                        attr = (XAttribute) child.Attribute("z");
                        if(attr!=null) localPosition.z = float.Parse(attr.Value);

                        point.setLocalOrientation(localPosition);
                        */
                    }
                }

                else if (child.Name.LocalName == "Shape")
                {
                    string url = "";

                    XAttribute attr = (XAttribute)child.Attribute("url");
                    if (attr != null) url = attr.Value;

                    bool movable = false;
                    attr = (XAttribute)child.Attribute("movable");
                    if (attr != null)
                    {
                        movable = Boolean.Parse(attr.Value);
                    }
                    bool recursive = false;
                    attr = (XAttribute)child.Attribute("recursive");
                    if (attr != null)
                    {
                        recursive = Boolean.Parse(attr.Value);
                    }

                    //url += basedir;

                    string shader = "";
                    attr = (XAttribute)child.Attribute("shader");
                    if (attr != null)
                    {
                        shader = attr.Value;
                    }
                    string name = "shape";
                    attr = (XAttribute)child.Attribute("name");
                    if (attr != null)
                    {
                        name = attr.Value;
                    }
                    ShapeSpecification specif = MascaretApplication.Instance.VRComponentFactory.createShape(entity.name, url, movable, recursive, shader);
                    //ShapeSpecification specif = MascaretApplication.Instance.VRComponentFactory.createShape(entity.name + "_" + name, url, movable, recursive, shader);
                    //entity.getProperty(shapeName).addValue(specif);
                    entity.setActiveShape(name);

                    specif.setEntity(entity);
                    entity.ActiveShape = specif;
                }
                else if (child.Name.LocalName == "Shapes")
                {
                    bool movable = false;
                    XAttribute attr = (XAttribute)child.Attribute("movable");
                    if (attr != null)
                    {
                        movable = Boolean.Parse(attr.Value);
                    }
                    bool recursive = false;
                    attr = (XAttribute)child.Attribute("recursive");
                    if (attr != null)
                    {
                        recursive = Boolean.Parse(attr.Value);
                    }

                    List<string> urls = new List<string>();
                    List<double> distances = new List<double>();

                    foreach (XElement shapeNode in child.Elements())
                    {
                        if (shapeNode.Name.LocalName == "Shape")
                        {
                            string url = "";
                            attr = (XAttribute)shapeNode.Attribute("url");
                            if (attr != null) url = attr.Value;

                            url += basedir;

                            if (url.Length == 0)
                            {
                            }
                            urls.Add(url);
                            double dist = 0;

                            attr = (XAttribute)shapeNode.Attribute("dist");
                            if (attr != null)
                            {
                                dist = Double.Parse(attr.Value);
                            }
                            distances.Add(dist);
                        }
                    }
                    string name = "shape";
                    attr = (XAttribute)child.Attribute("name");
                    if (attr != null)
                    {
                        name = attr.Value;
                    }
                    //ShapeSpecification specif = (UnityShapeSpecification)ScriptableObject.CreateInstance("UnityShapeSpecification");
                    //((UnityShapeSpecification)specif).instantiate(name,distances,urls,movable,recursive,"");
                    //entity.getProperty(name).addValue(specif);
                    //entity.set_DEP_current(specif);
                    //entity.setActiveShape(name);
                }
                else if (child.Name.LocalName == "Scale")
                {
                    XAttribute attr = (XAttribute)child.Attribute("sx");
                    if (attr != null) scaleFactor.x = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("sy");
                    if (attr != null) scaleFactor.y = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("sz");
                    if (attr != null) scaleFactor.z = float.Parse(attr.Value);

                }
                else if (child.Name.LocalName == "Animation")
                {
                    string name = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) name = attr.Value;

                    bool running = false;

                    attr = (XAttribute)child.Attribute("running");
                    if (attr != null) running = Boolean.Parse(attr.Value);

                    string file = "";
                    attr = (XAttribute)child.Attribute("url");
                    if (attr != null)
                    {
                        file = attr.Value + basedir;
                    }

                    //AnimationSpecification animation = (UnityAnimationSpecification)ScriptableObject.CreateInstance("UnityAnimationSpecification");
                    //((UnityAnimationSpecification)animation).instantiate(name,file, 1,1.0,false);
                    //entity.getProperty(name).addValue(animation);
                    //if (running) entity.playAnimation(name,1,1.0, true);
                }
                else if (child.Name.LocalName == "Sound")
                {
                    string name = "";

                    XAttribute attr = (XAttribute)child.Attribute("name");
                    if (attr != null) name = attr.Value;

                    string file = "";

                    attr = (XAttribute)child.Attribute("url");
                    if (attr != null) file = attr.Value + basedir;

                    double gain = 1.0;
                    double minDist = 1.0;
                    double maxDist = 100.0;

                    attr = (XAttribute)child.Attribute("gain");
                    if (attr != null) gain = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("minDistance");
                    if (attr != null) minDist = float.Parse(attr.Value);

                    attr = (XAttribute)child.Attribute("maxDistance");
                    if (attr != null) maxDist = float.Parse(attr.Value);

                    //SoundSpecification sound = (UnitySoundSpecification)ScriptableObject.CreateInstance("UnitySoundSpecification");
                    //((UnitySoundSpecification)sound).instantiate(name, file, gain,minDist,maxDist,false);
                    //entity.getProperty(name).addValue(sound);
                    //sound.attachTo(entity.ReferentialPoint);
                }
                else if (child.Name.LocalName == "Inline")
                {
                    XDocument parser = null;

                    XAttribute attr = (XAttribute)child.Attribute("url");
                    if (attr != null)
                    {
                        try
                        {
                            parser = XDocument.Load(attr.Value + basedir);
                            _readGeometryEntity(parser.Root, entity);
                        }
                        catch (FileLoadException )
                        {
                        }
                    }
                }
                else if (child.Name.LocalName == "InternalOrientationAxe")
                {
                    //TODO: Pourquoi non utilisé ?
                    /*Axe _front = AxeFromNodeProperty(child, "frontAxe");
                    Axe _left = AxeFromNodeProperty(child, "leftAxe");
                    Axe _above = AxeFromNodeProperty(child, "aboveAxe");*/
                    /*point.setFront(_front);
                    point.setLeft(_left);
                    point.setAbove(_above);*/
                }
                else if (child.Name.LocalName == "InternalOrientationVector")
                {
                    //TODO:
                }
                else if (child.Name.LocalName == "State")
                {
                    // TODO: Maybe it's not normal to found a State here ?
                    _initializeStateMachine(child, entity);
                }

            }
            /*
            if (entity.getActiveShape())
            {
                entity.getActiveShape().setScale(scaleFactor);
            }	 */
        }
Esempio n. 5
0
 public UnityEngine.Quaternion RotationVector2unityQuaternion(Mascaret.RotationVector vec4)
 {
     return(new UnityEngine.Quaternion((float)vec4.x, (float)vec4.y, (float)vec4.z, (float)vec4.angle));
 }
Esempio n. 6
0
        public override ValueSpecification clone()
        {
            RotationVector valueSpec = new RotationVector(x, y, z, angle);

            return((ValueSpecification)valueSpec);
        }
Esempio n. 7
0
 public void setLocalRotation(RotationVector orientation)
 {
     //callback operation
       //  referentialPoint.setLocalRotation(orientation);
 }
Esempio n. 8
0
 public override ValueSpecification clone()
 {
     RotationVector valueSpec = new RotationVector(x, y, z, angle);
     return (ValueSpecification)valueSpec;
 }
Esempio n. 9
0
 public abstract void rotate(RotationVector orientation);
Esempio n. 10
0
 public abstract void setGlobalRotation(RotationVector orientation);
Esempio n. 11
0
 public void setGlobalRotation(RotationVector orientation)
 {
     //callback operation
     referentialPoint.setGlobalRotation(orientation);
 }
Esempio n. 12
0
 public abstract void setLocalRotation(RotationVector orientation);
Esempio n. 13
0
 public abstract void rotate(RotationVector orientation);