コード例 #1
0
ファイル: TreeTest.cs プロジェクト: yong-ja/starodyssey
        protected override void OnInit(object sender, EventArgs e)
        {
            FixedNode fNode = new FixedNode();

            Camera.LookAt(Vector3.Zero, new Vector3(0, 0, -10f));
            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            torus = new Torus(5f, 0.25f, 256, 64);
            RenderableNode rNode = new RenderableNode(torus);
            fNode.AppendChild(rNode);

            Box box = new Box(1f);
            RenderableNode rNodeBox = new RenderableNode(box);
            //fNode.AppendChild(rNodeBox);

            //for (int i = 0; i < 10; i++)
            //{
            //    Quad quad = new Quad();
            //    quad.PositionV3 = new Vector3(0 + 1f * i, 0, -1f*i);

            //    RenderableNode rNode = new RenderableNode(quad);

            //    fNode.AppendChild(rNode);
            //}

            //for (int i = 0; i < 10; i++)
            //{
            //    Quad quad = new Quad();
            //    quad.PositionV3 = new Vector3(0 + 1f * i, 0.5f, -1.5f * i);
            //    ((IColorMaterial)quad.Material).DiffuseColor = new Color4(1f, 0, 0);

            //    RenderableNode rNode = new RenderableNode(quad);

            //    fNode.AppendChild(rNode);
            //}

            Scene.Tree.RootNode.AppendChild(fNode);
            Scene.BuildRenderScene();

            Hud = Hud.FromDescription(Game.Context.Device,
                new HudDescription(
                    width: Game.Context.Settings.ScreenWidth,
                    height: Game.Context.Settings.ScreenHeight,
                    zNear: Game.CurrentRenderer.Camera.NearClip,
                    zFar: Game.CurrentRenderer.Camera.FarClip,
                    cameraEnabled: true,
                    multithreaded: true
                    ));
            OdysseyUI.CurrentHud = Hud;
            Game.Logger.Activate();
            Hud.BeginDesign();
            Hud.Init();
            Hud.EndDesign();
        }
コード例 #2
0
 public UserInterfaceRenderCommand(Renderer renderer, Hud hud, RenderableNode rNode)
     : base(renderer, new UIMaterial(),
         new RenderableCollection(UIMaterial.ItemsDescription, new [] {rNode}))
 {
     CommandType = CommandType.UserInterfaceRenderCommand;
     CommandAttributes |= Graphics.CommandAttributes.MonoRendering;
     this.hud = hud;
     textMaterial = new TextMaterial();
     this.rNode = rNode;
     this.rNode.RenderableObject.Material = Material;
     tNode = (TransformNode)rNode.Parent;
     UpdateSprites(hud.SpriteControls);
     textTechnique = textMaterial.EffectDescription.Technique;
     textPass = textTechnique.GetPassByIndex(textMaterial.EffectDescription.Pass);
     textLayout = new InputLayout(Game.Context.Device, textPass.Description.Signature,
         TextItems.Description.InputElements);
 }
コード例 #3
0
        public override void Init()
        {
            Inited = true;
            if (LeadNode == null)
                foreach (SceneNode sNode in ChildrenIterator)
                {
                    RenderableNode rNode = sNode as RenderableNode;
                    if (rNode == null) continue;

                    LeadNode = rNode;
                    UpdateLocalWorldMatrix();
                    return;
                }

            else
            {
                UpdateLocalWorldMatrix();
                return;
            }

            throw Error.InvalidOperation(Properties.Resources.ERR_FtNodeRequiresRNode);
        }
