コード例 #1
0
 public static void RenderPlanetNoise()
 {
     if (Prefs.DevMode && DebugViewSettings.drawRecordedNoise)
     {
         if (NoiseDebugUI.currentPlanetNoise != null)
         {
             if (NoiseDebugUI.planetNoiseMesh == null)
             {
                 List <int> triangles;
                 SphereGenerator.Generate(6, 100.3f, Vector3.forward, 360f, out NoiseDebugUI.planetNoiseMeshVerts, out triangles);
                 NoiseDebugUI.planetNoiseMesh      = new Mesh();
                 NoiseDebugUI.planetNoiseMesh.name = "NoiseDebugUI";
                 NoiseDebugUI.planetNoiseMesh.SetVertices(NoiseDebugUI.planetNoiseMeshVerts);
                 NoiseDebugUI.planetNoiseMesh.SetTriangles(triangles, 0);
                 NoiseDebugUI.lastDrawnPlanetNoise = null;
             }
             if (NoiseDebugUI.lastDrawnPlanetNoise != NoiseDebugUI.currentPlanetNoise)
             {
                 NoiseDebugUI.UpdatePlanetNoiseVertexColors();
                 NoiseDebugUI.lastDrawnPlanetNoise = NoiseDebugUI.currentPlanetNoise;
             }
             Graphics.DrawMesh(NoiseDebugUI.planetNoiseMesh, Vector3.zero, Quaternion.identity, WorldMaterials.VertexColor, WorldCameraManager.WorldLayer);
         }
     }
 }
コード例 #2
0
        private static List <Line> CreateSphere(IMinecraftCommandService commandService, string[] commandArgs,
                                                Position position, List <SavedPosition> savedPositions)
        {
            ISphereOptions sphere   = new Options();
            var            location = position;

            switch (commandArgs.Length)
            {
            case 3:     // radius height(Y) block @ current position
                sphere.Radius = commandArgs[1].ToInt();
                sphere.Block  = commandArgs[2];
                break;

            case 4:     // radius height(Y) block savedposition
            case 6:     // radius height(Y) block x y z
                sphere.Radius = commandArgs[1].ToInt();
                sphere.Block  = commandArgs[2];
                location      = location.GetAbsolutePosition(commandArgs.Skip(3).Take(3), savedPositions);
                break;

            default:
                commandService.Status("\nCREATE SPHERE\n" +
                                      "create sphere radius block - current postion\n" +
                                      "create sphere radius block [named position]\n" +
                                      "create sphere raidus block x y z");
                return(new List <Line>());
            }

            sphere.Start = location.ToPoint();
            IGenerator generator = new SphereGenerator();

            return(generator.Run((Options)sphere));
        }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        SphereGenerator generator = (SphereGenerator)target;
        int             edges     = EditorGUILayout.IntSlider("Edges", generator.Edges, 3, 20);
        int             layers    = EditorGUILayout.IntSlider("Layers", generator.Layers, 2, 20);

        generator.Resize(edges, layers);
        generator.Generate();
    }
コード例 #4
0
 static void SphereSettingsGUI(SphereGenerator generator, bool isSceneGUI)
 {
     GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
     {
         generator.SphereSmoothShading = SettingsToggle(generator.SphereSmoothShading, SmoothShadingContent, isSceneGUI);
         TooltipUtility.SetToolTip(SmoothShadingTooltip);
         generator.IsHemiSphere = SettingsToggle(generator.IsHemiSphere, HemiSphereContent, isSceneGUI);
         TooltipUtility.SetToolTip(HemiSphereTooltip);
     }
     GUILayout.EndVertical();
 }
コード例 #5
0
    public void Refresh()
    {
        //SphereGenerator.Sphere(tool, 0.5f, level, correction);
        SphereGenerator.Hemisphere(tool, 0.5f, complexity, correction);

        if (spin)
        {
            transform.localRotation = Quaternion.Euler(-90, 0, 0);
            transform.Rotate(Vector3.up, Random.value * 360);
        }
    }
