Ejemplo n.º 1
0
 /// <summary>
 ///     Disposes the used resources (geometries and content).
 /// </summary>
 public void Dispose()
 {
     LineSegment.Dispose();
     Sphere.Dispose();
     Cube.Dispose();
     Disk.Dispose();
     Cylinder.Dispose();
     Effect.Dispose();
     Content.Dispose();
 }
Ejemplo n.º 2
0
        public override void Dispose()
        {
            //RemoveAssembly(this);
            cylinder.Dispose();
            leftCube.Dispose();
            rightCube.Dispose();

            if (OnPhotocellDisplayDeleted != null)
            {
                OnPhotocellDisplayDeleted(this, new EventArgs());
            }

            base.Dispose();
        }
Ejemplo n.º 3
0
        public void RunMainLoop(Control control)
        {
            using (var loop = new RenderLoop(control))
                while (loop.NextFrame())
                {
                    MainLoop(control.Size);
                }

            // main loop is done; release resources

            arrowDefault.Dispose();
            whiteDefault.Dispose();
            TextureManager.DisposeTextures();

            Cube.Dispose();
            Pyramid.Dispose();
            Cylinder.Dispose();
            Sphere.Dispose();
            Plane.Dispose();

            basicBuffer.Dispose();
            basicShader.Dispose();

            defaultBuffer.Dispose();
            defaultShader.Dispose();

            tintedBuffer.Dispose();
            tintedShader.Dispose();

            foreach (SharpMesh mesh in RenderWareModelFile.completeMeshList)
            {
                if (mesh != null)
                {
                    mesh.Dispose();
                }
            }

            foreach (var bf in completeVertexBufferList)
            {
                if (bf != null)
                {
                    bf.Dispose();
                }
            }

            device.Dispose();
        }
Ejemplo n.º 4
0
        public void RunMainLoop(Panel Panel, MainForm.MainForm mainForm)
        {
            RenderLoop.Run(Panel, () =>
            {
                if (dontRender)
                {
                    return;
                }

                //Resizing
                if (Device.MustResize)
                {
                    Device.Resize();
                    Camera.ProjectionMatrix.AspectRatio = (float)Panel.Width / Panel.Height;
                }

                mainForm.KeyboardController();
                mainForm.SetToolStripStatusLabel(Camera + " FPS: " + $"{SharpFps.StatFPS:0.0000}");

                //clear color
                Device.Clear(backgroundColor);

                //Set matrices
                viewProjection = Camera.ViewMatrix.GetViewMatrix() * Camera.ProjectionMatrix.GetProjectionMatrix();
                frustum        = new BoundingFrustum(viewProjection);

                mainForm.TexturePatternEditor.Animate();

                if (ShowCollision)
                {
                    foreach (var c in mainForm.CollisionEditorDict.Values)
                    {
                        c.RenderCollisionModel(this);
                    }
                    mainForm.LevelEditor.RenderShadowCollisionModel(this);
                }
                else
                {
                    mainForm.LevelEditor.RenderLevelModel(this);
                }

                if (ShowChunkBoxes)
                {
                    mainForm.LevelEditor.visibilityFunctions.RenderChunkModels(this);
                }

                if (ShowObjects == CheckState.Checked)
                {
                    foreach (var l in mainForm.LayoutEditorDict.Values)
                    {
                        l.RenderSetObjects(this, true);
                    }
                }
                else if (ShowObjects == CheckState.Indeterminate)
                {
                    foreach (var l in mainForm.LayoutEditorDict.Values)
                    {
                        l.RenderSetObjects(this, false);
                    }
                }

                if (ShowCameras)
                {
                    mainForm.CameraEditor.RenderCameras(this);
                }

                if (ShowStartPositions)
                {
                    mainForm.ConfigEditor.RenderStartPositions(this);
                }

                if (ShowSplines)
                {
                    mainForm.ConfigEditor.SplineEditor.RenderSplines(this);
                    mainForm.LevelEditor.shadowSplineEditor.RenderSplines(this);
                }

                if (ShowQuadtree)
                {
                    foreach (var c in mainForm.CollisionEditorDict.Values)
                    {
                        c.RenderQuadtree(this);
                    }
                }

                //present
                Device.Present();
                SharpFps.EndFrame();
            });

            //release resources

            whiteDefault.Dispose();
            mainForm.LevelEditor.bspRenderer.Dispose();
            TextureManager.DisposeTextures();
            dffRenderer.Dispose();
            foreach (var c in mainForm.CollisionEditors)
            {
                c.DisposeRenderStuff();
            }
            mainForm.ConfigEditor.SplineEditor.DisposeSplines();

            Cube.Dispose();
            Pyramid.Dispose();
            Cylinder.Dispose();
            Sphere.Dispose();

            basicBuffer.Dispose();
            basicShader.Dispose();

            defaultBuffer.Dispose();
            defaultShader.Dispose();

            collisionBuffer.Dispose();
            collisionShader.Dispose();

            tintedBuffer.Dispose();
            tintedShader.Dispose();

            Device.Dispose();
        }
