Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        X3DPage x3dPage = new X3DPage();

        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        X3DGroup group = new X3DGroup();

        x3dPage.Scene.AddChild(group);
        X3DTransform parentT = new X3DTransform();

        group.AddChild(parentT);
        X3DTransform worldT = X3DTransform.AddTransFormWithShape(ShapeType.Sphere);

        parentT.AddChild(worldT);
        worldT.Translation = new Vector3(0, 1, 3);
        worldT.Scale       = Vector3.One(0.3);
        worldT.Shape.Appearance.Material.DEF           = "MaterialLightBlue";
        worldT.Shape.Appearance.Material.DiffuseColor  = new Vector3(0.1, 0.5, 1);
        worldT.Shape.Appearance.Material.EmissiveColor = new Vector3(0, 0, 0.2);
        worldT.Shape.Appearance.ImageTexture.Url       = "earth-topo.png";
        worldT.Shape.Appearance.Movement.Rotate        = new Vector3(0, -1, 0);

        //Render page
        x3dPage.Render(sb);
        Response.Clear();
        Response.ContentType = "text/xml";
        Response.Write(sb.ToString());
        Response.End();
    }
Esempio n. 2
0
        public static X3DTransform BarGraph(GraphData o)
        {
            double yscale = GetYScale(o) * 1.1;
            double graphScale = 0.2;
            double dataHeight = 3;
            X3DTransform p = new X3DTransform();
            p.Translation = new Vector3(0, -graphScale * dataHeight /2.0, 0);
            p.Scale = new Vector3(graphScale);
            X3DTransform legenda = new X3DTransform();
            p.AddChild(legenda);
            legenda.Name = "legenda";
            int xlength = 1;
            int ylength = 1;
            if (o.Zvalues.Count>0)
            {
                ylength = o.Zvalues.Count;
                xlength = o.Zvalues[0].Xvalues.Count;
            }
            var offset = new Vector3(-((double)xlength) / 2, 0, 0);
            legenda.Translation = offset + new Vector3(xlength+1, 3, 0);
            //title
            if (!string.IsNullOrEmpty(o.Title))
            {
                var titletxt = X3DTransform.AddTransFormWithShape(ShapeType.Text);
                p.AddChild(titletxt);
                titletxt.Translation = offset + new Vector3(((float)xlength)/2.0f, -2, 0);
                titletxt.Scale = new Vector3(0.2);
                titletxt.Shape.Text = o.Title;
            }


            int z_idx = 0;
            foreach (var zvalue in o.Zvalues)
            {
                var li = GetLegendaLabel(zvalue.name, z_idx, zvalue.Color, zvalue.name);
                legenda.AddChild(li);
                li.Translation = new Vector3(0, -z_idx * 0.3, ylength);
                int monthno = 0;
                foreach (var m in zvalue.Xvalues)
                {
                    var value = m.Yvalue;
                    var label = z_idx == 0 ? m.name : null;
                    p.AddChild(GetBar(z_idx, monthno, value, dataHeight * value / yscale, zvalue.Color, label, zvalue.Transparency, ylength, offset));
                    monthno++;
                }
                z_idx++;
            }
            return p;
        }
Esempio n. 3
0
        static X3DTransform GetLabel(string text, Vector3 backColor, LabelSize labelSize, Vector3 fontColor)
        {
            X3DTransform p  = new X3DTransform();
            X3DTransform mb = X3DTransform.AddTransFormWithShape(ShapeType.Cube);

            p.AddChild(mb);
            var xScale     = 0.2;
            var yScale     = 0.06;
            var txtTrans   = 0.12;
            var rectLength = 20;

            switch (labelSize)
            {
            case LabelSize.large:
                xScale   = 0.7;
                txtTrans = -0.13;
                break;

            case LabelSize.xLarge:
                xScale     = 0.92;
                txtTrans   = 0;
                rectLength = 44;
                yScale     = 0.1;
                break;

            case LabelSize.xxLarge:
                xScale     = 0.92;
                txtTrans   = 0;
                rectLength = 44;
                yScale     = 0.71;
                break;
            }
            mb.Scale = new Vector3(xScale, yScale, 0.001);
            mb.Shape.Appearance.Material.DiffuseColor = backColor;
            var labeltxt = X3DTransform.AddTransFormWithShape(ShapeType.Text);

            p.AddChild(labeltxt);
            labeltxt.Translation             = new Vector3(txtTrans, 0, -0.012);
            labeltxt.Scale                   = new Vector3(0.02);
            labeltxt.Shape.Text              = text;
            labeltxt.Shape.FontStyle.Justify = Justify.LEFT;
            labeltxt.Shape.RectHeight        = 1;
            labeltxt.Shape.RectLength        = rectLength;
            labeltxt.Shape.Appearance.Material.DiffuseColor = fontColor;
            //labeltxt.Shape.FontStyle.
            return(p);
        }
