Beispiel #1
0
        void brusheffect_Toggled(object o, EventArgs e)
        {
            IBrushEffect targeteffect = brusheffects[o as RadioButton];

            Console.WriteLine("selected effect " + targeteffect);
            CurrentEditBrush.GetInstance().BrushEffect = targeteffect;
            ClearVBox(custombrusheffectlabels);
            ClearVBox(custombrusheffectwidgets);
            targeteffect.ShowControlBox(custombrusheffectlabels, custombrusheffectwidgets);
        }
Beispiel #2
0
        void brushshape_Toggled(object o, EventArgs e)
        {
            IBrushShape targeteffect = brushshapes[o as RadioButton];

            Console.WriteLine("selected shape " + targeteffect);
            CurrentEditBrush.GetInstance().BrushShape = targeteffect;
            ClearVBox(custombrushshapelabels);
            ClearVBox(custombrushshapewidgets);
            targeteffect.ShowControlBox(custombrushshapelabels, custombrushshapewidgets);
        }
Beispiel #3
0
 public void Register(IBrushShape brushshape)
 {
     Console.WriteLine(this.GetType() + " registering " + brushshape);
     this.brushshapes.Add(brushshape.GetType(), brushshape);
     if (CurrentEditBrush.GetInstance().BrushShape == null)
     {
         CurrentEditBrush.GetInstance().BrushShape = brushshape;
     }
     MainUI.GetInstance().uiwindow.AddBrushShape(brushshape.Name, brushshape.Description, brushshape);
 }
Beispiel #4
0
 public void Register(IBrushEffect brusheffect)
 {
     Console.WriteLine(this.GetType() + " registering " + brusheffect);
     this.brusheffects.Add(brusheffect.GetType(), brusheffect);
     if (CurrentEditBrush.GetInstance().BrushEffect == null)
     {
         CurrentEditBrush.GetInstance().BrushEffect = brusheffect;
     }
     MainUI.GetInstance().uiwindow.AddBrushEffect(brusheffect.Name, brusheffect.Description, brusheffect);
 }
Beispiel #5
0
        public void Render(Vector3 intersectpos)
        {
            double radius        = CurrentEditBrush.GetInstance().BrushSize;
            double displayradius = radius * Terrain.SquareSize;

            Terrain terrain = Terrain.GetInstance();

            int numsegments = 16;

            // list four corner of square, in order
            List <Vector2> corners = new List <Vector2>();

            corners.Add(new Vector2(-1, -1));
            corners.Add(new Vector2(-1, 1));
            corners.Add(new Vector2(1, 1));
            corners.Add(new Vector2(1, -1));

            Gl.glBegin(Gl.GL_LINE_LOOP);
            for (int i = 0; i < 4; i++)
            {
                Vector2 startcorner = corners[i];
                Vector2 endcorner   = corners[(i + 1) % 4];
                double  startx      = intersectpos.x + startcorner.x * displayradius;
                double  starty      = intersectpos.y + startcorner.y * displayradius;
                startx = Math.Max(0, startx);
                startx = Math.Min(startx, terrain.MapWidth * Terrain.SquareSize);
                starty = Math.Max(0, starty);
                starty = Math.Min(starty, terrain.MapHeight * Terrain.SquareSize);

                double endx = intersectpos.x + endcorner.x * displayradius;
                double endy = intersectpos.y + endcorner.y * displayradius;
                endx = Math.Max(0, endx);
                endx = Math.Min(endx, terrain.MapWidth * Terrain.SquareSize);
                endy = Math.Max(0, endy);
                endy = Math.Min(endy, terrain.MapHeight * Terrain.SquareSize);

                for (int segment = 0; segment < numsegments; segment++)
                {
                    double x = startx + (endx - startx) * segment / numsegments;
                    double y = starty + (endy - starty) * segment / numsegments;
                    double z = Terrain.GetInstance().Map[(int)(x / Terrain.SquareSize),
                                                         (int)(y / Terrain.SquareSize)];
                    z = Math.Max(0.1, z);   // make sure visible over sea
                    Gl.glVertex3d(x, y, z);
                }
            }
            Gl.glEnd();
        }
