Exemple #1
0
        public void Render(ModelPart modelPart)
        {
            var renderArgs = new RenderArgs(modelPart);

            modelPart.SetRenderArgsSelection(renderArgs);

            WorldMatrix = modelPart.GetAnchorRotationAndPositionMatrix() * WorldMatrix;

            ModelPart(modelPart, renderArgs, false);

            var wireframeMode = Wireframe;

            if (RenderAnchors)
            {
                Wireframe = true;

                foreach (var anchor in modelPart.Anchors)
                {
                    Anchor(anchor);
                }

                Wireframe = wireframeMode;
            }

            var bMat = WorldMatrix;

            foreach (var anchor in modelPart.Anchors)
            {
                if (!anchor.HasChildren)
                    continue;

                WorldMatrix = Matrix.Translation(anchor.Position) * WorldMatrix;
                var wMat = WorldMatrix;

                foreach (var child in anchor.Children)
                {
                    WorldMatrix = Matrix.Translation(child.Position) * WorldMatrix;

                    Render(child);
                    WorldMatrix = wMat;
                }
            }

            WorldMatrix = bMat;
        }