Esempio n. 4
0
 static X3DTransform GetLegendaLabel(string axisValue, int axisIndex, Vector3 color, string label)
 {
     X3DTransform p = new X3DTransform();
     X3DTransform t = X3DTransform.AddTransFormWithShape(ShapeType.Sphere);
     p.AddChild(t);
     t.Scale = new Vector3(0.2);
     t.Shape.Appearance.Material = new X3DMaterial();
     t.Shape.Appearance.Material.DiffuseColor = color == null ? GetColor(axisIndex) : color;
     if (!string.IsNullOrEmpty(label))
     {
         var labeltxt = X3DTransform.AddTransFormWithShape(ShapeType.Text);
         p.AddChild(labeltxt);
         labeltxt.Translation = new Vector3(0.75, 0, 0);
         labeltxt.Scale = new Vector3(0.2);
         labeltxt.Shape.Text = label;
     }
     return p;
 }
Esempio n. 5
0
        static X3DTransform GetBar(int z, int x, double value, double drawvalue, Vector3 color,  string label, double transparency, int ylength, Vector3 offset)
        {
            X3DTransform p = new X3DTransform();
            p.Translation = offset+ new Vector3(x, 0, z);
            X3DTransform t = X3DTransform.AddTransFormWithShape(ShapeType.Prefab);
            t.Shape.Group = "primitives";
            t.Shape.Item = "smoothcube";
            p.AddChild(t);
            t.Translation = new Vector3(0, 0.5 * drawvalue, 0);
            t.Scale = 0.5* new Vector3(0.7, drawvalue, 0.7);
            t.Shape.Appearance.Material = new X3DMaterial();
            t.Shape.Appearance.Material.DiffuseColor = color==null?GetColor(z): color;
            if(transparency>0)
            {
                t.Shape.Appearance.Material.Transparency = transparency;
            }
            if (!string.IsNullOrEmpty(label))
            {
                var labeltxt = X3DTransform.AddTransFormWithShape(ShapeType.Text);
                p.AddChild(labeltxt);
                labeltxt.Translation = new Vector3(1.2, -1, ylength);
                labeltxt.Scale = new Vector3(0.2);
                labeltxt.EulerRotation = new Vector3(0, 0, -30);
                labeltxt.Shape.Text = label;
                labeltxt.Shape.FontStyle.Justify = Justify.LEFT;
                labeltxt.Shape.RectHeight = 1;
                labeltxt.Shape.RectLength = 14;
            }
            var valuetxt = X3DTransform.AddTransFormWithShape(ShapeType.Text);
            p.AddChild(valuetxt);
            valuetxt.Translation = new Vector3(0, drawvalue+0.2, 0);
            valuetxt.Scale = new Vector3(0.2);
            valuetxt.Shape.Text = value.ToString("0.");

            return p;

        }
Esempio n. 6
0
        public static X3DTransform BarGraph(ChartData o)
        {
            double yscale = GetYScale(o) * 0.4;
            double graphScale = 0.2;
            double dataHeight = 3;
            X3DTransform p = new X3DTransform();
            p.Translation = new Vector3(0, -graphScale * dataHeight / 2.0, 0);
            p.Scale = new Vector3(graphScale);
            X3DTransform legenda = new X3DTransform();
            p.AddChild(legenda);
            legenda.Name = "legenda";
            int xlength = o.x_values.Count;
            int zlength = o.z_values.Count;
            var offset = new Vector3(-((double)xlength) / 2, 0, 0);
            legenda.Translation = offset + new Vector3(xlength + 1, 3, 0);
            //title
            if (!string.IsNullOrEmpty(o.title))
            {
                var titletxt = X3DTransform.AddTransFormWithShape(ShapeType.Text);
                p.AddChild(titletxt);
                titletxt.Translation = offset + new Vector3(((float)xlength) / 2.0f, -2, 0);
                titletxt.Scale = new Vector3(0.2);
                titletxt.Shape.Text = o.title;
            }

            if (o.z_values.Count > 1)
            {
                foreach (var val in o.z_values)
                {
                    var z_idx = o.z_values.IndexOf(val);
                    var li = GetLegendaLabel(val.value, z_idx, getColor(val.color), val.label);
                    legenda.AddChild(li);
                    li.Translation = new Vector3(0, -z_idx * 0.3, zlength);
                }
            }
            foreach (var m in o.data)
            {
                var value = m.y;
                var z_val = o.z_values.Find(i => i.value == m.z);
                var z_idx = 0;
                if (z_val == null && o.z_values.Count > 0)
                {
                    z_val = o.z_values[0];
                }
                if (z_val == null)
                {
                    z_val = new AxisValue();
                    z_val.color = "1, 0, 0";
                }
                else
                {
                    z_idx = o.z_values.IndexOf(z_val);
                }
                z_idx = z_idx == -1 ? 0 : z_idx;
                var x_val = o.x_values.Find(i => i.value == m.x);
                var x_idx = o.x_values.IndexOf(x_val);
                var label = "";
                if (o.x_values.Count > 0)
                {
                    label = z_idx == 0 ? o.x_values[x_idx].label : null;
                }
                z_idx = o.z_values.Count - z_idx;
                //var z_val = o.z_values[m.z];
                Vector3 color = new Vector3(1);
                p.AddChild(GetBar(z_idx, x_idx, value, dataHeight * value / yscale, getColor(z_val.color), label, 0, zlength, offset));
            }
            return p;
        }