コード例 #4
0
ファイル: ImageRenderer.cs プロジェクト: yong-ja/starodyssey
        public override void Init()
        {
            TexturedPolygon quad = TexturedPolygon.CreateTexturedQuad("ScreenQuad", Vector3.Zero, 1920, 1080);
            ImageLoadInformation info = new ImageLoadInformation()
            {
                BindFlags = BindFlags.None,
                CpuAccessFlags = CpuAccessFlags.Read,
                FilterFlags = FilterFlags.None,
                Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm,
                MipFilterFlags = FilterFlags.None,
                OptionFlags = ResourceOptionFlags.None,
                Usage = ResourceUsage.Staging,
                MipLevels = 1
            };
            Texture2D tex = Texture2D.FromFile(Game.Context.Device, "medusa.jpg",  info);

            ShaderResourceView srv = new ShaderResourceView(Game.Context.Device,  Make3D(tex));
            quad.DiffuseMapResource = srv;
            rNode = new RenderableNode(quad);
            iMat = new ImageMaterial();
            FixedNode fNode = new FixedNode();
            fNode.Init();
            quad.PositionV3 = Layout.OrthographicTransform(Vector2.Zero, 100, new Size(1920,1080));

            RenderableCollection rCol = new RenderableCollection(iMat.RenderableCollectionDescription);
            MaterialNode mMat = new MaterialNode(iMat);
            rCol.Add(rNode);

            fNode.AppendChild(mMat);
            mMat.AppendChild(rNode);

            rCommand = new RenderCommand(mMat, rCol);
            rCommand.Init();
            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Scene.Tree.RootNode.AppendChild(fNode);
            Scene.BuildRenderScene();
        }
コード例 #5
0
ファイル: BoxRenderer.cs プロジェクト: yong-ja/starodyssey
        protected override void OnInit(object sender, EventArgs e)
        {
            Camera.LookAt(Vector3.Zero, new Vector3(0, 0, -10f));

            Box box = new Box(1, 1, 1);
            Sphere sphere = new Sphere(1, 16);
            Arrow arrow = new Arrow(1, 1, 3, 0.5f) { PositionV3 = new Vector3(-2.5f, 0, 0) };
            AvengersUtd.Odyssey.Graphics.Meshes.BoundingBox bbox = new AvengersUtd.Odyssey.Graphics.Meshes.BoundingBox(4);
            sphere.PositionV3= new Vector3(0f, 3f, 0);
            RenderableNode rNodeBox = new RenderableNode(box) { Label = "RBox" };
            RenderableNode rNodeSPhere = new RenderableNode(sphere);
            RenderableNode rNodeBBox = new RenderableNode(bbox);
            FixedNode fNodeGrid = new FixedNode { Label = "fGrid", Position = Vector3.Zero };

            CameraAnchorNode coNode = new CameraAnchorNode();
            Scene.Tree.RootNode.AppendChild(fNodeGrid);
            Scene.Tree.RootNode.AppendChild(coNode);
             fNodeGrid.AppendChild(rNodeSPhere);
            fNodeGrid.AppendChildren(arrow.ToNodes());
            fNodeGrid.AppendChildren(bbox.ToNodes());

            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Hud = Hud.FromDescription(Game.Context.Device,
                new HudDescription(
                    width: Game.Context.Settings.ScreenWidth,
                    height: Game.Context.Settings.ScreenHeight,
                    zNear: Game.CurrentRenderer.Camera.NearClip,
                    zFar: Game.CurrentRenderer.Camera.FarClip,
                    cameraEnabled: true,
                    multithreaded: true
                    ));
            OdysseyUI.CurrentHud = Hud;
            Game.Logger.Init();
            Hud.BeginDesign();

            Game.Logger.Log("Prova1");
            Game.Logger.Log("Prova2");
            Game.Logger.Log("Prova3");
            Game.Logger.Log("Prova4");
            Game.Logger.Log("Prova5");

            Button bConnect = new Button()
            {
                Size = new System.Drawing.Size(120, 30),
                //Content = "Start",
                Position = new Vector2(1800, 0)
            };

            Button bTracking = new Button()
            {
                Size = new System.Drawing.Size(120, 30),
                //Content = "Start",
                Position = new Vector2(1800, 40)
            };

            //bConnect.MouseClick += (sender, e) => { tracker.Connect(); };
            //bTracking.MouseClick += (sender, e) => { tracker.StartTracking(); };

            //TouchRayPanel rp = new TouchRayPanel { Size = Hud.Size, Camera = this.Camera };
            //Hud.Add(rp);

            //rp.Add(bConnect);
            //rp.Add(bTracking);
            //rp.SetTracker(tracker);

            Game.Logger.Activate();
            Hud.Init();
            Hud.EndDesign();

            //Scene.BuildRenderScene();
            //Hud.AddToScene(this, Scene);
            IsInited = true;
            //tracker.StartBrowsing();
        }
