Exemplo n.º 1
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;
     }
     MainTerrainWindow.GetInstance().AddBrushShape(brushshape.Name, brushshape.Description, brushshape);
 }
Exemplo n.º 2
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;
     }
     MainTerrainWindow.GetInstance().AddBrushEffect(brusheffect.Name, brusheffect.Description, brusheffect);
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 5
0
        public void Render(Vector3 intersectpos)
        {
            double radius        = CurrentEditBrush.GetInstance().BrushSize;
            double displayradius = radius;

            TerrainModel terrain = MetaverseClient.GetInstance().worldstorage.terrainmodel;

            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);
                starty = Math.Max(0, starty);
                starty = Math.Min(starty, terrain.MapHeight);

                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);
                endy = Math.Max(0, endy);
                endy = Math.Min(endy, terrain.MapHeight);

                for (int segment = 0; segment < numsegments; segment++)
                {
                    double x = startx + (endx - startx) * segment / numsegments;
                    double y = starty + (endy - starty) * segment / numsegments;
                    double z = MetaverseClient.GetInstance().worldstorage.terrainmodel.Map[(int)(x),
                                                                                           (int)(y)];
                    z = Math.Max(0.1, z);   // make sure visible over sea
                    Gl.glVertex3d(x, y, z);
                }
            }
            Gl.glEnd();
        }
Exemplo n.º 6
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 (ViewerState.GetInstance().CurrentViewerState != ViewerState.ViewerStateEnum.Terrain)
            {
                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 < (MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightMapWidth) &&
                y < (MetaverseClient.GetInstance().worldstorage.terrainmodel.HeightMapHeight))
            {
                double milliseconds = DateTime.Now.Subtract(LastDateTime).TotalMilliseconds;
                LastDateTime = DateTime.Now;
                CurrentEditBrush.GetInstance().BrushEffect.ApplyBrush(
                    CurrentEditBrush.GetInstance().BrushShape, CurrentEditBrush.GetInstance().BrushSize,
                    x, y, increaseheight, milliseconds);
            }
        }
Exemplo n.º 7
0
        public void Render(Vector3 intersectpos)
        {
            double       radius = CurrentEditBrush.GetInstance().BrushSize;
            int          segments = 32;
            double       anglestep = Math.PI * 2 / segments;
            TerrainModel terrain = MetaverseClient.GetInstance().worldstorage.terrainmodel;
            double       x, y, z;
            // outer radius
            double displayradius = radius;

            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);
                y = Math.Max(0, y);
                y = Math.Min(y, terrain.MapHeight);
                z = terrain.Map[(int)(x),
                                (int)(y)];
                z = Math.Max(0.1, z);   // make sure visible over sea
                Gl.glVertex3d(x, y, z);
            }
            Gl.glEnd();
            // core radius
            displayradius = coresizevalue / 100 * radius;
            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);
                y = Math.Max(0, y);
                y = Math.Min(y, terrain.MapHeight);
                z = terrain.Map[(int)(x),
                                (int)(y)];
                z = Math.Max(0.1, z);   // make sure visible over sea
                Gl.glVertex3d(x, y, z);
            }
            Gl.glEnd();
        }
Exemplo n.º 8
0
        void BrushShapeController_WriteNextFrameEvent(Vector3 camerapos)
        {
            if (ViewerState.GetInstance().CurrentViewerState == ViewerState.ViewerStateEnum.Terrain)
            {
                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);
                    }
                }
            }
        }
Exemplo n.º 9
0
 public void on_brushsize1_move_slider(object o, EventArgs e)
 {
     LogFile.WriteLine("New brushsize: " + brushsize.Value.ToString());
     CurrentEditBrush.GetInstance().BrushSize = (int)brushsize.Value;
 }