Esempio n. 7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        ReadRequestHeaders();
        System.Text.StringBuilder sb = new System.Text.StringBuilder();
        X3DPage page = new X3DPage();
        X3DMeta meta = new X3DMeta();

        meta.MetaType = MetaType.keywords;
        meta.Content  = "X3D, v-slam, information, browser";
        page.Head.MetaTags.Add(meta);
        X3DMeta metasingleUser = new X3DMeta();

        metasingleUser.MetaType = MetaType.singleuser;
        metasingleUser.Content  = "true";
        page.Head.MetaTags.Add(metasingleUser);
        //page
        X3DMeta metaPage = new X3DMeta();

        metaPage.MetaType = MetaType.page;
        metaPage.Content  = "0";
        page.Head.MetaTags.Add(metaPage);
        X3DMeta metaFilter = new X3DMeta();

        metaFilter.MetaType = MetaType.filter;
        metaFilter.Content  = "";
        page.Head.MetaTags.Add(metaFilter);

        page.ViewPoint.DEF      = "ViewUpClose";
        page.ViewPoint.Position = new Vector3(0, 1, -3);
        var now = DateTime.UtcNow.AddHours(1 + Timezone_Offset);

        if (CallingApp == CallingDevices.HoloLens)
        {
            page.ViewPoint.Position = new Vector3(0, 1, -3);
        }
        if (CallingApp != CallingDevices.HoloLens)
        {
            X3DBackGround backGround = new X3DBackGround();
            backGround.Name           = "skyBox";
            backGround.SkyBox         = "sky5X4";
            backGround.LightingMode   = LightingMode.SkyBox;
            backGround.ReflectionMode = ReflectionMode.SkyBox;
            page.Scene.BackGround     = backGround;
        }
        X3DFog fog = new X3DFog();

        page.Scene.AddChild(fog);
        fog.Density = 0;
        X3DGroup group = new X3DGroup();

        page.Scene.AddChild(group);
        double intens = 0.5;

        X3DTransform dLightt2 = X3DTransform.AddTransFormWithShape(ShapeType.Empty);

        group.AddChild(dLightt2);
        dLightt2.EulerRotation = new Vector3(140, 180, 0);
        X3DLight light2 = new X3DLight();

        light2.LightType = LightType.DirectionalLight;
        light2.Intensity = intens;
        dLightt2.AddChild(light2);

        if (CallingApp != CallingDevices.HoloLens)
        {
            X3DTransform environment = new X3DTransform();
            group.AddChild(environment);
            environment.Name = "environment";
            X3DInline inline = new X3DInline();
            environment.AddChild(inline);
            inline.Url = "exp/cliffhouse/cliffhouse.x3dx";
        }
        X3DTransform navigationGroup = X3DTransform.AddTransFormWithShape(ShapeType.Empty, new Vector3(0, 1.477, 0));

        group.AddChild(navigationGroup);
        navigationGroup.Name = "NavigationGroup";
        if (CallingApp == CallingDevices.HoloLens)
        {
            navigationGroup.Scale = new Vector3(holoScale);
        }

        //add transform earth
        X3DTransform transform = X3DTransform.AddTransFormWithShape(ShapeType.Sphere, new Vector3(), new Quaternion(0, 1, 0, 3), Vector3.One(0.3));

        navigationGroup.AddChild(transform);
        transform.Shape.Appearance.Material.DEF           = "MaterialLightBlue";
        transform.Shape.Appearance.Material.DiffuseColor  = new Vector3(0.1, 0.5, 1);
        transform.Shape.Appearance.Material.EmissiveColor = new Vector3(0, 0, 0.2);
        transform.Shape.Appearance.ImageTexture.Url       = "images/earth-topo.png";
        transform.Shape.Appearance.Movement.Rotate        = new Vector3(0, -1, 0);
        transform.Shape.Url     = "#slam_menu";
        transform.Shape.ToolTip = "Select to open main menu";

        //text
        X3DTransform transform4 = X3DTransform.AddTransFormWithShape(ShapeType.Text, new Vector3(0, -0.3, 0), null, Vector3.One(0.03));

        navigationGroup.AddChild(transform4);
        //transform4.Translation = "0 0.855 0";
        transform4.Shape.Appearance.Material.USE = "MaterialLightBlue";
        transform4.Shape.Text              = "\"v-Slam\" \"browse the world!\"";
        transform4.Shape.FaceCamera        = FaceCamera.back_lock_y;
        transform4.Shape.FontStyle.Justify = Justify.MIDDLE;

        //infoHolder
        X3DTransform transformInfoHolder = X3DTransform.AddTransFormWithShape(ShapeType.Empty, new Vector3(0, 0.685, -1));

        transformInfoHolder.Name = "infoHolder";
        if (CallingApp == CallingDevices.HoloLens)
        {
            transformInfoHolder.Scale       = new Vector3(0.4);
            transformInfoHolder.Translation = new Vector3(0, 1.2, -1);
        }
        group.AddChild(transformInfoHolder);

        X3DTransform light1 = X3DTransform.AddTransFormWithShape(ShapeType.Empty);

        group.AddChild(light1);

        light1.EulerRotation = new Vector3(40, -28, -20);
        light1.Name          = "light1";
        X3DLight light = new X3DLight();

        light1.AddChild(light);

        light.LightType = LightType.DirectionalLight;
        light.Intensity = 0.3;
        if (CallingApp == CallingDevices.HoloLens)
        {
            light.Intensity = 1.5;
        }
        light.ShadowIntensity = 1.0;
        if (CallingApp == CallingDevices.HoloLens)
        {
            X3DTransform pl = new X3DTransform();
            group.AddChild(pl);
            pl.Translation = new Vector3(-2.4, 3.17, -2.19);
            X3DLight light3 = new X3DLight();
            pl.AddChild(light3);
            light3.LightType       = LightType.PointLight;
            light3.Direction       = new Vector3(-230, -115, 70);
            light3.Intensity       = 3.0;
            light3.ShadowIntensity = 1.0;

            //arrows
            X3DTransform arrows = new X3DTransform();
            group.AddChild(arrows);
            arrows.Translation = new Vector3(0, 1, 0);
            X3DTransform arr1 = X3DTransform.AddTransFormWithShape(ShapeType.Prefab);
            arrows.AddChild(arr1);
            arr1.Shape.Group = "primitives";
            arr1.Shape.Item  = "roundedarrow";
            arr1.Translation = new Vector3(2, 0, -2);
            arr1.Shape.Appearance.Material.DEF          = "arcMat";
            arr1.Shape.Appearance.Material.DiffuseColor = new Vector3(0.3, 0.3, 0.7);
            arr1.Shape.Appearance.Material.Transparency = 0.7;
            arr1.EulerRotation = new Vector3(0, -90, 0);
            arr1.Scale         = new Vector3(1.22, 0.7, 0.7);

            X3DTransform arr2 = X3DTransform.AddTransFormWithShape(ShapeType.Prefab);
            arrows.AddChild(arr2);
            arr2.Shape.Group = "primitives";
            arr2.Shape.Item  = "roundedarrow";
            arr2.Translation = new Vector3(-2, 0, -2);
            arr2.Shape.Appearance.Material.USE          = "arcMat";
            arr2.Shape.Appearance.Material.DiffuseColor = new Vector3(0.3, 0.3, 0.7);
            arr2.Shape.Appearance.Material.Transparency = 0.7;
            arr2.EulerRotation = new Vector3(180, -90, 0);
            arr2.Scale         = new Vector3(1.22, 0.7, 0.7);

            X3DTransform arr3 = X3DTransform.AddTransFormWithShape(ShapeType.Prefab);
            arrows.AddChild(arr3);
            arr3.Shape.Group = "primitives";
            arr3.Shape.Item  = "roundedarrow";
            arr3.Translation = new Vector3(-1, 0, -5);
            arr3.Shape.Appearance.Material.USE          = "arcMat";
            arr3.Shape.Appearance.Material.DiffuseColor = new Vector3(0.3, 0.3, 0.7);
            arr3.Shape.Appearance.Material.Transparency = 0.7;
            arr3.EulerRotation = new Vector3(180, -120, 0);
            arr3.Scale         = new Vector3(1.22, 0.7, 0.7);
            X3DTransform arr4 = X3DTransform.AddTransFormWithShape(ShapeType.Prefab);
            arrows.AddChild(arr4);
            arr4.Shape.Group = "primitives";
            arr4.Shape.Item  = "roundedarrow";
            arr4.Translation = new Vector3(1, 0, -5);
            arr4.Shape.Appearance.Material.USE          = "arcMat";
            arr4.Shape.Appearance.Material.DiffuseColor = new Vector3(0.3, 0.3, 0.7);
            arr4.Shape.Appearance.Material.Transparency = 0.7;
            arr4.EulerRotation = new Vector3(0, -60, 0);
            arr4.Scale         = new Vector3(1.22, 0.7, 0.7);
        }

        X3DSound sound = new X3DSound();

        page.Scene.AddChild(sound);
        sound.Url     = "\"sound/soft.wav\"";
        sound.Loop    = true;
        sound.Enabled = true;
        sound.Volume  = 0.0;
        page.Render(sb);
        Response.Clear();
        Response.ContentType = "text/xml";
        Response.Write(sb.ToString());
        Response.End();
    }