コード例 #6
0
ファイル: TestRenderer.cs プロジェクト: yong-ja/starodyssey
        public override void Init()
        {
            Camera.LookAt(Vector3.Zero, new Vector3(0, 5, -10f));
            Sphere lightSphere = Primitive.CreateSphere(1f, 8);
            lightSphere.Name = "LightSphere";
            lightSphere.SetBehaviour(new MouseDraggingBehaviour(Camera));
            Odyssey.Graphics.Meshes.BoundingBox box = AvengersUtd.Odyssey.Graphics.Meshes.BoundingBox.FromSphere(lightSphere);

            Odyssey.Graphics.Meshes.Grid grid = new AvengersUtd.Odyssey.Graphics.Meshes.Grid(50, 50, 8, 8);

            Sphere sphere = Primitive.CreateSphere(6f, 10);
            sphere.Name = "BigSphere";
            //sphere.DiffuseColor = new Color4(1.0f, 0.867f,0.737f,1.0f);
            sphere.PositionV3 = new Vector3(0f, 0, 20f);
            RenderableNode rNodeSphere = new RenderableNode(sphere);
            RenderableNode rNodeLightSphere = new RenderableNode(lightSphere);
            RenderableNode rNodeBox = new RenderableNode(box);
            //RenderableNode rNodeSky = new RenderableNode(skybox);
            RenderableNode rNodeGrid = new RenderableNode(grid);
            FixedNode fNodeSphere = new FixedNode { Position = new Vector3(5, 0, -5) };
            FixedNode fNodeGrid = new FixedNode {Label = "fGrid", Position = grid.PositionV3 };

            //Box box2 = new Box(new Vector3(0.25f, 0.25f, 0.25f), 1, 1, 1);
            Box box2 = new Box(1, 1, 1);

            box.PositionV3 = new Vector3(0, 5, 0);
            RenderableNode rNodeBox2 = new RenderableNode(box2) { Label="RBox"};
            CameraAnchorNode coNode = new CameraAnchorNode();
            Scene.Tree.RootNode.AppendChild(fNodeSphere);

            Scene.Tree.RootNode.AppendChild(fNodeGrid);
            Scene.Tree.RootNode.AppendChild(coNode);

            fNodeSphere.AppendChild(rNodeSphere);
            fNodeSphere.AppendChild(rNodeLightSphere);
            fNodeSphere.AppendChild(rNodeBox);
            fNodeGrid.AppendChild(rNodeGrid);
            fNodeGrid.AppendChild(rNodeBox2);

            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Hud = Hud.FromDescription(Game.Context.Device,
                new HudDescription(
                    width: Game.Context.Settings.ScreenWidth,
                    height: Game.Context.Settings.ScreenHeight,
                    zNear: Game.CurrentRenderer.Camera.NearClip,
                    zFar: Game.CurrentRenderer.Camera.FarClip,
                    cameraEnabled: true,
                    multithreaded: true
                    ));
            OdysseyUI.CurrentHud = Hud;
            Game.Logger.Init();
            Hud.BeginDesign();

            Game.Logger.Log("Prova1");
            Game.Logger.Log("Prova2");
            Game.Logger.Log("Prova3");
            Game.Logger.Log("Prova4");
            Game.Logger.Log("Prova5");

            Button bConnect = new Button()
            {
                Size = new System.Drawing.Size(120, 30),
                //Content = "Start",
                Position = new Vector2(1800, 0)
            };

            Button bTracking = new Button()
            {
                Size = new System.Drawing.Size(120, 30),
                //Content = "Start",
                Position = new Vector2(1800, 40)
            };

            bConnect.MouseClick += (sender, e) => { tracker.Connect(); };
            bTracking.MouseClick += (sender, e) => { tracker.StartTracking(); };

            TouchRayPanel rp = new TouchRayPanel { Size = Hud.Size, Camera = this.Camera };
            Hud.Add(rp);

            rp.Add(bConnect);
            rp.Add(bTracking);
            rp.SetTracker(tracker);

            Game.Logger.Activate();
            Hud.Init();
            Hud.EndDesign();

            Scene.BuildRenderScene();
            Hud.AddToScene(this, Scene);
            IsInited = true;
            tracker.StartBrowsing();
            //EyeTrackerServer server = new Odyssey.Network.EyeTrackerServer();
            //server.Start();
        }