Ejemplo n.º 5
0
        public void RunMainLoop(Panel Panel)
        {
            RenderLoop.Run(Panel, () =>
            {
                //Resizing
                if (device.MustResize)
                {
                    device.Resize();
                    Camera.AspectRatio = (float)Panel.Width / Panel.Height;
                }

                Program.MainForm.KeyboardController();

                sharpFPS.Update();

                device.Clear(backgroundColor);

                if (ArchiveEditorFunctions.allowRender)
                {
                    if (isDrawingUI)
                    {
                        viewProjection = Matrix.OrthoOffCenterRH(0, 640, -480, 0, -Camera.FarPlane, Camera.FarPlane);

                        device.SetFillModeDefault();
                        device.SetCullModeDefault();
                        device.ApplyRasterState();
                        device.SetBlendStateAlphaBlend();
                        device.SetDefaultDepthState();
                        device.UpdateAllStates();

                        foreach (IRenderableAsset a in
                                 (from IRenderableAsset asset in ArchiveEditorFunctions.renderableAssets
                                  where (asset is AssetUI || asset is AssetUIFT) && asset.ShouldDraw(this)
                                  select(IClickableAsset) asset).OrderBy(f => - f.PositionZ))
                        {
                            a.Draw(this);
                        }
                    }
                    else
                    {
                        if (playingFly)
                        {
                            flyToPlay.Play();
                        }

                        Program.MainForm.SetToolStripStatusLabel(Camera.ToString() + " FPS: " + $"{sharpFPS.FPS:0.0000}");

                        Matrix view    = Camera.ViewMatrix;
                        viewProjection = view * Camera.ProjectionMatrix;
                        frustum        = new BoundingFrustum(view * Camera.BiggerFovProjectionMatrix);

                        device.SetFillModeDefault();
                        device.SetCullModeDefault();
                        device.ApplyRasterState();
                        device.SetDefaultDepthState();
                        device.UpdateAllStates();

                        foreach (var a in ArchiveEditorFunctions.renderableJSPs)
                        {
                            if (a.ShouldDraw(this))
                            {
                                a.Draw(this);
                            }
                        }

                        foreach (IRenderableAsset a in ArchiveEditorFunctions.renderableAssets)
                        {
                            if (a.ShouldDraw(this))
                            {
                                renderableAssets.Add(a);
                            }
                            else
                            {
                                renderableAssets.Remove(a);
                            }
                        }

                        //foreach (IRenderableAsset a in renderableAssets.OrderByDescending(a => a.GetDistanceFrom(Camera.Position)))
                        //    a.Draw(this);

                        HashSet <IRenderableAsset> renderableAssetsTrans = new HashSet <IRenderableAsset>();

                        foreach (IRenderableAsset a in renderableAssets)
                        {
                            if (a.SpecialBlendMode)
                            {
                                renderableAssetsTrans.Add(a);
                            }
                            else
                            {
                                a.Draw(this);
                            }
                        }

                        foreach (IRenderableAsset a in renderableAssetsTrans.OrderByDescending(a => a.GetDistanceFrom(Camera.Position)))
                        {
                            a.Draw(this);
                        }
                    }
                }

                device.SetCullModeNone();
                device.ApplyRasterState();
                device.SetBlendStateAlphaBlend();
                device.UpdateAllStates();

                ArchiveEditorFunctions.RenderGizmos(this);

                device.Present();
            });

            //release resources
            whiteDefault.Dispose();
            TextureManager.DisposeTextures();

            Cube.Dispose();
            Pyramid.Dispose();
            Cylinder.Dispose();
            Sphere.Dispose();
            Plane.Dispose();

            basicBuffer.Dispose();
            basicShader.Dispose();

            defaultBuffer.Dispose();
            defaultShader.Dispose();

            tintedBuffer.Dispose();
            tintedShader.Dispose();

            foreach (SharpMesh mesh in RenderWareModelFile.completeMeshList)
            {
                if (mesh != null)
                {
                    mesh.Dispose();
                }
            }

            foreach (var bf in completeVertexBufferList)
            {
                if (bf != null)
                {
                    bf.Dispose();
                }
            }

            device.Dispose();
        }