private void ApplyPreset()
        {
            if (this._sourceWindZone.objectReferenceValue != (UnityEngine.Object)null)
            {
                if (!EditorUtility.DisplayDialog("Apply Preset?", "The wind settings are driven by a wind zone. Do you want to apply the preset to the source Wind Zone?", "Apply", "Cancel"))
                {
                    this._selectedPreset = (WindComponentEditor.WindPreset) this._preset.intValue;
                    return;
                }
                Undo.RecordObjects(new UnityEngine.Object[2]
                {
                    this.target,
                    this._sourceWindZone.objectReferenceValue
                }, "Load Wind Preset");
            }
            else
            {
                Undo.RecordObject(this.target, "Load Wind Preset");
            }
            WindComponent target = (WindComponent)this.target;

            switch (this._selectedPreset)
            {
            case WindComponentEditor.WindPreset.Calm:
                target.Settings = FWindSettings.Calm;
                break;

            case WindComponentEditor.WindPreset.Breeze:
                target.Settings = FWindSettings.Breeze;
                break;

            case WindComponentEditor.WindPreset.StrongBreeze:
                target.Settings = FWindSettings.StrongBreeze;
                break;

            case WindComponentEditor.WindPreset.Storm:
                target.Settings = FWindSettings.Storm;
                break;
            }
            target.Settings = new FWindSettings(target.Settings)
            {
                WindDirection = FWindSettings.RotationToDirection(target.transform.rotation)
            };
            this.serializedObject.Update();
            if (this._sourceWindZone.objectReferenceValue != (UnityEngine.Object)null)
            {
                ((WindComponent)this.target).Settings.ApplyToWindZone((WindZone)this._sourceWindZone.objectReferenceValue);
                EditorUtility.SetDirty(this._sourceWindZone.objectReferenceValue);
            }
            Undo.FlushUndoRecordObjects();
        }
Пример #2
0
        //

        public PlantReadyMaster(IEnumerable <PlantUnit> plants, VBOArrayF modelAttribs, string[] textureSets, WindComponent component)
        {
            SetMemento(plants);
            this._postConstructor = true;
            this._texture         = new List <ITexture>();
            foreach (var item in textureSets)
            {
                _texture.Add(PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(item));
            }
            this._attribs       = modelAttribs;
            this._wind          = component;
            this._grassMaterial = new Material(new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                                               new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), 10.0f, 1.0f);
            this._meshCenter = GetCenter();
        }
        private void OnSceneGUI()
        {
            WindComponent target = this.target as WindComponent;

            if ((UnityEngine.Object)target == (UnityEngine.Object)null)
            {
                return;
            }
            Quaternion rotation   = Quaternion.Euler(0.0f, target.transform.eulerAngles.y, 0.0f);
            float      handleSize = HandleUtility.GetHandleSize(target.transform.position);

            Handles.color = Color.yellow;
            Handles.ArrowHandleCap(GUIUtility.GetControlID(FocusType.Passive), target.transform.position, rotation, 2f * handleSize, UnityEngine.EventType.Repaint);
            Handles.SphereHandleCap(GUIUtility.GetControlID(FocusType.Passive), target.transform.position, rotation, 0.2f * handleSize, UnityEngine.EventType.Repaint);
        }
Пример #4
0
 public PlantBuilderMaster(Int32 init_buffer_size, string pathToModel, string[] textureSets, WindComponent component)
 {
     this.INIT_BUFFER_SIZE = init_buffer_size;
     this._plants          = new List <PlantUnit>();
     this._bufferAssembled = false;
     this._postConstructor = true;
     _texture = new List <ITexture>();
     foreach (var item in textureSets)
     {
         _texture.Add(PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(item));
     }
     this._buffer        = AllocateVaoMemory(pathToModel);
     this._wind          = component;
     this._grassMaterial = new Material(new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                                        new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), 10.0f, 1.0f);
     this._meshCenter = GetCenter();
 }
Пример #5
0
        public PlantReadyMaster(Int32 entityCount, float MAP_SIZE, VBOArrayF ModelAttribs, Vector3 Scale,
                                string[] textureSets, WindComponent component, MistComponent mist = null)
        {
            _postConstructor = true;
            _attribs         = ModelAttribs;
            _texture         = new List <ITexture>();
            foreach (var item in textureSets)
            {
                _texture.Add(PoolProxy.GetResource <ObtainTexturePool, TextureAllocationPolicy, string, ITexture>(item));
            }
            this.MAP_SIZE  = MAP_SIZE;
            entityCount    = entityCount > MAX_ENTITIES_COUNT ? MAX_ENTITIES_COUNT : entityCount;
            _grassMaterial = new Material(new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f),
                                          new Vector3(1.0f, 1.0f, 1.0f), new Vector3(1.0f, 1.0f, 1.0f), 10.0f, 1.0f);

            _meshCenter = GetCenter();
            _plants     = new List <PlantUnit>();
            for (Int32 i = 0; i < entityCount; i++)
            {
                _plants.Add(new PlantUnit(i, Scale, MAP_SIZE, new uint[] { 1, 2, 3 }));
            }
            this._wind = component;
            this._mist = mist;
        }
Пример #6
0
 public void setWind(WindComponent wind)
 {
     u_windDirection.LoadUniform(wind.WindDirection);
     u_windPower.LoadUniform(wind.WindPower);
 }