コード例 #7
0
ファイル: CommandManager.cs プロジェクト: yong-ja/starodyssey
 public void AddNewRenderableObject(RenderableNode rNode)
 {
     IRenderCommand relatedCommand = (IRenderCommand)FindByMaterial(rNode.RenderableObject.Material);
     if (!relatedCommand.Items.Contains(rNode))
         relatedCommand.Items.Add(rNode);
 }
コード例 #8
0
ファイル: Hud.cs プロジェクト: yong-ja/starodyssey
        public void AddToScene(Renderer renderer, SceneManager scene)
        {
            UIMaterial uiMaterial = new UIMaterial();

            RenderableNode rNode = new RenderableNode(InterfaceMesh);
            CameraOverlayNode caNode = new CameraOverlayNode(renderer.Camera);

            caNode.AppendChild(rNode);

            uiRCommand = new UserInterfaceRenderCommand(renderer, this, rNode);

            uiUCommand = new UserInterfaceUpdateCommand(this, uiRCommand);

            scene.Tree.RootNode.AppendChild(caNode);
            scene.CommandManager.AddUpdateCommand(uiUCommand);
            scene.CommandManager.AddBaseCommands(uiMaterial.PreRenderStates);
            scene.CommandManager.AddRenderCommand(uiRCommand);
            scene.CommandManager.AddBaseCommands(uiMaterial.PostRenderStates);
        }
