Exemplo n.º 1
0
        private void HierarchyRename_Click(object sender, RoutedEventArgs e)
        {
            string new_name = Prompt.ShowDialog(GetEntityName(Hierarchy.SelectedIndex), "Change Name");

            SetEntityName(Hierarchy.SelectedIndex, new_name);

            UnrealScienceScripting.ChangeName(new_name);
        }
Exemplo n.º 2
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            UnrealScienceScripting.CleanUI();

            foreach (DraggableLabel l in elements)
            {
                UnrealScienceScripting.AddText2D(l.Text, l.FontName, (int)l.PositionX, (int)l.PositionY, (int)l.SizeX, (int)l.SizeY, (int)l.fontSize);
            }
        }
Exemplo n.º 3
0
        void Resize()
        {
            if (loaded)
            {
                float aspectRatio = panel.Height / (panel.Width * 1.0f);

                UnrealScienceScripting.ResizeViewport(aspectRatio);
            }
        }
Exemplo n.º 4
0
        private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            UnrealScienceScripting.ChangeCameraSpeed((float)CameraSpeed.Value);

            if (host != null)
            {
                host.Focus();
            }
        }
Exemplo n.º 5
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            List <AnimationKey> SceneKeys = new List <AnimationKey>();

            for (int i = 0; i < Keys.Items.Count; i++)
            {
                AnimationKey key = (Keys.Items[i] as ListBoxItem).Tag as AnimationKey;

                SceneKeys.Add(key);
            }

            UnrealScienceScripting.PushAnimationKeys(SceneKeys);
        }
Exemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            UnrealScienceScripting.SetPlaying();

            unsafe
            {
                UnrealScienceScripting.InitD3D(panel.Handle.ToPointer(),
                                               System.Windows.Forms.SystemInformation.VirtualScreen.Width,
                                               System.Windows.Forms.SystemInformation.VirtualScreen.Height);

                loaded = true;
            }


            UnrealScienceScripting.InitWorld();

            timer = new System.Windows.Forms.Timer();

            timer.Interval = 10;

            timer.Tick += timer_Tick;

            timer.Start();

            Scripting = new UnrealScienceScripting();

            Scripting.InitScripting();

            Scripting.InitAnimationScripting();

            if (UnrealScienceScripting.World.Entities.Count != 0)
            {
                Scripting.isPlaying = true;
                CreateScene(UnrealScienceScripting.World);
                isArray = true;
            }
            else if (Reader.Scene != null)
            {
                Scripting.isPlaying = true;
                CreateScene(Reader.Scene);
            }

            Resize();

            InitSpeech();
        }
Exemplo n.º 7
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string formula = ProcessFormula(Function.Text);

            float xMin = XMin.Value;
            float xMax = XMax.Value;

            float yMin = YMin.Value;
            float yMax = YMax.Value;

            float step = Step.Value;

            int type = GraphType.SelectedIndex;

            UnrealScienceScripting.SetType(type + 1);

            UnrealScienceScripting.ResetGraph3D();

            BuildGraph(xMin, xMax, yMin, yMax, step, formula);

            UnrealScienceScripting.InitializeGraph();
        }
Exemplo n.º 8
0
        private void BuildGraph(float xMin, float xMax, float yMin, float yMax, float step, string formula)
        {
            SetZFunction(this, formula);

            List <Vector3D> v = new List <Vector3D>();

            for (float x = xMin; x <= xMax; x += step)
            {
                for (float y = yMin; y <= yMax; y += step)
                {
                    float z = Z.Invoke(x, y);

                    Vector3D vector = new Vector3D(x, y, z);

                    v.Add(vector);

                    //UnrealScienceScripting.AddGraph3DVertex(x, y, z, 50, 50, 50);
                }
            }

            float[] xArr = new float[v.Count];
            float[] yArr = new float[v.Count];
            float[] zArr = new float[v.Count];

            for (int i = 0; i < v.Count; i++)
            {
                xArr[i] = v[i].X;
                yArr[i] = v[i].Y;
                zArr[i] = v[i].Z;
            }

            UnrealScienceScripting.BuildGraph3D(xArr, yArr, zArr, v.Count);

            //for (int i = 0; i < 10; i++)
            //{
            //    UnrealScienceScripting.AddGraph3DVertex(i, i, i, i, i, i);
            //}
        }