コード例 #6
0
        private List <Line> CreateSphere(string[] commandArgs, Position position, List <SavedPosition> savedPositions,
                                         List <Line> lines)
        {
            IGenerator     generator;
            ISphereOptions sphere = new Options();

            switch (commandArgs.Length)
            {
            // radius height block [position]
            case 3:
                sphere.Radius = commandArgs[1].ToInt();
                //sphere.Height = commandArgs[2].ToInt();
                sphere.Block = commandArgs[2];

                sphere.CenterX = position.X;
                sphere.CenterY = position.Y;
                sphere.CenterZ = position.Z;
                break;

            // radius height block position
            case 4:
                sphere.Radius = commandArgs[1].ToInt();
                //sphere.Height = commandArgs[2].ToInt();
                sphere.Block = commandArgs[2];
                var center = savedPositions.Single(a => a.Name.Equals(commandArgs[3])).Position;
                sphere.CenterX = center.X;
                sphere.CenterY = center.Y;
                sphere.CenterZ = center.Z;
                break;

            // radius height block x y z
            case 6:
                sphere.Radius = commandArgs[1].ToInt();
                //sphere.Height = commandArgs[2].ToInt();
                sphere.Block   = commandArgs[2];
                sphere.CenterX = commandArgs[3].ToInt();
                sphere.CenterY = commandArgs[4].ToInt();
                sphere.CenterZ = commandArgs[5].ToInt();
                break;

            default:
                _minecraft.Status("\ncreate sphere syntax\n" +
                                  "create sphere radius block - current postion\n" +
                                  "create sphere radius block [named position]\n" +
                                  "create sphere raidus block x y z");
                return(new List <Line>());

                break;
            }
            generator = new SphereGenerator();
            lines     = generator.Run((Options)sphere);
            return(lines);
        }
コード例 #7
0
 private void Awake()
 {
     if (i == null)
     {
         i = this;
     }
     else
     {
         Destroy(gameObject);
     }
     sphereGenerator  = GetComponent <SphereGenerator>();
     cameraController = Camera.main.GetComponent <CameraController>();
 }
コード例 #8
0
        void ResetTool()
        {
            Grid.ForceGrid = false;
            if (!freedrawGenerator)
            {
                freedrawGenerator = ScriptableObject.CreateInstance <FreeDrawGenerator>();
                freedrawGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                freedrawGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                freedrawGenerator.shapeCancelled  = OnShapeCancelledEvent;
                freedrawGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!cylinderGenerator)
            {
                cylinderGenerator = ScriptableObject.CreateInstance <CylinderGenerator>();
                cylinderGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                cylinderGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                cylinderGenerator.shapeCancelled  = OnShapeCancelledEvent;
                cylinderGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!boxGenerator)
            {
                boxGenerator = ScriptableObject.CreateInstance <BoxGenerator>();
                boxGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                boxGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                boxGenerator.shapeCancelled  = OnShapeCancelledEvent;
                boxGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }
            if (!sphereGenerator)
            {
                sphereGenerator = ScriptableObject.CreateInstance <SphereGenerator>();
                sphereGenerator.snapFunction    = CSGBrushEditorManager.SnapPointToGrid;
                sphereGenerator.raySnapFunction = CSGBrushEditorManager.SnapPointToRay;
                sphereGenerator.shapeCancelled  = OnShapeCancelledEvent;
                sphereGenerator.shapeCommitted  = OnShapeCommittedEvent;
            }

            var generator = InternalCurrentGenerator;

            if (generator != null)
            {
                var obj = generator as ScriptableObject;
                if (obj)
                {
                    generator.Init();
                }
            }
        }
