Ejemplo n.º 1
0
        private static Vector3d SetupShadow(RenderContext11 renderContext, Vector3d centerPoint, float width, SolarSystemObjects shadowCaster, int shadowIndex)
        {
            var device = renderContext.Device;

            if (PlanetShadow == null)
            {
                PlanetShadow = Texture11.FromBitmap(device, Resources.planetShadow);
            }

            var invViewCam = renderContext.View;
            invViewCam.Invert();

            var sun = planet3dLocations[0];
            sun.Subtract(centerPoint);

            var moon = planet3dLocations[(int)shadowCaster];
            moon.Subtract(centerPoint);

            var biasd = Matrix3d.Scaling(0.5, 0.5, 0.5) * Matrix3d.Translation(new Vector3d(0.5, 0.5, 0.5));

            var mat =
                invViewCam *
                Matrix3d.LookAtLH(sun, moon, new Vector3d(0, 1, 0)) *
                Matrix3d.PerspectiveFovLH(width, 1, 0.001f, 200f) *
                biasd;

            renderContext.SetEclipseShadowMatrix(shadowIndex, mat.Matrix11);

            return centerPoint;
        }