Exemplo n.º 9
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            UnrealScienceScripting.Cleanup();

            base.OnClosing(e);
        }
Exemplo n.º 10
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog d = new OpenFileDialog();

            d.Filter = "Unreal Science Scene files (*.usscene)|*.usscene";

            d.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString();



            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK && d.FileName.Length > 0)
            {
                if (System.Windows.MessageBox.Show("Do you want to save the scene?", "Save?", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    SaveFileDialog save = new SaveFileDialog();

                    save.Filter = "Unreal Science Scene files (*.usscene)|*.usscene";

                    save.InitialDirectory = Environment.SpecialFolder.MyDocuments.ToString();

                    if (save.ShowDialog() == System.Windows.Forms.DialogResult.OK && save.FileName.Length > 0)
                    {
                        SaveSceneTo(save.FileName);
                    }
                }

                SavedFilename = d.FileName;

                UnrealScienceScripting.Cleanup();
                UnrealScienceScripting.CleanUI();

                UnrealScienceScripting.World.Entities.Clear();
                Hierarchy.Items.Clear();

                Read r = new Read();

                Scripting.isPlaying = false;

                r.Deserialize(d.FileName);

                #region entities
                foreach (SceneEntity s in r.Scene.Entities)
                {
                    Scripting.ScriptingManager.Parse(s.CreationCommand);

                    Scripting.ScriptingManager.Parse(String.Format("move {0} {1} {2}",
                                                                   s.Transform.Position.X,
                                                                   s.Transform.Position.Y,
                                                                   s.Transform.Position.Z));

                    Scripting.ScriptingManager.Parse(String.Format("rotate {0} {1} {2}",
                                                                   s.Transform.Rotation.X,
                                                                   s.Transform.Rotation.Y,
                                                                   s.Transform.Rotation.Z));

                    Scripting.ScriptingManager.Parse(String.Format("scale {0} {1} {2}",
                                                                   s.Transform.Scale.X,
                                                                   s.Transform.Scale.Y,
                                                                   s.Transform.Scale.Z));

                    Scripting.ScriptingManager.Parse("setTexture " + s.Texture);

                    Scripting.ScriptingManager.Parse(String.Format("setColor {0} {1} {2}", s.Color.X, s.Color.Y, s.Color.Z));

                    if (s.Animation.AnimationKeys.Count != 0)
                    {
                        foreach (AnimationKey key in s.Animation.AnimationKeys)
                        {
                            Vector3D v = new Vector3D();

                            if (key.KeyType == 1)
                            {
                                v = key.Destination.Position;
                            }
                            else if (key.KeyType == 2)
                            {
                                v = key.Destination.Rotation;
                            }
                            else if (key.KeyType == 3)
                            {
                                v = key.Destination.Scale;
                            }

                            string type = "";

                            if (key.KeyType == 1)
                            {
                                type = "position";
                            }
                            else if (key.KeyType == 2)
                            {
                                type = "rotation";
                            }
                            else if (key.KeyType == 3)
                            {
                                type = "scale";
                            }

                            Scripting.AnimationManager.Parse(String.Format("setKey {0} {1} {2} {3} {4} {5}",
                                                                           type, key.StartOrder, key.Duration, v.X, v.Y, v.Z));
                        }
                    }
                }
                #endregion

                #region create_UI

                foreach (UnrealScienceLibrary.UIElement element in r.Scene.Elements)
                {
                    if (element is Text2D)
                    {
                        //Scripting.ScriptingManager.Parse("addText {0} {1} {2} {3} {4} {5}",
                        //    (element as Text2D).Text, );

                        Text2D t = element as Text2D;

                        UnrealScienceScripting.AddText2D(t.Text, t.FontName, (int)t.Position.X, (int)t.Position.Y, (int)t.Scale.X, (int)t.Scale.Y, (int)t.FontSize);
                    }
                }

                #endregion
            }
        }