コード例 #9
0
        private static void Main(string[] args)
        {
            var options = new Options();

            if (!Parser.Default.ParseArguments(args, options))
            {
                return;
            }

            if (options.Center != null && options.Dimensions != options.Center.Length)
            {
                throw new ArgumentException("Center elements count must be equal to Dimensions option value");
            }

            if (options.Center == null)
            {
                options.Center = new double[options.Dimensions];
            }

            IShapeGenerator generator;

            switch (options.Shape)
            {
            case Shapes.Sphere:
                generator = new SphereGenerator();
                break;

            case Shapes.SphereFromUniform:
                generator = new SphereFromUniformGenerator();
                break;

            case Shapes.MultipleClouds:
                generator = new MultipleCloudsGenerator();
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(args));
            }

            var data = generator.Generate(options.Dimensions, options.Radius, options.Center,
                                          options.Positives, options.Negatives, options.Multiplicity);

            WriteToFile(data, options.OutputFile, options.Delimiter);
        }
コード例 #10
0
        private static List <Line> CreateSphere(string[] commandArgs, Position position, List <SavedPosition> savedPositions, List <Line> lines)
        {
            IGenerator     generator;
            ISphereOptions sphere = new Options();

            switch (commandArgs.Length)
            {
            // radius height block [position]
            case 3:
                sphere.Radius = commandArgs[1].ToInt();
                //sphere.Height = commandArgs[2].ToInt();
                sphere.Block = commandArgs[2];

                sphere.CenterX = position.X;
                sphere.CenterY = position.Y;
                sphere.CenterZ = position.Z;
                break;

            // radius height block position
            case 4:
                sphere.Radius = commandArgs[1].ToInt();
                //sphere.Height = commandArgs[2].ToInt();
                sphere.Block = commandArgs[2];
                var center = savedPositions.Single(a => a.Name.Equals(commandArgs[3])).Position;
                sphere.CenterX = center.X;
                sphere.CenterY = center.Y;
                sphere.CenterZ = center.Z;
                break;

            // radius height block x y z
            case 6:
                sphere.Radius = commandArgs[1].ToInt();
                //sphere.Height = commandArgs[2].ToInt();
                sphere.Block   = commandArgs[2];
                sphere.CenterX = commandArgs[3].ToInt();
                sphere.CenterY = commandArgs[4].ToInt();
                sphere.CenterZ = commandArgs[5].ToInt();
                break;
            }
            generator = new SphereGenerator();
            lines     = generator.Run((Options)sphere);
            return(lines);
        }
コード例 #11
0
ファイル: DustScene.cs プロジェクト: 0000duck/MiniRTS
        private void AddAsteroidField()
        {
            var asteroid = SphereGenerator.Generate(this.Device, 15);
            var material = new Material(this.Assets.AlbedoPixel(Color.Red), this.Assets.NormalPixel(), this.Assets.MetalicnessPixel(0.3f), this.Assets.RoughnessPixel(0.5f), this.Assets.AmbientOcclussionPixel(1.0f));
            var model    = new GeometryModel(asteroid, material);

            var random     = new Random(255);
            var transforms = new Matrix[1024];
            var i          = 0;

            for (var x = -16; x < 16; x++)
            {
                for (var z = -16; z < 16; z++)
                {
                    var y = ((float)random.NextDouble() + 0.5f) * 10.0f;

                    var p = new Vector3(x * 2, y, z * 2);
                    transforms[i++] = Matrix.CreateTranslation(p);
                }
            }
            transforms[0] = Matrix.CreateScale(new Vector3(2.0f, 0.1f, 2.0f)) * Matrix.CreateTranslation(Vector3.Up * 30);

            (var geometry, var transform, var bounds, var instancing) = this.Geometry.Create(model, transforms);
        }
コード例 #12
0
        public void Load(ContentStack content)
        {
            var geometry = SphereGenerator.Generate(this.Device, 15);
            var material = new Material(this.Assets.WhitePixel, this.Assets.NormalPixel(), this.Assets.MetalicnessPixel(0.5f), this.Assets.RoughnessPixel(0.0f), this.Assets.AmbientOcclussionPixel(1.0f));

            var entity = this.Entities.Create();

            this.Components.Add(new GeometryComponent(entity, new GeometryModel(geometry, material)));
            this.Components.Add(new TransformComponent(entity));

            var transforms = new Matrix[1024];
            var i          = 0;

            for (var x = -16; x < 16; x++)
            {
                for (var y = -16; y < 16; y++)
                {
                    var p = new Vector3(x * 2, y * 2, 0.0f);
                    transforms[i++] = Matrix.CreateTranslation(p);
                }
            }

            this.Components.Add(InstancingComponent.Create(entity, transforms));
        }
