示例#1
0
        void CalcBounds()
        {
            if (Meshes.Count == 0)
            {
                BoundingBox    = AABB.Empty;
                BoundingSphere = BoundSphere.Empty;
            }

            BoundingBox    = AABB.CalculateAABB(Meshes.SelectMany(M => M.GetVertices().Select(V => V.Position)));
            BoundingSphere = BoundSphere.FromAABB(BoundingBox);
        }
示例#2
0
        public AABB CalculateAABB()
        {
            AABB Bounds = MapModels[0].BoundingBox;

            for (int ModelIdx = 1; ModelIdx < MapModels.Length; ModelIdx++)
            {
                Vector3[] Verts = new Vector3[16];
                Array.Copy(Bounds.GetVertices().ToArray(), 0, Verts, 0, 8);
                Array.Copy(MapModels[ModelIdx].BoundingBox.GetVertices().ToArray(), 0, Verts, 8, 8);
                Bounds = AABB.CalculateAABB(Verts);
            }

            return(Bounds);
        }
示例#3
0
        public static void Init()
        {
            Engine.GBuffer = new RenderTexture(Engine.Window.WindowWidth, Engine.Window.WindowHeight, IsGBuffer: true);
            Engine.GBuffer.Framebuffer.SetLabel(OpenGL.ObjectIdentifier.Framebuffer, "GBuffer");

            Engine.ScreenRT = new RenderTexture(Engine.Window.WindowWidth, Engine.Window.WindowHeight);
            Engine.ScreenRT.Framebuffer.SetLabel(OpenGL.ObjectIdentifier.Framebuffer, "ScreenRT");

            Engine.ScreenQuad = new Mesh2D();
            Engine.ScreenQuad.PrimitiveType = PrimitiveType.Triangles;
            Engine.ScreenQuad.SetVertices(Utils.EmitRectangleTris(new Vertex2[6], 0, 0, 0, Engine.Window.WindowWidth, Engine.Window.WindowHeight, 0, 0, 1, 1, Color.White));
            Engine.ScreenQuad.VAO.SetLabel(OpenGL.ObjectIdentifier.VertexArray, "Screen Quad");

            var Msh = FishGfx.Formats.Obj.Load("content/models/sphere_2.obj").First();

            Vertex3[] MshVerts        = Msh.Vertices.ToArray();
            AABB      PointLightBound = AABB.CalculateAABB(MshVerts.Select(V => V.Position));

            for (int i = 0; i < MshVerts.Length; i++)
            {
                MshVerts[i].Position /= PointLightBound.Size;
            }

            Engine.PointLightMesh = new libTechMesh();
            Engine.PointLightMesh.SetVertices(MshVerts);
            Engine.PointLightMesh.SetLabel("Point Light Volume");

            // Screen framebuffer
            OpenGL.Gl.Get(OpenGL.Gl.MAX_SAMPLES, out int MaxMSAA);
            if (Engine.MSAA > MaxMSAA)
            {
                Engine.MSAA.Value = MaxMSAA;
            }

            LoadShaders();
        }