Beispiel #1
0
        /// <summary>
        /// Generates a renderthread and graphics related data structures
        /// </summary>
        /// <param name="whatControl">The GLControl to use for rendering</param>
        /// <param name="whatMap">The map to render in the control</param>
        public Renderer(GLControl whatControl, WorldMap whatMap, AstarInterface whatInterface)
        {
            if (whatInterface == null)
            {
                throw new ArgumentNullException("whatInterface", "Cannot get selector position from non-existing interface.");
            }
            AstarInterface = whatInterface;
            if (whatMap == null)
            {
                throw new ArgumentNullException("whatMap", "Cannot render a non-existing map");
            }
            map = whatMap;
            if (whatControl == null)
            {
                throw new ArgumentNullException("whatControl", "Cannot use a non-existing GLControl for rendering");
            }
            GLControl = whatControl;
            GLControl.Context.MakeCurrent(null);

            //Currently hardcoded camera position
            lock (whatMap)
            {
                camera = new Camera(
                    new Vector3d((double)whatMap.xSizeCache / 2, (double)whatMap.ySizeCache / 2, (double)whatMap.zSizeCache / 2 + whatMap.xSizeCache + CAMERA_HEIGHT_PADDING),
                    new Vector3d((double)whatMap.xSizeCache / 2, (double)whatMap.ySizeCache / 2, (double)whatMap.zSizeCache / 2));
            }
            renderTask = Task.Factory.StartNew(rendererMain, TaskCreationOptions.LongRunning);
        }
        /// <summary>
        /// Generates a renderthread and graphics related data structures
        /// </summary>
        /// <param name="whatControl">The GLControl to use for rendering</param>
        /// <param name="whatMap">The map to render in the control</param>
        public Renderer(GLControl whatControl, WorldMap whatMap, AstarInterface whatInterface)
        {
            if (whatInterface == null)
                throw new ArgumentNullException("whatInterface", "Cannot get selector position from non-existing interface.");
            AstarInterface = whatInterface;
            if (whatMap == null)
                throw new ArgumentNullException("whatMap", "Cannot render a non-existing map");
            map = whatMap;
            if (whatControl == null)
                throw new ArgumentNullException("whatControl", "Cannot use a non-existing GLControl for rendering");
            GLControl = whatControl;
            GLControl.Context.MakeCurrent(null);

            //Currently hardcoded camera position
            lock (whatMap)
            {
                camera = new Camera(
                    new Vector3d((double)whatMap.xSizeCache / 2, (double)whatMap.ySizeCache / 2, (double)whatMap.zSizeCache / 2 + whatMap.xSizeCache + CAMERA_HEIGHT_PADDING),
                    new Vector3d((double)whatMap.xSizeCache / 2, (double)whatMap.ySizeCache / 2, (double)whatMap.zSizeCache / 2));
            }
            renderTask = Task.Factory.StartNew(rendererMain, TaskCreationOptions.LongRunning);
        }