Esempio n. 1
0
        private void RenderRec(SceneObject obj, Matrix4x4 parentMatrix, RenderFrameData frameData)
        {
            var model = obj.Matrix * parentMatrix;
            var color = GetColor(obj, frameData.DefaultColor);

            if (obj is IRenderableObj renderableObj)
            {
                Render(renderableObj, model, frameData, color);
            }

            if (obj is IScreenRenderable screenRenderable)
            {
                Render(screenRenderable, model, frameData, color);
            }

            if (_scene.SelectedObject != null && obj.Id == _scene.SelectedObject.Id)
            {
                if (obj is IIntersectionRenderableObj intersectionRenderableObj)
                {
                    RenderIntersect(intersectionRenderableObj.IntersectionGetRenderData0(), 0);
                    RenderIntersect(intersectionRenderableObj.IntersectionGetRenderData1(), 1);
                }
            }

            foreach (var child in obj.Children)
            {
                RenderRec(child, model, frameData);
            }

            foreach (var child in obj.HiddenChildren)
            {
                RenderRec(child, model, frameData);
            }
        }
Esempio n. 2
0
        private void Render(IRenderableObj obj, Matrix4x4 model, RenderFrameData frameData, Color color)
        {
            var data   = obj.GetRenderData();
            var matrix = model * frameData.ViewProjMatrix;

            foreach (var vert in data.Vertices)
            {
                var v = matrix.Multiply(vert.ToVector4());

                if (v.Z > 0)
                {
                    DrawVertex(v, color, frameData.AddColors);
                }
            }

            foreach (var edge in data.Edges)
            {
                var vertA = matrix.Multiply(data.Vertices[edge.IdxA].ToVector4());
                var vertB = matrix.Multiply(data.Vertices[edge.IdxB].ToVector4());

                if (vertA.Z > 0 && vertB.Z > 0)
                {
                    DrawLine(vertA, vertB, color, frameData.AddColors);
                }
            }
        }
Esempio n. 3
0
        private void Render(Matrix4x4 projMatrix, Color color, bool addColors)
        {
            var view = GetViewMatrix();

            var frameData = new RenderFrameData()
            {
                AddColors      = addColors,
                DefaultColor   = color,
                ViewProjMatrix = view * projMatrix,
            };

            RenderRec(_scene, Matrix4x4.Identity, frameData);
        }
Esempio n. 4
0
        private void Render(IScreenRenderable obj, Matrix4x4 model, RenderFrameData frameData, Color color)
        {
            var data = obj.GetScreenRenderData();

            var cameraCenter = new Vector4(0, 0, 0, 1);

            foreach (var pix in data.CameraPixels)
            {
                DrawOnScren(cameraCenter, pix, color, frameData.AddColors);
            }

            var matrix = model * frameData.ViewProjMatrix;
            var center = matrix.Multiply(new Vector4(0, 0, 0, 1));

            if (center.Z > 0)
            {
                foreach (var pix in data.Pixels)
                {
                    DrawOnScren(center, pix, color, frameData.AddColors);
                }
            }
        }