public void Draw(RenderContext context)
        {
            double        height   = heightInFeet / 300000;
            RenderContext context2 = new RenderContext(context.graphicsDevice, Matrixd.CreateTranslation(new Vector3d(0, 0, height)) * context.WVP, context.minX, context.maxX, context.minY, context.maxY, context.cameraZoom, context.layerPass);

            buffer.Draw(context2, PrimitiveType.TriangleList, null, roofColor.ToVector3());
            buffer2.Draw(context, PrimitiveType.TriangleList, wallTexture, null);
        }
Beispiel #2
0
        private Matrixd CreateShipWVP(RenderContext renderContext, double rotation)
        {
            double   fakeScale = Math.Max(Math.Pow(2, 21 - camera.cameraZoom), 1); // make the ship bigger to account for depth buffer limitations
            Vector3d shipPos   = position;
            // earth radius 6371 km
            double  shipScale          = fakeScale / 6371000;
            double  distanceFromCamera = 30;                                                                             // in meters
            Matrixd world    = Matrixd.CreateRotationZ(-camera.cameraRotX) * Matrixd.CreateRotationX(camera.cameraRotY); // eh.... think hard on this later
            double  distance = 9 * Math.Pow(0.5, camera.cameraZoom);

            shipPos += position.WalkNorth(-Math.PI / 4) * (distance * 2 - distanceFromCamera * shipScale); // why distance * 2??
            Matrixd view       = CameraMatrixManager.GetWorldViewd(distance);
            Matrixd projection = CameraMatrixManager.GetWorldProjectiond(distance, renderContext.graphicsDevice.Viewport.AspectRatio);
            Matrixd worldWVP   = world * view * projection;
            Matrixd shipRot    = Matrixd.CreateRotationZ(rotation + Math.PI) * Matrixd.CreateRotationX(Math.PI / 2 - camera.cameraRotY) * Matrixd.CreateRotationZ(camera.cameraRotX);

            return(shipRot * Matrixd.CreateScale(shipScale) * Matrixd.CreateTranslation(shipPos) * worldWVP);
        }