コード例 #13
0
        public void Load(ContentStack content)
        {
            var red = new Texture2D(this.Device, 1, 1);

            red.SetData(new Color[] { Color.White });
            content.Link(red);

            var white = new Texture2D(this.Device, 1, 1);

            white.SetData(new Color[] { Color.White });
            content.Link(white);

            var black = new Texture2D(this.Device, 1, 1);

            black.SetData(new Color[] { Color.Black });
            content.Link(black);

            var normal = new Texture2D(this.Device, 1, 1);

            normal.SetData(new Color[] { new Color(0.5f, 0.5f, 1.0f) });
            content.Link(normal);

            var blue  = content.Load <Texture2D>("Textures/Blue");
            var bumps = content.Load <Texture2D>("Textures/Bricks_Normal");

            var rows     = 7;
            var columns  = 7;
            var spacing  = 2.5f;
            var geometry = SphereGenerator.Generate(this.Device, 15);

            for (var row = 0; row < rows; row++)
            {
                var metalicness = row / (float)rows;

                var metalicnessTexture = new Texture2D(this.Device, 1, 1);
                metalicnessTexture.SetData(new Color[] { new Color(Vector3.One * metalicness) });
                content.Link(metalicnessTexture);

                for (var col = 0; col < columns; col++)
                {
                    var roughness        = Math.Clamp(col / (float)columns, 0.05f, 1.0f);
                    var roughnessTexture = new Texture2D(this.Device, 1, 1);
                    roughnessTexture.SetData(new Color[] { new Color(Vector3.One * roughness) });
                    content.Link(roughnessTexture);

                    var material = new Material(red, normal, metalicnessTexture, roughnessTexture, white);

                    var position = new Vector3((col - (columns / 2.0f)) * spacing, (row - (rows / 2.0f)) * spacing, 0.0f);
                    this.CreateSphere(geometry, material, position, Vector3.One);
                }
            }

            var backgroundGeometry = CubeGenerator.Generate(this.Device);

            this.CreateSphere(backgroundGeometry, new Material(bumps, GeneratedAssets.NormalPixel(), black, white, white), Vector3.Forward * 20, new Vector3(200, 200, 1));

            this.CreateLight(new Vector3(-10, 10, 10), Color.Red, 30.0f);
            this.CreateLight(new Vector3(10, 10, 10), Color.Blue, 30.0f);
            this.CreateLight(new Vector3(-10, -10, 10), Color.Green, 30.0f);
            this.CreateLight(new Vector3(10, -10, 10), Color.White, 30.0f);

            this.CreateSpotLight(new Vector3(0, 0, 10), Vector3.Forward, 1500.0f);
        }