Exemplo n.º 11
0
        private void host_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            float aspectRatio = panel.Height / (panel.Width * 1.0f);

            UnrealScienceScripting.ResizeViewport(aspectRatio);
        }
Exemplo n.º 12
0
        void timer_Tick(object sender, EventArgs e)
        {
            c = COMMANDS.NONE;


            if (isHold)
            {
                panel.Cursor = System.Windows.Forms.Cursors.Hand;
            }
            if (host.IsKeyboardFocused)
            {
                if (Keyboard.IsKeyDown(Key.W))
                {
                    c = COMMANDS.EDITOR_MOVE_FORWARD;
                }
                if (Keyboard.IsKeyDown(Key.S))
                {
                    c = COMMANDS.EDITOR_MOVE_BACKWARD;
                }

                if (Keyboard.IsKeyDown(Key.A))
                {
                    c = COMMANDS.EDITOR_MOVE_LEFT;
                }

                if (Keyboard.IsKeyDown(Key.D))
                {
                    c = COMMANDS.EDITOR_MOVE_RIGHT;
                }

                if (Keyboard.IsKeyDown(Key.LeftAlt))
                {
                    p = GetMousePositionWindowsForms();

                    c = COMMANDS.EDITOR_ALT;

                    //box.Text += 2 * p.X / (panel.Width) + " " + 2 * p.Y / (panel.Height)  + "\n";
                }

                if (Keyboard.IsKeyDown(Key.Q))
                {
                    c = COMMANDS.EDITOR_ROTATE_LEFT;
                }

                if (Keyboard.IsKeyDown(Key.E))
                {
                    c = COMMANDS.EDITOR_ROTATE_RIGHT;
                }

                if (Keyboard.IsKeyDown(Key.Z))
                {
                    c = COMMANDS.EDITOR_ROTATE_UP;
                }

                if (Keyboard.IsKeyDown(Key.X))
                {
                    c = COMMANDS.EDITOR_ROTATE_DOWN;
                }

                if (Keyboard.IsKeyDown(Key.LeftCtrl) && Keyboard.IsKeyToggled(Key.T))
                {
                    c = COMMANDS.EDITOR_ROTATE_TOP;
                }
            }



            if (host.IsFocused)
            {
                UnrealScienceScripting.TestUpdate((int)c, (float)difference.X, (float)difference.Y);
            }



            //Update();
            UnrealScienceScripting.Render();



            //Update();
        }
Exemplo n.º 13
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            unsafe
            {
                UnrealScienceScripting.InitD3D(panel.Handle.ToPointer(),
                                               System.Windows.Forms.SystemInformation.VirtualScreen.Width,
                                               System.Windows.Forms.SystemInformation.VirtualScreen.Height);
            }


            UnrealScienceScripting.InitWorld();

            timer = new System.Windows.Forms.Timer();

            //IntPtr hinstance = /*Marshal.GetHINSTANCE(typeof(MainWindow).Module)*/System.Diagnostics.Process.GetCurrentProcess().Handle;
            //IntPtr hInst = Marshal.GetHINSTANCE(this.GetType().Module);

            //unsafe
            //{
            //    bool t = InitInput(hInst.ToPointer());
            //}



            timer.Interval = 10;

            timer.Tick += timer_Tick;

            timer.Start();

            //InitScripting();

            Scripting = new UnrealScienceScripting();

            Scripting.InitScripting();

            Scripting.AddEntity         = new Action <int>(AddEntity);
            Scripting.Select_Entity     = new Action <int>(Select_Entity);
            Scripting.RemoveEntity      = new Action <int>(RemoveEntity);
            Scripting.ChangeEntityColor = new Action <int>(ChangeColor);

            PropertyGrid.PositionChanged = new Action(MoveEntity);
            PropertyGrid.RotationChanged = new Action(RotateEntity);
            PropertyGrid.ScaleChanged    = new Action(ScaleEntity);

            PropertyGrid.TextureChanged = new Action(SetTexture);

            PropertyGrid.ColorChanged = new Action(SetColor);

            PropertyGrid.InitGrid();



            //InitAnimationScripting();

            Scripting.InitAnimationScripting();

            Scripting.ScriptingManager.functions.Remove("startAnimation");
            Scripting.ScriptingManager.functions.Remove("next");
            Scripting.ScriptingManager.functions.Remove("prev");

            PropertyGrid.Visibility = System.Windows.Visibility.Collapsed;
        }