Esempio n. 8
0
        public static X3DTransform GetMailStructure(MailData mailData)
        {
            Vector3      labelColor = new Vector3(0.7, 0.7, 1);
            Vector3      dataColor  = new Vector3(0.7, 0.9, 0.9);
            Vector3      fontColor  = new Vector3(0, 0, 0);
            X3DTransform p          = new X3DTransform();
            X3DTransform mb         = X3DTransform.AddTransFormWithShape(ShapeType.Cube);

            p.AddChild(mb);
            mb.Scale = new Vector3(1, 1.3, 0.001);
            mb.Shape.Appearance.Material.DiffuseColor = new Vector3(0.6, 0.7, 0.9);
            var ypos = 0.58;
            var rh   = -0.1;
            //from
            var labelFrom = GetLabel("From", labelColor, LabelSize.small, fontColor);

            p.AddChild(labelFrom);
            labelFrom.Translation = new Vector3(-0.37, ypos, -0.007);
            var dataFrom = GetLabel(mailData.From, dataColor, LabelSize.large, fontColor);

            p.AddChild(dataFrom);
            dataFrom.Translation = new Vector3(0.1, ypos, -0.007);
            //to
            ypos += rh;
            var labelTo = GetLabel("To", labelColor, LabelSize.small, fontColor);

            p.AddChild(labelTo);
            labelTo.Translation = new Vector3(-0.37, ypos, -0.007);
            var dataTo = GetLabel(mailData.To, dataColor, LabelSize.large, fontColor);

            p.AddChild(dataTo);
            dataTo.Translation = new Vector3(0.1, ypos, -0.007);
            //sendDate
            ypos += rh;
            var labelSend = GetLabel("Send", labelColor, LabelSize.small, fontColor);

            p.AddChild(labelSend);
            labelSend.Translation = new Vector3(-0.37, ypos, -0.007);
            var dataSend = GetLabel(mailData.SendDate.ToString("yyyy/MM/dd hh:mm"), dataColor, LabelSize.large, fontColor);

            p.AddChild(dataSend);
            dataSend.Translation = new Vector3(0.1, ypos, -0.007);
            //subject
            ypos += rh;
            var labelSubject = GetLabel("Subject:", labelColor, LabelSize.small, fontColor);

            p.AddChild(labelSubject);
            labelSubject.Translation = new Vector3(-0.37, ypos, -0.007);
            ypos += rh;
            var dataSubject = GetLabel(mailData.Subject, dataColor, LabelSize.xLarge, fontColor);

            p.AddChild(dataSubject);
            dataSubject.Translation = new Vector3(-0.01, ypos, -0.007);
            ypos += rh;
            var dataBody = GetLabel(mailData.Body, dataColor, LabelSize.xxLarge, fontColor);

            p.AddChild(dataBody);
            dataBody.Translation = new Vector3(-0.01, -0.25, -0.007);



            return(p);
        }