Beispiel #6
0
        public void Render(Vector3 intersectpos)
        {
            double  radius = CurrentEditBrush.GetInstance().BrushSize;
            int     segments = 32;
            double  anglestep = Math.PI * 2 / segments;
            Terrain terrain = Terrain.GetInstance();
            double  x, y, z;
            // outer radius
            double displayradius = radius * Terrain.SquareSize;

            Gl.glBegin(Gl.GL_LINE_LOOP);
            for (double angle = 0; angle < Math.PI * 2; angle += anglestep)
            {
                x = intersectpos.x + displayradius * Math.Sin(angle);
                y = intersectpos.y + displayradius * Math.Cos(angle);
                x = Math.Max(0, x);
                x = Math.Min(x, terrain.MapWidth * Terrain.SquareSize);
                y = Math.Max(0, y);
                y = Math.Min(y, terrain.MapHeight * Terrain.SquareSize);
                z = terrain.Map[(int)(x / Terrain.SquareSize),
                                (int)(y / Terrain.SquareSize)];
                z = Math.Max(0.1, z);   // make sure visible over sea
                Gl.glVertex3d(x, y, z);
            }
            Gl.glEnd();
            // core radius
            displayradius = coresizevalue / 100 * radius * Terrain.SquareSize;
            Gl.glBegin(Gl.GL_LINE_LOOP);
            for (double angle = 0; angle < Math.PI * 2; angle += anglestep)
            {
                x = intersectpos.x + displayradius * Math.Sin(angle);
                y = intersectpos.y + displayradius * Math.Cos(angle);
                x = Math.Max(0, x);
                x = Math.Min(x, terrain.MapWidth * Terrain.SquareSize);
                y = Math.Max(0, y);
                y = Math.Min(y, terrain.MapHeight * Terrain.SquareSize);
                z = terrain.Map[(int)(x / Terrain.SquareSize),
                                (int)(y / Terrain.SquareSize)];
                z = Math.Max(0.1, z);   // make sure visible over sea
                Gl.glVertex3d(x, y, z);
            }
            Gl.glEnd();
        }
Beispiel #7
0
        void BrushShapeController_WriteNextFrameEvent(Vector3 camerapos)
        {
            if (CurrentEditBrush.GetInstance().BrushShape != null)
            {
                if (CurrentEditBrush.GetInstance().BrushEffect.Repeat)
                {
                    Vector3 intersectpos = EditingHelper.GetIntersectPoint();
                    if (intersectpos == null)
                    {
                        return;
                    }

                    Gl.glDisable(Gl.GL_LIGHTING);
                    Gl.glColor3ub(0, 255, 200);
                    CurrentEditBrush.GetInstance().BrushShape.Render(intersectpos);
                    Gl.glColor3ub(255, 255, 255);
                    Gl.glEnable(Gl.GL_LIGHTING);
                }
            }
        }
Beispiel #8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="IsInitialMouseclick">When mouse button is initially pressed, this is true.</param>
        void ApplyBrush(bool IsInitialMouseclick)
        {
            if (!(increaseheight || decreaseheight))
            {
                return;
            }

            if (CurrentEditBrush.GetInstance().BrushEffect == null ||
                CurrentEditBrush.GetInstance().BrushShape == null)
            {
                return;
            }

            if (!(IsInitialMouseclick || CurrentEditBrush.GetInstance().BrushEffect.Repeat))
            {
                return;
            }

            Vector3 intersectpoint = EditingHelper.GetIntersectPoint();

            if (intersectpoint == null)
            {
                return;
            }

            double x = intersectpoint.x;
            double y = intersectpoint.y;

            if (x >= 0 && y >= 0 &&
                x < (Terrain.GetInstance().HeightMapWidth *Terrain.SquareSize) &&
                y < (Terrain.GetInstance().HeightMapHeight *Terrain.SquareSize))
            {
                double milliseconds = DateTime.Now.Subtract(LastDateTime).TotalMilliseconds;
                LastDateTime = DateTime.Now;
                CurrentEditBrush.GetInstance().BrushEffect.ApplyBrush(
                    CurrentEditBrush.GetInstance().BrushShape, CurrentEditBrush.GetInstance().BrushSize,
                    x, y, increaseheight, milliseconds);
            }
        }
Beispiel #9
0
 public void on_brushsize1_move_slider(object o, EventArgs e)
 {
     LogFile.GetInstance().WriteLine("New brushsize: " + brushsize.Value.ToString());
     CurrentEditBrush.GetInstance().BrushSize = (int)brushsize.Value;
 }