Beispiel #1
0
        public Bitmap CreateMapTile(Viewport viewport, bool useTextures)
        {
            m_colors.Clear();

            int width  = viewport.Width;
            int height = viewport.Height;

            WarpRenderer renderer = new WarpRenderer();

            if (!renderer.CreateScene(width, height))
            {
                return(new Bitmap(width, height));
            }

            #region Camera

            warp_Vector pos    = ConvertVector(viewport.Position);
            warp_Vector lookat = warp_Vector.add(ConvertVector(viewport.Position), ConvertVector(viewport.LookDirection));

            renderer.Scene.defaultCamera.setPos(pos);
            renderer.Scene.defaultCamera.lookAt(lookat);

            if (viewport.Orthographic)
            {
                renderer.Scene.defaultCamera.setOrthographic(true, viewport.OrthoWindowWidth, viewport.OrthoWindowHeight);
            }
            else
            {
                float fov = viewport.FieldOfView;
                fov *= 1.75f; // FIXME: ???
                renderer.Scene.defaultCamera.setFov(fov);
            }

            #endregion Camera

            renderer.Scene.addLight("Light1", new warp_Light(new warp_Vector(1.0f, 0.5f, 1f), 0xffffff, 0, 320, 40));
            renderer.Scene.addLight("Light2", new warp_Light(new warp_Vector(-1f, -1f, 1f), 0xffffff, 0, 100, 40));

            CreateWater(renderer);
            CreateTerrain(renderer, m_textureTerrain);
            if (m_drawPrimVolume)
            {
                CreateAllPrims(renderer, useTextures);
            }

            renderer.Render();
            Bitmap bitmap = renderer.Scene.getImage();

            renderer.Scene.destroy();
            renderer.Reset();
            renderer = null;
            viewport = null;

            m_colors.Clear();
            GC.Collect();
            m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()");

            return(bitmap);
        }