Exemplo n.º 14
0
        public void CreateScene(Scene World)
        {
            #region generate_world
            foreach (SceneEntity s in World.Entities)
            {
                Scripting.ScriptingManager.Parse(s.CreationCommand);

                Scripting.ScriptingManager.Parse(String.Format("move {0} {1} {2}",
                                                               s.Transform.Position.X,
                                                               s.Transform.Position.Y,
                                                               s.Transform.Position.Z));

                Scripting.ScriptingManager.Parse(String.Format("rotate {0} {1} {2}",
                                                               s.Transform.Rotation.X,
                                                               s.Transform.Rotation.Y,
                                                               s.Transform.Rotation.Z));

                Scripting.ScriptingManager.Parse(String.Format("scale {0} {1} {2}",
                                                               s.Transform.Scale.X,
                                                               s.Transform.Scale.Y,
                                                               s.Transform.Scale.Z));

                Scripting.ScriptingManager.Parse("setTexture " + s.Texture);

                Scripting.ScriptingManager.Parse(String.Format("setColor {0} {1} {2}", s.Color.X, s.Color.Y, s.Color.Z));

                if (s.Animation.AnimationKeys.Count != 0)
                {
                    foreach (AnimationKey key in s.Animation.AnimationKeys)
                    {
                        Vector3D v = new Vector3D();

                        if (key.KeyType == 1)
                        {
                            v = key.Destination.Position;
                        }
                        else if (key.KeyType == 2)
                        {
                            v = key.Destination.Rotation;
                        }
                        else if (key.KeyType == 3)
                        {
                            v = key.Destination.Scale;
                        }

                        string type = "";

                        if (key.KeyType == 1)
                        {
                            type = "position";
                        }
                        else if (key.KeyType == 2)
                        {
                            type = "rotation";
                        }
                        else if (key.KeyType == 3)
                        {
                            type = "scale";
                        }

                        Scripting.AnimationManager.Parse(String.Format("setKey {0} {1} {2} {3} {4} {5}",
                                                                       type, key.StartOrder, key.Duration, v.X, v.Y, v.Z));
                    }
                }



                if (s.Animation.AnimationKeys.Count != 0)
                {
                    Scripting.ScriptingManager.Parse("startAnimation");
                }
            }
            //Scripting.ScriptingManager.Parse("select 1");
            #endregion

            #region create_UI

            foreach (UnrealScienceLibrary.UIElement element in World.Elements)
            {
                if (element is Text2D)
                {
                    //Scripting.ScriptingManager.Parse("addText {0} {1} {2} {3} {4} {5}",
                    //    (element as Text2D).Text, );

                    Text2D t = element as Text2D;

                    //UnrealScienceScripting.AddSprite2D("back.jpg", (int)t.Position.X, (int)t.Position.Y, 1000, 500);

                    UnrealScienceScripting.AddText2D(t.Text, t.FontName, (int)t.Position.X, (int)t.Position.Y, (int)t.Scale.X, (int)t.Scale.Y, (int)t.FontSize);
                }
            }

            UnrealScienceScripting.InitializeUI();



            #endregion
        }