コード例 #9
0
ファイル: BoxRenderer.cs プロジェクト: yong-ja/starodyssey
        public override void Init()
        {
            clock = new Timer() { Interval = 1000 };
            stopwatch = new Stopwatch();
            clock.Elapsed += delegate
                             {

                                 lCountDown.Content = (--countdown).ToString();
                                 if (countdown == 0)
                                 {
                                     BoxRenderer boxR = new BoxRenderer(Game.Context);
                                     Global.Window.Dispatcher.BeginInvoke(new Action(delegate { Game.ChangeRenderer(boxR);boxR.StartNew(); }));

                                     clock.Stop();
                                 }
                             };
            //Camera.LookAt(new Vector3(3,0f, 3), new Vector3(-6.5f, 5.55f, -6.5f));
            int[] condition = conditions[Test.BoxIndex % conditions.Count];
            bool[] arrowCondition = arrowConditions[condition[1]];
            boxSize = new float[]
            {
                arrowCondition[0] ? 1.5f : 4.5f,
                arrowCondition[1] ? 1.5f : 4.5f,
                arrowCondition[2] ? 1.5f : 4.5f
            };
            box = new Box(1, 1, 1);
            box.ScalingValues = new Vector3(boxSize[0], boxSize[1], boxSize[2]);
            sWidget = new ScalingWidget(box);

            RenderableNode rNodeBox = new RenderableNode(box) { Label = "RBox" };
            float[] axis = axes[condition[2]];

            FixedNode fNodeFrame = new FixedNode {
                Label = "fGrid",
                Position = Vector3.Zero,
                Rotation = Quaternion.RotationYawPitchRoll(MathHelper.DegreesToRadians(axis[0]),
                MathHelper.DegreesToRadians(axis[1]),
                MathHelper.DegreesToRadians(axis[2]))
            };

            fNodeBox = new FixedNode
            {
                Label = "fBox",
            };

            NewSession();

            CameraAnchorNode coNode = new CameraAnchorNode();
            Scene.Tree.RootNode.AppendChild(fNodeFrame);
            Scene.Tree.RootNode.AppendChild(coNode);
            fNodeBox.AppendChild(rNodeBox);
            fNodeFrame.AppendChild(bbox.ToBranch());
            fNodeFrame.AppendChild(fNodeBox);

            FixedNode nWidget = sWidget.ToBranch();
            fNodeBox.AppendChild(nWidget);

            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Hud = Hud.FromDescription(Game.Context.Device,
                new HudDescription(
                    width: Game.Context.Settings.ScreenWidth,
                    height: Game.Context.Settings.ScreenHeight,
                    zNear: Game.CurrentRenderer.Camera.NearClip,
                    zFar: Game.CurrentRenderer.Camera.FarClip,
                    cameraEnabled: true,
                    multithreaded: true
                    ));
            OdysseyUI.CurrentHud = Hud;

            Hud.BeginDesign();

            bNew = new Button()
            {
                Size = new System.Drawing.Size(120, 60),
                Content = "New Session",
                Position = new Vector2(1760, 0)
            };

            Button bSession = new Button()
            {
                Size = new System.Drawing.Size(120, 30),
                Content = "Next",
                Position = new Vector2(1760, 40)
            };
            bSession.MouseClick += (sender, e) =>
            {
                //Test.BoxIndex++;
                Test.Count= (Test.Count + 1) % conditions.Count;
                BoxRenderer boxR = new BoxRenderer(Game.Context);
                Global.Window.Dispatcher.BeginInvoke(new Action(delegate { Game.ChangeRenderer(boxR); boxR.StartNew(); }));
            };

            Button bStop = new Button
            {
                Size = new System.Drawing.Size(120, 60),
                Content = "Stop",
                Position = new Vector2(0, 1020)
            };
            bStop.TouchUp += (sender, e) =>
                {
                    stopwatch.Stop();
                    Stop(new BoxEventArgs(startTime,DateTime.Now, true));
                };

            lCountDown = new Label()
                         {
                             Content = "3",
                             Position = new Vector2(800, 300),
                             IsVisible = false,
                             TextDescriptionClass = "Huge"
                         };

            rp = new TouchRayPanel { Size = Hud.Size, };//Camera = this.Camera };
            rp.SetScalingWidget(sWidget);
            rp.SetBox(box);
            rp.SetFrame((IBox)bbox);
            rp.SetArrowConditions(arrowCondition);
            rp.SetAxis(axis);
            Hud.Add(rp);
            //rp.Add(bSession);
            //rp.Add(bConnect);
            //rp.Add(bTracking);
            //
            rp.Add(bStop);
            rp.Add(bNew);
            rp.Completed += (sender, e) => ((BoxRenderer)Game.CurrentRenderer).Stop(e);

            bNew.MouseUp += delegate
                               {
                                   if (startingNewSession)
                                       return;
                                   startingNewSession = true;
                                   Hud.BeginDesign();
                                   lCountDown.IsVisible = true;
                                   Hud.Controls.Add(lCountDown);
                                   Hud.EndDesign();
                                   clock.Start();
                               };

            Hud.Init();
            Hud.EndDesign();

            Scene.BuildRenderScene();
            Hud.AddToScene(this, Scene);
            IsInited = true;
        }
コード例 #10
0
 void UpdateSprites(IEnumerable<ISpriteObject> spriteControls)
 {
     TextItems = new RenderableCollection(TextMaterial.ItemsDescription);
     tNode.RemoveAll();
     tNode.AppendChild(rNode);
     foreach (ISpriteObject spriteControl in spriteControls)
     {
         RenderableNode textNode = new RenderableNode(spriteControl.RenderableObject);
         tNode.AppendChild(textNode);
         TextItems.Add(textNode);
         textNode.Update();
     }
 }
