示例#1
0
 public void Update(SBViewport viewport)
 {
     TextureList.Items.Clear();
     TextureBank    = viewport.Scene.Surfaces;
     Import.Enabled = true;
     TextureList.Items.AddRange(TextureBank.ToArray());
 }
示例#2
0
 public void Update(SBViewport viewport)
 {
     if (viewport.Scene is HSDScene scene)
     {
         this.scene = scene;
         RefreshList();
     }
 }
 public void Update(SBViewport viewport)
 {
     if (viewport.Scene is SBSceneSSBH ultimate)
     {
         scene = ultimate;
         materialMode.Bind(ultimate, "MaterialMode");
     }
 }
示例#4
0
        public void Render(SBViewport viewport, float frame)
        {
            if (animation == null)
            {
                return;
            }

            if (frame != PreviousFrame)
            {
                animation.UpdateScene(frame, viewport.Scene);
            }
            PreviousFrame = frame;
        }
示例#5
0
        public void Render(SBViewport viewport, float frame = 0)
        {
            if (IsActive && PropertyGrid.SelectedObject != null && PropertyGrid.SelectedObject is SBSurface surface)
            {
                OpenTK.Graphics.OpenGL.GL.Disable(OpenTK.Graphics.OpenGL.EnableCap.DepthTest);

                if (surface.IsCubeMap)
                {
                    SkyBox.RenderSkyBox(viewport.Camera, (TextureCubeMap)surface.GetRenderTexture(), MipLevel.Value);
                }
                else
                {
                    ScreenTriangle.RenderTexture(DefaultTextures.Instance.defaultWhite);

                    ScreenTriangle.RenderTexture(surface.GetRenderTexture(),
                                                 R.BackColor != Color.Gray, G.BackColor != Color.Gray, B.BackColor != Color.Gray, A.BackColor != Color.Gray,
                                                 MipLevel.Value, surface.IsSRGB);
                }
            }
        }
示例#6
0
 public void Step(SBViewport viewport)
 {
 }
示例#7
0
 public void Render(SBViewport viewport, float frame = 0)
 {
 }
示例#8
0
 public void Update(SBViewport viewport)
 {
 }
