public void CreateRiver(string gameObjectName, Vector3 position)
        {
#if RAM_2019
            RiverSettings riverSettings = editor.extension.riverSettings;

            GameObject parentGameObject = editor.extension.transform.gameObject;

            // create new gameobject
            RamSpline spline = RamSpline.CreateSpline(AssetDatabase.GetBuiltinExtraResource <Material>("Default-Diffuse.mat"));

            // ensure gameobject gets reparented if this was a context click (otherwise does nothing)
            GameObjectUtility.SetParentAndAlign(spline.gameObject, parentGameObject);

            // set position
            spline.transform.position = Vector3.zero; // keeping it unique for the gameobject; using the point position we'd have to adjust the river points

            // apply river settings
            spline.width          = 100;
            spline.currentProfile = riverSettings.splineProfile;
            spline.width          = Random.Range(riverSettings.widthMin, riverSettings.widthMax);

            // apply simulation settings
            spline.AddPoint(position);

            spline.simulatedRiverLength = Random.Range(riverSettings.simulatedRiverLengthMin, riverSettings.simulatedRiverLengthMax);
            spline.simulatedRiverPoints = Random.Range(riverSettings.simulatedRiverPointsMin, riverSettings.simulatedRiverPointsMax);
            spline.simulatedMinStepSize = Random.Range(riverSettings.simulatedMinStepSizeMin, riverSettings.simulatedMinStepSizeMax);

            spline.simulatedNoUp      = riverSettings.simulatedNoUp;
            spline.simulatedBreakOnUp = riverSettings.simulatedBreakOnUp;
            spline.noiseWidth         = riverSettings.noiseWidth;

            spline.simulatedMinStepSize = Random.Range(riverSettings.simulatedMinStepSizeMin, riverSettings.simulatedMinStepSizeMax);
            spline.simulatedMinStepSize = Random.Range(riverSettings.simulatedMinStepSizeMin, riverSettings.simulatedMinStepSizeMax);

            spline.noiseMultiplierWidth = Random.Range(riverSettings.noiseMultiplierWidthMin, riverSettings.noiseMultiplierWidthMax);
            spline.noiseSizeWidth       = Random.Range(riverSettings.noiseSizeWidthMin, riverSettings.noiseSizeWidthMax);

            // simulate
            bool generate = riverSettings.automation == RiverSettings.Automation.Generate;
            spline.SimulateRiver(generate);

            // register the creation in the undo system
            Undo.RegisterCreatedObjectUndo(spline.gameObject, "Create " + spline.gameObject.name);
#endif
        }
Пример #2
0
    public static RamSpline CreateSpline(Material splineMaterial = null, List <Vector4> positions = null)
    {
        GameObject   gameObject   = new GameObject("RamSpline");
        RamSpline    ramSpline    = gameObject.AddComponent <RamSpline>();
        MeshRenderer meshRenderer = gameObject.AddComponent <MeshRenderer>();

        meshRenderer.receiveShadows    = false;
        meshRenderer.shadowCastingMode = ShadowCastingMode.Off;
        if (splineMaterial != null)
        {
            meshRenderer.sharedMaterial = splineMaterial;
        }
        if (positions != null)
        {
            for (int i = 0; i < positions.Count; i++)
            {
                ramSpline.AddPoint(positions[i]);
            }
        }
        return(ramSpline);
    }
Пример #3
0
    public static RamSpline CreateSpline(Material splineMaterial = null, List <Vector4> positions = null)
    {
        GameObject   gameObject   = new GameObject(nameof(RamSpline));
        RamSpline    ramSpline    = (RamSpline)gameObject.AddComponent <RamSpline>();
        MeshRenderer meshRenderer = (MeshRenderer)gameObject.AddComponent <MeshRenderer>();

        ((Renderer)meshRenderer).set_receiveShadows(false);
        ((Renderer)meshRenderer).set_shadowCastingMode((ShadowCastingMode)0);
        if (Object.op_Inequality((Object)splineMaterial, (Object)null))
        {
            ((Renderer)meshRenderer).set_sharedMaterial(splineMaterial);
        }
        if (positions != null)
        {
            for (int index = 0; index < positions.Count; ++index)
            {
                ramSpline.AddPoint(positions[index]);
            }
        }
        return(ramSpline);
    }