Beispiel #1
0
        internal Visual(XmlNode node)
        {
            Name = node.Attributes?["name"]?.Value;

            Geometry?geometry = null;

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "cast_shadows":
                    CastShadows = BoolElement.ValueOf(child);
                    break;

                case "transparency":
                    Transparency = DoubleElement.ValueOf(child);
                    break;

                case "pose":
                    Pose = new Pose(child);
                    break;

                case "material":
                    Material = new Material(child);
                    break;

                case "geometry":
                    geometry = new Geometry(child);
                    break;
                }
            }

            Geometry = geometry ?? throw new MalformedSdfException(node, "Expected geometry!");
            HasUri   = Geometry.HasUri;
        }
Beispiel #2
0
        internal Material(XmlNode node)
        {
            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "lighting":
                    Lighting = BoolElement.ValueOf(child);
                    break;

                case "ambient":
                    Ambient = new Color(child);
                    break;

                case "diffuse":
                    Diffuse = new Color(child);
                    break;

                case "specular":
                    Specular = new Color(child);
                    break;

                case "emissive":
                    Emissive = new Color(child);
                    break;
                }
            }
        }
Beispiel #3
0
        internal Include(XmlNode node)
        {
            Uri?uri = null;

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "uri":
                    uri = new Uri(child);
                    break;

                case "name":
                    Name = child.InnerText;
                    break;

                case "static":
                    Static = BoolElement.ValueOf(child);
                    break;

                case "pose":
                    Pose = new Pose(child);
                    break;
                }
            }

            Uri = uri ?? throw new MalformedSdfException(node, "Expected uri!");
        }
Beispiel #4
0
        internal Light(XmlNode node)
        {
            Name = node.Attributes?["name"]?.Value;

            string?type = node.Attributes?["type"]?.Value;

            switch (type)
            {
            case "directional":
                Type = LightType.Directional;
                break;

            case "spot":
                Type = LightType.Spot;
                break;

            case "point":
            case null:
                Type = LightType.Point;
                break;
            }

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "cast_shadows":
                    CastShadows = BoolElement.ValueOf(child);
                    break;

                case "diffuse":
                    Diffuse = new Color(child);
                    break;

                case "specular":
                    Specular = new Color(child);
                    break;

                case "attenuation":
                    Attenuation = new Attenuation(child);
                    break;

                case "direction":
                    Direction = new Vector3d(child);
                    break;

                case "spot":
                    Spot = new Spot(child);
                    break;

                case "pose":
                    Pose = new Pose(child);
                    break;
                }
            }
        }
Beispiel #5
0
        internal Link(XmlNode node)
        {
            Name = node.Attributes?["name"]?.Value;

            List <Visual> visuals = new List <Visual>();
            List <Light>  lights  = new List <Light>();

            Visuals = visuals.AsReadOnly();
            Lights  = lights.AsReadOnly();

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "gravity":
                    Gravity = BoolElement.ValueOf(child);
                    break;

                case "enable_wind":
                    EnableWind = BoolElement.ValueOf(child);
                    break;

                case "self_collide":
                    SelfCollide = BoolElement.ValueOf(child);
                    break;

                case "kinematic":
                    Kinematic = BoolElement.ValueOf(child);
                    break;

                case "must_be_base_link":
                    MustBeBaseLink = BoolElement.ValueOf(child);
                    break;

                case "pose":
                    Pose = new Pose(child);
                    break;

                case "visual":
                    visuals.Add(new Visual(child));
                    break;

                case "light":
                    lights.Add(new Light(child));
                    break;
                }
            }

            HasUri = Visuals.Any(visual => visual.HasUri);
        }
Beispiel #6
0
        internal Model(XmlNode node)
        {
            Name          = node.Attributes?["name"]?.Value;
            CanonicalLink = node.Attributes?["canonical_link"]?.Value;

            List <Include> includes = new List <Include>();
            List <Model>   models   = new List <Model>();
            List <Frame>   frames   = new List <Frame>();
            List <Link>    links    = new List <Link>();

            Includes = includes.AsReadOnly();
            Models   = models.AsReadOnly();
            Frames   = frames.AsReadOnly();
            Links    = links.AsReadOnly();

            foreach (XmlNode child in node.ChildNodes)
            {
                switch (child.Name)
                {
                case "static":
                    Static = BoolElement.ValueOf(child);
                    break;

                case "self_collide":
                    SelfCollide = BoolElement.ValueOf(child);
                    break;

                case "allow_auto_disable":
                    AllowAutoDisable = BoolElement.ValueOf(child);
                    break;

                case "include":
                    includes.Add(new Include(child));
                    break;

                case "model":
                    models.Add(new Model(child));
                    break;

                case "enable_wind":
                    EnableWind = BoolElement.ValueOf(child);
                    break;

                case "frame":
                    frames.Add(new Frame(child));
                    break;

                case "pose":
                    Pose = new Pose(child);
                    break;

                case "link":
                    links.Add(new Link(child));
                    break;
                }
            }

            HasIncludes =
                Includes.Count != 0 ||
                Models.Any(model => model.HasIncludes) ||
                Links.Any(link => link.HasUri);
        }