示例#9
0
        public MainForm()
        {
            InitializeComponent();

            ApplicationSettings.Init();

            ApplicationSettings.SkinControl(this);

            // Editors that are forms
            ApplicationSettingsEditor = new SBRenderSettingsEditor();
            MaterialEditor            = new GenericMaterialEditor();

            projectTree      = new SBProjectTree();
            projectTree.Dock = DockStyle.Fill;

            LeftPane      = new SBPopoutPanel(PopoutSide.Left, ">", "<");
            LeftPane.Dock = DockStyle.Left;
            LeftPane.Contents.Add(projectTree);

            BottomPane      = new SBPopoutPanel(PopoutSide.Bottom, "Open Console", "Close Console");
            BottomPane.Dock = DockStyle.Bottom;
            BottomPane.Contents.Add(SBConsole.Console);

            MenuBar = new SBMenuBar();
            {
                var ts = new SBToolStripMenuItem("File");
                {
                    var open = new SBToolStripMenuItem("Open");
                    {
                        var folder = new SBToolStripMenuItem("Folder");
                        folder.Click       += OpenFolder;
                        folder.ShortcutKeys = Keys.O | Keys.Control | Keys.Shift | Keys.Alt;
                        open.DropDownItems.Add(folder);

                        var scene = new SBToolStripMenuItem("Scene");
                        scene.Click       += OpenFile;
                        scene.ShortcutKeys = Keys.O | Keys.Control;
                        open.DropDownItems.Add(scene);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var open = new SBToolStripMenuItem("Import");
                    {
                        var scene = new SBToolStripMenuItem("Model Into Scene");
                        scene.Click += ImportToScene;
                        open.DropDownItems.Add(scene);

                        var animimport = new SBToolStripMenuItem("Animation Into Scene");
                        animimport.Click += ImportAnimationToScene;
                        open.DropDownItems.Add(animimport);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var open = new SBToolStripMenuItem("Export");
                    {
                        var folder = new SBToolStripMenuItem("Scene to File(s)");
                        folder.Click += SaveScene;
                        open.DropDownItems.Add(folder);

                        var animexport = new SBToolStripMenuItem("Animation to File");
                        animexport.Click += ExportAnimationToFile;
                        open.DropDownItems.Add(animexport);
                    }
                    ts.DropDownItems.Add(open);
                }
                {
                    var closeWkspc = new SBToolStripMenuItem("Clear Workspace");
                    closeWkspc.Click += CloseWorkspace;
                    ts.DropDownItems.Add(closeWkspc);
                }
                MenuBar.Items.Add(ts);

                var view = new SBToolStripMenuItem("View");
                {
                    var rsettings = new SBToolStripMenuItem("Render Settings");
                    rsettings.Click += OpenRenderSettings;
                    view.DropDownItems.Add(rsettings);

                    var meditor = new SBToolStripMenuItem("Material Editor");
                    meditor.Click += OpenMaterialEditor;
                    view.DropDownItems.Add(meditor);
                }
                MenuBar.Items.Add(view);

                var viewport = new SBToolStripMenuItem("Camera");
                {
                    var resetCamera = new SBToolStripMenuItem("Reset Camera Position");
                    resetCamera.Click += Viewport_ResetCameraPosition;
                    viewport.DropDownItems.Add(resetCamera);

                    var rsettings = new SBToolStripMenuItem("Render Viewport to File");
                    rsettings.Click += ExportRenderToFile;
                    viewport.DropDownItems.Add(rsettings);
                }
                MenuBar.Items.Add(viewport);
            }
            MenuBar.Dock = DockStyle.Top;

            Viewport      = new SBViewport();
            Viewport.Dock = DockStyle.Fill;

            BoneTree             = new SBBoneTree();
            BoneTree.MaximumSize = RightBarSize;
            BoneTree.Dock        = DockStyle.Top;

            MeshList             = new SBMeshList();
            MeshList.MaximumSize = RightBarSize;
            MeshList.Dock        = DockStyle.Top;

            BoneEditor      = new SBBoneEditor();
            BoneEditor.Dock = DockStyle.Fill;

            MeshPanel      = new SBMeshPanel();
            MeshPanel.Dock = DockStyle.Fill;

            RightPane      = new SBPopoutPanel(PopoutSide.Right, "<", ">");
            RightPane.Dock = DockStyle.Right;

            animationBar      = new SBAnimationBar();
            animationBar.Dock = DockStyle.Bottom;
            animationBar.Frame.Bind(Viewport, "Frame");
            animationBar.Visible = false;

            ResetControls();

            Controls.Add(Viewport);
            Controls.Add(animationBar);
            Controls.Add(BottomPane);
            Controls.Add(RightPane);
            Controls.Add(LeftPane);
            Controls.Add(MenuBar);

            RenderTimer          = new Timer();
            RenderTimer.Interval = 1000 / 120;
            RenderTimer.Tick    += new EventHandler(InvalidateRender);
            RenderTimer.Start();

            FormClosing += MainForm_FormClosing;
            InitializeImportTypes();

            if (ApplicationSettings.LastOpenedPath != "")
            {
                projectTree.SetRoot(ApplicationSettings.LastOpenedPath);
            }
        }
示例#10
0
        public void Render(SBViewport viewport, float frame = 0)
        {
            //if (!IsActive)
            //    return;
            FlashTimer++;
            if (FlashTimer > FlashInterval)
            {
                FlashTimer = 0;
                if (FlashColor == FlashColor1)
                {
                    FlashColor = FlashColor2;
                }
                else
                {
                    FlashColor = FlashColor1;
                }
            }

            // TODO: draw with shader
            if (LVD != null)
            {
                GL.PushAttrib(AttribMask.AllAttribBits);

                GL.Disable(EnableCap.CullFace);
                GL.Clear(ClearBufferMask.DepthBufferBit);

                GL.UseProgram(0);

                GL.Color3(1f, 1f, 0);
                GL.LineWidth(2f);

                GL.PointSize(5f);
                GL.Begin(PrimitiveType.Points);
                GL.Vertex3(Picked.X, Picked.Y, Picked.Z);
                GL.End();

                RenderCollisions();

                foreach (var blast in LVD.BlastZoneBounds)
                {
                    RenderBounds(blast, Color.LightPink);
                }

                foreach (var camera in LVD.CameraBounds)
                {
                    RenderBounds(camera, Color.SkyBlue);
                }

                foreach (var blast in LVD.ShrunkBlastZoneBounds)
                {
                    RenderBounds(blast, Color.LightPink);
                }

                foreach (var camera in LVD.ShrunkCameraBounds)
                {
                    RenderBounds(camera, Color.SkyBlue);
                }

                int playerIndex = 1;
                foreach (var spawn in LVD.Spawns)
                {
                    if (PropertyGrid.SelectedObject == spawn)
                    {
                        Rendering.TextRenderer.Draw(viewport.Camera, "P" + playerIndex++, Matrix4.CreateTranslation(new Vector3(spawn.X, spawn.Y, 0)), FlashColor);
                    }
                    else
                    {
                        Rendering.TextRenderer.Draw(viewport.Camera, "P" + playerIndex++, Matrix4.CreateTranslation(new Vector3(spawn.X, spawn.Y, 0)));
                    }
                }

                foreach (var spawn in LVD.Respawns)
                {
                    if (PropertyGrid.SelectedObject == spawn)
                    {
                        Rendering.Shapes.Spawn.RenderSpawn(spawn.X, spawn.Y, 5, FlashColor);
                    }
                    else
                    {
                        Rendering.Shapes.Spawn.RenderSpawn(spawn.X, spawn.Y, 5, new Vector3(0.95f, 0.95f, 0.95f));
                    }
                }

                foreach (var point in LVD.GeneralPoints)
                {
                    Rendering.Shapes.VectorGraphicType graphic = Rendering.Shapes.VectorGraphicType.StarStorm;
                    Vector3 col = new Vector3(0.75f, 0.85f, 1);
                    if (point.EntryLabel.Contains("Ike"))
                    {
                        graphic = Rendering.Shapes.VectorGraphicType.FireEmblem;
                        col     = new Vector3(1, 0.85f, 0.75f);
                    }
                    if (point.EntryLabel.Contains("Pikmin"))
                    {
                        graphic = Rendering.Shapes.VectorGraphicType.Pikmin;
                        col     = new Vector3(0.65f, 1, 0.65f);
                    }
                    if (PropertyGrid.SelectedObject == point)
                    {
                        col = FlashColor;
                    }
                    Rendering.Shapes.VectorGraphic.RenderGraphic(graphic, Matrix4.CreateTranslation(point.X, point.Y, point.Z), col, 8);
                }

                foreach (var spawner in LVD.ItemSpawners)
                {
                    foreach (var shape in spawner.Sections)
                    {
                        RenderShape(shape);
                    }
                }

                GL.PopAttrib();
            }

            if (PropertyGrid.SelectedObject is LVDVector2)
            {
                Rendering.TextRenderer.DrawOrtho(viewport.Camera, "Alt+Mouse: Move Point", new Vector2(4, viewport.Camera.RenderHeight - 30));
                Rendering.TextRenderer.DrawOrtho(viewport.Camera, "Alt + A  : Add Point", new Vector2(4, viewport.Camera.RenderHeight - 16));
                Rendering.TextRenderer.DrawOrtho(viewport.Camera, "Delete   : Delete", new Vector2(4, viewport.Camera.RenderHeight - 2));
            }
            else
            {
                Rendering.TextRenderer.DrawOrtho(viewport.Camera, "Double Click to Select", new Vector2(4, viewport.Camera.RenderHeight - 16));
            }
        }
示例#11
0
        public void Step(SBViewport viewport)
        {
            var mouseP     = viewport.GetMousePosition();
            var deltaMouse = PrevMousePosition - mouseP;

            PrevMousePosition = mouseP;
            if (!IsActive)
            {
                return;
            }
            if (Keyboard.GetState().IsKeyDown(Key.AltLeft))
            {
                if (Keyboard.GetState().IsKeyDown(Key.A))
                {
                    if (!ADown)
                    {
                        ADown = true;

                        if (PropertyGrid.SelectedObject is LVDVector2 v)
                        {
                            AddNewPoint(v);
                        }
                    }
                }
                else
                {
                    ADown = false;
                }
                if (Mouse.GetState().IsButtonDown(MouseButton.Left))
                {
                    if (PropertyGrid.SelectedObject is LVDGeneralPoint point)
                    {
                        point.StartPosition.X -= deltaMouse.X / 4;
                        point.StartPosition.Y += deltaMouse.Y / 4;
                        point.X -= deltaMouse.X / 4;
                        point.Y += deltaMouse.Y / 4;
                        PropertyGrid.SelectedObject = PropertyGrid.SelectedObject;
                    }
                    if (PropertyGrid.SelectedObject is LVDSpawn spawn)
                    {
                        spawn.StartPosition.X -= deltaMouse.X / 4;
                        spawn.StartPosition.Y += deltaMouse.Y / 4;
                        spawn.X -= deltaMouse.X / 4;
                        spawn.Y += deltaMouse.Y / 4;
                        PropertyGrid.SelectedObject = PropertyGrid.SelectedObject;
                    }
                    if (PropertyGrid.SelectedObject is LVDVector2 v)
                    {
                        v.X -= deltaMouse.X / 4;
                        v.Y += deltaMouse.Y / 4;

                        // recalculate normals
                        // is there a better way to do this?
                        foreach (var col in LVD.Collisions)
                        {
                            int index = col.Vertices.IndexOf(v);
                            if (index == -1)
                            {
                                continue;
                            }

                            if (index < col.Normals.Count)
                            {
                                col.Normals[index] = LVDVector2.GenerateNormal(v, col.Vertices[index + 1]);
                            }
                            if (index > 0)
                            {
                                col.Normals[index - 1] = LVDVector2.GenerateNormal(col.Vertices[index - 1], v);
                            }
                            break;
                        }
                        PropertyGrid.SelectedObject = PropertyGrid.SelectedObject;
                    }
                }
            }
            if (Keyboard.GetState().IsKeyDown(Key.Delete))
            {
                if (!DeleteDown)
                {
                    DeleteDown = true;

                    if (PropertyGrid.SelectedObject is LVDVector2 v)
                    {
                        DeleteVertex(v);
                    }
                }
            }
            else
            {
                DeleteDown = false;
            }
        }