コード例 #11
0
ファイル: TestRenderer.cs プロジェクト: yong-ja/starodyssey
        protected override void OnInit(object sender, EventArgs e)
        {
            //AvengersUtd.Odyssey.Text.TextManager.DrawText("prova");

            Camera.LookAt(Vector3.Zero, new Vector3(0,5,-10f));

            Box box = new Box(1, 1, 1);
            Sphere sphere = new Sphere(1, 16);
            Arrow arrow = new Arrow(1, 1, 3, 0.5f) { PositionV3 = new Vector3(-2.5f, 0, 0) };
            AvengersUtd.Odyssey.Graphics.Meshes.BoundingBox bbox = new AvengersUtd.Odyssey.Graphics.Meshes.BoundingBox(4);
            sphere.PositionV3 = new Vector3(0f, 3f, 0);
            RenderableNode rNodeBox = new RenderableNode(box) { Label = "RBox" };
            RenderableNode rNodeSPhere = new RenderableNode(sphere);
            RenderableNode rNodeBBox = new RenderableNode(bbox);
            FixedNode fNodeGrid = new FixedNode { Label = "fGrid", Position = Vector3.Zero };

            CameraAnchorNode coNode = new CameraAnchorNode();
            Scene.Tree.RootNode.AppendChild(fNodeGrid);
            Scene.Tree.RootNode.AppendChild(coNode);
            fNodeGrid.AppendChild(rNodeSPhere);
            fNodeGrid.AppendChildren(arrow.ToNodes());
            fNodeGrid.AppendChildren(bbox.ToNodes());

            DeviceContext.Immediate.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;

            Hud = Hud.FromDescription(Game.Context.Device,
                new HudDescription(
                    width: Game.Context.Settings.ScreenWidth,
                    height: Game.Context.Settings.ScreenHeight,
                    zNear: Game.CurrentRenderer.Camera.NearClip,
                    zFar: Game.CurrentRenderer.Camera.FarClip,
                    cameraEnabled: true,
                    multithreaded: true
                    ));
            OdysseyUI.CurrentHud = Hud;
            Hud.BeginDesign();

            Game.Logger.Log("Prova1");
            Game.Logger.Log("Prova2");
            Game.Logger.Log("Prova3");
            Game.Logger.Log("Prova4");
            Game.Logger.Log("Prova5");
            //Game.Logger.Log("Prova1");
            //Game.Logger.Log("Prova2");
            //Game.Logger.Log("Prova3");
            //Game.Logger.Log("Prova4");
            //Game.Logger.Log("Prova5");
            //Game.Logger.Log("U MAD?");
            //Game.Logger.Log("PROBLEM?");
            LogEvent.UserInterface.Write("U MAD?");
            LogEvent.Engine.Write("YO DAWG");

            TexturedIcon crosshair = new TexturedIcon
            {
                Position = new Vector2(512f, 512f),
                Size = new Size(64, 64),
                Texture = Texture2D.FromFile(Game.Context.Device, "Resources/Textures/crosshair.png")

            };

            Hud.Add(crosshair);

            //Hud.Add(new Panel
            //{
            //    Position = new Vector2(500f, 175f),
            //    Size = new Size(200, 200)
            //});

            Hud.Add(new DecoratorButton
                        {
                            Position = new Vector2(550f, 300f),
                        });

            Hud.Add(new RayPickingPanel { Size = Hud.Size, Camera = this.Camera });
            Game.Logger.Activate();
            Hud.Init();
            Hud.EndDesign();

            //Scene.BuildRenderScene();
            //Hud.AddToScene(this, Scene);
            //
            //lightSphere.SetBehaviour(new FreeMovementGamepadBehaviour(50));

            IsInited = true;
        }