예제 #1
0
        protected virtual void RenderToolSquare(Viewport viewport, Component_Terrain terrain, Vector2 center)
        {
            var radius    = Component_Scene_DocumentWindow.TerrainToolRadius;
            int stepCount = (int)(radius * 2);

            RenderToolLine(viewport, terrain, center + new Vector2(-radius, -radius), center + new Vector2(-radius, radius), stepCount);
            RenderToolLine(viewport, terrain, center + new Vector2(-radius, radius), center + new Vector2(radius, radius), stepCount);
            RenderToolLine(viewport, terrain, center + new Vector2(radius, radius), center + new Vector2(radius, -radius), stepCount);
            RenderToolLine(viewport, terrain, center + new Vector2(radius, -radius), center + new Vector2(-radius, -radius), stepCount);
        }
예제 #2
0
        protected virtual bool GetToolPosition(Viewport viewport, out Component_Terrain terrain, out Vector3 center)
        {
            if (!viewport.MouseRelativeMode)
            {
                var ray = viewport.CameraSettings.GetRayByScreenCoordinates(viewport.MousePosition);

                if (Component_Terrain.GetTerrainByRay(scene, ray, out terrain, out center))
                {
                    return(true);
                }
            }

            terrain = null;
            center  = Vector3.Zero;
            return(false);
        }
        List <Component_PaintLayer> GetLayersToResizeMask(Component_Terrain terrain)
        {
            var result = new List <Component_PaintLayer>();

            foreach (var layer in terrain.GetComponents <Component_PaintLayer>())
            {
                if (layer.Enabled && layer.Mask.Value != null && layer.Mask.Value.Length != 0)
                {
                    if (layer.Mask.Value.Length != terrain.GetPaintMaskSizeInteger() * terrain.GetPaintMaskSizeInteger())
                    {
                        result.Add(layer);
                    }
                }
            }
            return(result);
        }
예제 #4
0
        protected virtual void RenderToolCircle(Viewport viewport, Component_Terrain terrain, Vector2 center)
        {
            var radius = Component_Scene_DocumentWindow.TerrainToolRadius;

            const double step    = Math.PI / 32;
            Vector3      lastPos = Vector3.Zero;

            for (double angle = 0; angle <= Math.PI * 2 + step / 2; angle += step)
            {
                var pos = new Vector3(
                    center.X + Math.Cos(angle) * radius,
                    center.Y + Math.Sin(angle) * radius, 0);
                pos.Z = terrain.GetHeight(pos.ToVector2(), false);

                if (angle != 0)
                {
                    viewport.Simple3DRenderer.AddLine(lastPos + new Vector3(0, 0, toolRenderOffset), pos + new Vector3(0, 0, toolRenderOffset));
                }

                lastPos = pos;
            }
        }
예제 #5
0
        protected virtual void RenderToolLine(Viewport viewport, Component_Terrain terrain, Vector2 start, Vector2 end, int stepCount)
        {
            Vector2 diff = end - start;
            Vector2 dir  = diff;
            var     len  = dir.Normalize();

            Vector3 lastPos = Vector3.Zero;

            for (int n = 0; n <= stepCount; n++)
            {
                Vector3 pos = new Vector3(
                    start.X + dir.X * ((float)n / stepCount * len),
                    start.Y + dir.Y * ((float)n / stepCount * len), 0);
                pos.Z = terrain.GetHeight(pos.ToVector2(), false);
                //if( selectedTerrain.HeightmapTerrainManager != null && HeightmapTerrainManager.Instance != null )
                //{
                //	float z;
                //	if( HeightmapTerrainManager.Instance.GetHeight( pos.ToVector2(), false, out z ) )
                //		pos.Z = z;
                //	else
                //		pos.Z = float.MinValue;
                //}
                //else
                //	pos.Z = selectedTerrain.GetHeight( pos.ToVector2(), false );

                if (n != 0)
                {
                    if (lastPos.Z != double.MinValue && pos.Z != double.MinValue)
                    {
                        viewport.Simple3DRenderer.AddLine(lastPos + new Vector3(0, 0, toolRenderOffset), pos + new Vector3(0, 0, toolRenderOffset));
                    }
                }

                lastPos = pos;
            }
        }
예제 #6
0
 public static Vector2I GetClampedCellIndex(Component_Terrain terrain, Vector2I index)
 {
     terrain.ClampCellIndex(ref index);
     return(index);
 }
예제 #7
0
        //

        public Component_Terrain_GeometryChangeUndoAction(Component_Terrain terrain)
        {
            this.terrain = terrain;
        }
예제 #8
0
        /////////////////////////////////////////

        public Component_Terrain_PaintChangeUndoAction(Component_Terrain terrain)
        {
            this.terrain = terrain;
        }