コード例 #14
0
        static void OnGUIContents(SphereGenerator generator, bool isSceneGUI)
        {
            var distanceUnit = RealtimeCSG.CSGSettings.DistanceUnit;
            var nextUnit     = Units.CycleToNextUnit(distanceUnit);
            var unitText     = Units.GetUnitGUIContent(distanceUnit);

            //GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
            //{
            //bool enabled = generator.HaveBrushes;
            GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
            {
                /*
                 * EditorGUI.BeginDisabledGroup(!enabled);
                 * {
                 *      if (isSceneGUI)
                 *              GUILayout.BeginVertical(GUI.skin.box, width100);
                 *      else
                 *              GUILayout.BeginVertical(GUIStyle.none);
                 *      {
                 *              bool mixedValues = !enabled;
                 *              CSGOperationType operation = generator.CurrentCSGOperationType;
                 *              EditorGUI.BeginChangeCheck();
                 *              operation = GUIStyleUtility.ChooseOperation(operation, mixedValues);
                 *              if (EditorGUI.EndChangeCheck())
                 *              {
                 *                      generator.CurrentCSGOperationType = operation;
                 *              }
                 *      }
                 *      GUILayout.EndVertical();
                 * }
                 * EditorGUI.EndDisabledGroup();
                 */
                if (isSceneGUI)
                {
                    SphereSettingsGUI(generator, isSceneGUI);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginVertical(GUIStyleUtility.ContentEmpty);
            {
                GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                {
                    EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                    {
                        GUILayout.Label(RadiusContent, width65);
                        if (isSceneGUI)
                        {
                            TooltipUtility.SetToolTip(RadiusTooltip);
                        }
                        var radius = generator.SphereRadius;
                        EditorGUI.BeginChangeCheck();
                        {
                            if (!isSceneGUI)
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius)));
                            }
                            else
                            {
                                radius = Units.DistanceUnitToUnity(distanceUnit, EditorGUILayout.DoubleField(Units.UnityToDistanceUnit(distanceUnit, radius), width65));
                            }
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            generator.SphereRadius = radius;
                        }
                        if (GUILayout.Button(unitText, EditorStyles.miniLabel, width25))
                        {
                            distanceUnit = nextUnit;
                            RealtimeCSG.CSGSettings.DistanceUnit = distanceUnit;
                            RealtimeCSG.CSGSettings.UpdateSnapSettings();
                            RealtimeCSG.CSGSettings.Save();
                            SceneView.RepaintAll();
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                }
                GUILayout.EndHorizontal();
                if (!isSceneGUI)
                {
                    TooltipUtility.SetToolTip(RadiusTooltip);
                }

                {
                    generator.SphereSplits = IntSettingsSlider(generator.SphereSplits, 1, 9, SplitsContent, isSceneGUI);
                    TooltipUtility.SetToolTip(SplitsTooltip);
                }
                {
                    generator.SphereOffset = SettingsSlider(generator.SphereOffset, 0, 360, OffsetContent, isSceneGUI);
                    TooltipUtility.SetToolTip(OffsetTooltip);
                }
            }
            GUILayout.EndVertical();

            if (!isSceneGUI)
            {
                GUILayout.Space(5);

                SphereSettingsGUI(generator, isSceneGUI);

                //GUILayout.Space(10);
            }                    /* else
                                  * {
                                  *     GUILayout.Space(10);
                                  * }*/
                                 /*
                                  * EditorGUI.BeginDisabledGroup(!generator.CanCommit);
                                  * {
                                  *      GUILayout.BeginHorizontal(GUIStyleUtility.ContentEmpty);
                                  *      {
                                  *              if (GUILayout.Button(CommitContent)) { generator.DoCommit(); }
                                  *              TooltipUtility.SetToolTip(CommitTooltip);
                                  *              if (GUILayout.Button(CancelContent)) { generator.DoCancel(); }
                                  *              TooltipUtility.SetToolTip(CancelTooltip);
                                  *      }
                                  *      GUILayout.EndHorizontal();
                                  * }
                                  * EditorGUI.EndDisabledGroup();
                                  */
            //}
            //GUILayout.EndVertical();
        }
コード例 #15
0
 public double Distance(Point from)
 {
     return(SphereGenerator.Distance(X, Z, Y, from.X, from.Z, from.Y));
 }
コード例 #16
0
 public static bool OnShowGUI(SphereGenerator generator, bool isSceneGUI)
 {
     GUIStyleUtility.InitStyles();
     OnGUIContents(generator, isSceneGUI);
     return(true);
 }
コード例 #17
0
 public double Distance2D(Point from)
 {
     return(SphereGenerator.Distance(X, Z, 0, from.X, from.Z, 0));
 }
コード例 #18
0
 public void Init()
 {
     _sphereGenerator = new SphereGenerator();
 }
コード例 #19
0
 private void Start()
 {
     GetComponent <MeshFilter>().mesh = SphereGenerator.Create(subdivisions, radius);
 }
コード例 #20
0
 public SphereLightVolume(GraphicsDevice device)
 {
     this.Sphere = SphereGenerator.Generate(device, 3);
 }