public AttractionForceAffector(AnimationCurve curve, Vector3 pos, EffectNode node) : base(node) { AttractionCurve = curve; Position = pos; UseCurve = true; }
public TimedSequenceEditorEffectEditor(EffectNode effectNode) { InitializeComponent(); _effectNode = effectNode; IEnumerable<IEffectEditorControl> controls = ApplicationServices.GetEffectEditorControls(_effectNode.Effect.Descriptor.TypeId); if (controls == null) { Label l = new Label(); l.Text = "Can't find any effect editors that can edit this effect!"; l.Anchor = AnchorStyles.None; tableLayoutPanelEffectEditors.Controls.Add(l); tableLayoutPanelEffectEditors.SetColumnSpan(l, 2); return; } _controls = new List<IEffectEditorControl>(); object[] values = _effectNode.Effect.ParameterValues; // if there were multiple controls returned, or there was only a single control needed (ie. the efffect parameters had only // a single item) then add controls inside a ParameterEditor wrapper using editors for that type, and label them appropriately. // if it was only a single control returned, it must have matched the entire effect (by GUID or signature), so just dump the // control it, and let it deal with everything it needs to. if (controls.Count() > 1 || (controls.Count() == 1 && (_effectNode.Effect.Descriptor as IEffectModuleDescriptor).Parameters.Count == 1)) { _usedSingleControl = false; int i = 0; foreach (IEffectEditorControl ec in controls) { // as it's a single control for a single parameter, it *should* take the corresponding indexed parameter from the effect. // so pull that individual parameter out, and give it to the control as a single item. This is a bit of an assumption // and seems...... prone to breaking. TODO: review. ec.EffectParameterValues = values[i].AsEnumerable().ToArray(); ec.TargetEffect = effectNode.Effect; Label l = new Label(); l.Width = 1; l.Height = 1; l.Text = _effectNode.Effect.Parameters[i].Name + ":"; l.AutoSize = true; l.Anchor = AnchorStyles.None; tableLayoutPanelEffectEditors.Controls.Add(l); (ec as Control).Anchor = AnchorStyles.None; tableLayoutPanelEffectEditors.Controls.Add(ec as Control); // save the editor control into a list we can use as a reference later on, to pull the data back out of them in the right order. _controls.Add(ec); i++; } } else { _usedSingleControl = true; IEffectEditorControl control = controls.First(); control.EffectParameterValues = _effectNode.Effect.ParameterValues; control.TargetEffect = effectNode.Effect; tableLayoutPanelEffectEditors.Controls.Add(control as Control); tableLayoutPanelEffectEditors.SetColumnSpan((control as Control), 2); _controls.Add(control); } }
public AttractionForceAffector(float magnitude, Vector3 pos, EffectNode node) : base(node) { Magnitude = magnitude; Position = pos; UseCurve = false; }
public TimedSequenceElement(EffectNode effectNode) : base() { StartTime = effectNode.StartTime; Duration = effectNode.TimeSpan; EffectNode = effectNode; }
protected override bool _DataListener(IEffectNode effectNode) { //*** compensation delta, user-configurable IEffectNode contextRelativeEffectNode = new EffectNode(effectNode.Effect, effectNode.StartTime + TimingSource.Position); Sequence.SequenceData.EffectData.AddData(contextRelativeEffectNode); // We don't want any handlers beyond the executor to get live data. return true; }
public TimedSequenceElement(EffectNode effectNode) : base() { StartTime = effectNode.StartTime; Duration = effectNode.TimeSpan; EffectNode = effectNode; //BorderColor = Color.Black; //BackColor = Color.FromArgb(0, 0, 0, 0); }
public Vector3 GetEmitRotation(EffectNode node) { Vector3 ret = Vector3.zero; //Set Direction: //NOTICE:SPHERE AND CIRCLE Emitter, default dir is spread from the center. not influenced with the IsRandomDir and VelocityAxis. if (Layer.EmitType == (int)EMITTYPE.SPHERE) { if (!Layer.SyncClient) { ret = node.Position - (Layer.ClientTransform.position + Layer.EmitPoint); } else { ret = node.Position - Layer.EmitPoint; } } else if (Layer.EmitType == (int)EMITTYPE.CIRCLE) { Vector3 dir; if (!Layer.SyncClient) dir = node.Position - (Layer.ClientTransform.position + Layer.EmitPoint); else dir = node.Position - Layer.EmitPoint; Vector3 target = Vector3.RotateTowards(dir, Layer.CircleDir, (90 - Layer.AngleAroundAxis) * Mathf.Deg2Rad, 1); Quaternion rot = Quaternion.FromToRotation(dir, target); ret = rot * dir; } else if (Layer.IsRandomDir) { //first, rotate y around z 30 degrees Quaternion rotY = Quaternion.Euler(0, 0, Layer.AngleAroundAxis); //second, rotate around y 360 random dir; Quaternion rotAround = Quaternion.Euler(0, Random.Range(0, 360), 0); //last, rotate the dir to OriVelocityAxis Quaternion rotTo = Quaternion.FromToRotation(Vector3.up, Layer.OriVelocityAxis); ret = rotTo * rotAround * rotY * Vector3.up; } else { ret = Layer.OriVelocityAxis; } return ret; }
public RotateAffector(float delta, EffectNode node) : base(node) { Type = RSTYPE.SIMPLE; Delta = delta; }
public void RemoveEffectNodeAndElement(EffectNode node) { //Debug.WriteLine("{0} RemoveEffectNodeAndElement(InstanceId={1})", (int)DateTime.Now.TimeOfDay.TotalMilliseconds, node.Effect.InstanceId); // Lookup this effect node's Timeline Element TimedSequenceElement tse = (TimedSequenceElement)_effectNodeToElement[node]; foreach (Row row in TimelineControl) // Remove the element from all rows row.RemoveElement(tse); // TODO: Unnecessary? tse.ContentChanged -= ElementContentChangedHandler; // Unregister event handlers tse.TimeChanged -= ElementTimeChangedHandler; _effectNodeToElement.Remove(node); // Remove the effect node from the map _sequence.RemoveData(node); // Remove the effect node from sequence }
private TimedSequenceElement setupNewElementFromNode(EffectNode node) { TimedSequenceElement element = new TimedSequenceElement(node); element.ContentChanged += ElementContentChangedHandler; element.TimeChanged += ElementTimeChangedHandler; return element; }
/// <summary> /// Populates the TimelineControl grid with a new TimedSequenceElement for the given EffectNode. /// Will add a single TimedSequenceElement to in each row that each targeted element of /// the EffectNode references. It will also add callbacks to event handlers for the element. /// </summary> /// <param name="node">The EffectNode to make element(s) in the grid for.</param> private TimedSequenceElement addElementForEffectNodeTPL(EffectNode node) { TimedSequenceElement element = setupNewElementFromNode(node); // for the effect, make a single element and add it to every row that represents its target elements node.Effect.TargetNodes.AsParallel().WithCancellation(cancellationTokenSource.Token) .ForAll(target => { if (_elementNodeToRows.ContainsKey(target)) { // Add the element to each row that represents the element this command is in. foreach (Row row in _elementNodeToRows[target]) { if (!_effectNodeToElement.ContainsKey(node)) { _effectNodeToElement[node] = element; } row.AddElement(element); } } else { // we don't have a row for the element this effect is referencing; most likely, the row has // been deleted, or we're opening someone else's sequence, etc. Big fat TODO: here for that, then. // dunno what we want to do: prompt to add new elements for them? map them to others? etc. const string message = "No Timeline.Row is associated with a target ElementNode for this EffectNode. It now exists in the sequence, but not in the GUI."; Logging.Error(message); MessageBox.Show(message); } }); TimelineControl.grid.RenderElement(element); return element; }
public void SetEmitPosition(EffectNode node) { Vector3 zero = Vector3.zero; if (this.Layer.EmitType == 1) { Vector3 emitPoint = this.Layer.EmitPoint; float num = UnityEngine.Random.Range((float)(emitPoint.x - (this.Layer.BoxSize.x / 2f)), (float)(emitPoint.x + (this.Layer.BoxSize.x / 2f))); float num2 = UnityEngine.Random.Range((float)(emitPoint.y - (this.Layer.BoxSize.y / 2f)), (float)(emitPoint.y + (this.Layer.BoxSize.y / 2f))); float num3 = UnityEngine.Random.Range((float)(emitPoint.z - (this.Layer.BoxSize.z / 2f)), (float)(emitPoint.z + (this.Layer.BoxSize.z / 2f))); zero.x = num; zero.y = num2; zero.z = num3; if (!this.Layer.SyncClient) { zero = this.Layer.ClientTransform.position + zero; } } else if (this.Layer.EmitType == 0) { zero = this.Layer.EmitPoint; if (!this.Layer.SyncClient) { zero = this.Layer.ClientTransform.position + this.Layer.EmitPoint; } } else if (this.Layer.EmitType == 2) { zero = this.Layer.EmitPoint; if (!this.Layer.SyncClient) { zero = this.Layer.ClientTransform.position + this.Layer.EmitPoint; } Vector3 vector3 = (Vector3)(Vector3.up * this.Layer.Radius); zero = ((Vector3)(Quaternion.Euler((float)UnityEngine.Random.Range(0, 360), (float)UnityEngine.Random.Range(0, 360), (float)UnityEngine.Random.Range(0, 360)) * vector3)) + zero; } else if (this.Layer.EmitType == 4) { Vector3 vector4 = this.Layer.EmitPoint + ((Vector3)((this.Layer.ClientTransform.localRotation * Vector3.forward) * this.Layer.LineLengthLeft)); Vector3 vector5 = this.Layer.EmitPoint + ((Vector3)((this.Layer.ClientTransform.localRotation * Vector3.forward) * this.Layer.LineLengthRight)); Vector3 vector6 = vector5 - vector4; float num4 = ((float)(node.Index + 1)) / ((float)this.Layer.MaxENodes); float num5 = vector6.magnitude * num4; zero = vector4 + ((Vector3)(vector6.normalized * num5)); if (!this.Layer.SyncClient) { zero = this.Layer.ClientTransform.TransformPoint(zero); } } else if (this.Layer.EmitType == 3) { float num6 = ((float)(node.Index + 1)) / ((float)this.Layer.MaxENodes); float y = 360f * num6; Vector3 vector7 = (Vector3)(Quaternion.Euler(0f, y, 0f) * (Vector3.right * this.Layer.Radius)); zero = (Vector3)(Quaternion.FromToRotation(Vector3.up, this.Layer.CircleDir) * vector7); if (!this.Layer.SyncClient) { zero = (this.Layer.ClientTransform.position + zero) + this.Layer.EmitPoint; } else { zero += this.Layer.EmitPoint; } } node.SetLocalPosition(zero); }
/// <summary> /// Experimental method to attempt to execute any type of effect. Unused at the moment and needs work. /// </summary> /// <param name="elementEffect"></param> /// <returns></returns> public static Status Effect(ElementEffect elementEffect) { if (elementEffect == null) { throw new ArgumentNullException("elementEffect"); } ElementNode node = VixenSystem.Nodes.GetElementNode(elementEffect.Id); if (node == null) { throw new ArgumentException(@"Invalid element id", @"elementEffect"); } var status = new Status(); IModuleDescriptor effectDescriptor = ApplicationServices.GetModuleDescriptors <IEffectModuleInstance>().Cast <IEffectModuleDescriptor>().FirstOrDefault(x => x.EffectName.Equals(elementEffect.EffectName)); if (effectDescriptor != null) { var effect = ApplicationServices.Get <IEffectModuleInstance>(effectDescriptor.TypeId); EffectNode effectNode = CreateEffectNode(effect, node, TimeSpan.FromMilliseconds(elementEffect.Duration)); Object[] newValues = effectNode.Effect.ParameterValues; int index = 0; foreach (var sig in effectNode.Effect.Parameters) { if (sig.Type == typeof(Color)) { newValues[index] = ColorTranslator.FromHtml(elementEffect.Color.First().Key); } else { if (sig.Type == typeof(ColorGradient)) { var cg = new ColorGradient(); cg.Colors.Clear(); foreach (var d in elementEffect.Color) { cg.Colors.Add(new ColorPoint(ColorTranslator.FromHtml(d.Key), d.Value)); } newValues[index] = cg; } else { if (sig.Type == typeof(Curve)) { var pointPairList = new PointPairList(); foreach (KeyValuePair <double, double> keyValuePair in elementEffect.LevelCurve) { pointPairList.Add(keyValuePair.Key, keyValuePair.Value); } var curve = new Curve(pointPairList); newValues[index] = curve; } } } index++; } effectNode.Effect.ParameterValues = newValues; ApplyOptionParameters(effectNode, elementEffect.Options); Module.LiveContext.Execute(effectNode); status.Message = string.Format("{0} element(s) turned effect {1} for {2} milliseconds.", VixenSystem.Nodes.GetElementNode(elementEffect.Id).Name, elementEffect.EffectName, elementEffect.Duration); } return(status); }
public VortexAffector(float mag, Vector3 dir, EffectNode node) : base(node) { Magnitude = mag; Direction = dir; UseCurve = false; }
/// <summary> /// Adds an EffectNode to the sequence and the TimelineControl and puts it in the given layer. /// </summary> /// <param name="node"></param> /// <returns>The TimedSequenceElement created and added to the TimelineControl.</returns> public TimedSequenceElement AddEffectNode(EffectNode node, ILayer layer) { //Debug.WriteLine("{0} AddEffectNode({1})", (int)DateTime.Now.TimeOfDay.TotalMilliseconds, node.Effect.InstanceId); _sequence.InsertData(node); //return addElementForEffectNode(node); var element = AddElementForEffectNodeTpl(node); Sequence.GetSequenceLayerManager().AssignEffectNodeToLayer(node, layer); return element; }
public void Execute(EffectNode data) { _dataSource.AddData(data); }
public AttractionForceAffector(AnimationCurve curve, Vector3 pos, EffectNode node) : base(node) { this.AttractionCurve = curve; this.Position = pos; this.UseCurve = true; }
public AttractionForceAffector(float magnitude, Vector3 pos, EffectNode node) : base(node) { this.Magnitude = magnitude; this.Position = pos; this.UseCurve = false; }
public TimedSequenceEditorEffectEditor(EffectNode effectNode) { InitializeComponent(); ForeColor = ThemeColorTable.ForeColor; BackColor = ThemeColorTable.BackgroundColor; ThemeUpdateControls.UpdateControls(this); _effectNode = effectNode; _effectNodes = null; IEnumerable <IEffectEditorControl> controls = ApplicationServices.GetEffectEditorControls(_effectNode.Effect.Descriptor.TypeId); if (controls == null) { Label l = new Label(); l.Text = "Can't find any effect editors that can edit this effect!"; l.Anchor = AnchorStyles.None; tableLayoutPanelEffectEditors.Controls.Add(l); tableLayoutPanelEffectEditors.SetColumnSpan(l, 2); return; } _controls = new List <IEffectEditorControl>(); object[] values = _effectNode.Effect.ParameterValues; if (_effectNode.Effect.EffectName.Equals("Nutcracker")) { var data = _effectNode.Effect.ParameterValues.First() as ICloneable; values = new [] { data.Clone() }; } _cleanValues = _effectNode.Effect.ParameterValues; // if there were multiple controls returned, or there was only a single control needed (ie. the efffect parameters had only // a single item) then add controls inside a ParameterEditor wrapper using editors for that type, and label them appropriately. // if it was only a single control returned, it must have matched the entire effect (by GUID or signature), so just dump the // control it, and let it deal with everything it needs to. if (controls.Count() > 1 || (controls.Count() == 1 && (_effectNode.Effect.Descriptor as IEffectModuleDescriptor).Parameters.Count == 1)) { _usedSingleControl = false; int i = 0; foreach (IEffectEditorControl ec in controls) { // as it's a single control for a single parameter, it *should* take the corresponding indexed parameter from the effect. // so pull that individual parameter out, and give it to the control as a single item. This is a bit of an assumption // and seems...... prone to breaking. TODO: review. ec.EffectParameterValues = values[i].AsEnumerable().ToArray(); ec.TargetEffect = effectNode.Effect; if (_effectNode.Effect.Parameters[i].ShowLabel) { Label l = new Label(); l.Width = 1; l.Height = 1; l.Text = string.Format("{0}:", _effectNode.Effect.Parameters[i].Name); l.AutoSize = true; l.Anchor = AnchorStyles.None; tableLayoutPanelEffectEditors.Controls.Add(l); } (ec as Control).Anchor = AnchorStyles.None; tableLayoutPanelEffectEditors.Controls.Add(ec as Control); // save the editor control into a list we can use as a reference later on, to pull the data back out of them in the right order. _controls.Add(ec); i++; } } else { _usedSingleControl = true; IEffectEditorControl control = controls.First(); control.EffectParameterValues = _effectNode.Effect.ParameterValues; control.TargetEffect = effectNode.Effect; tableLayoutPanelEffectEditors.Controls.Add(control as Control); tableLayoutPanelEffectEditors.SetColumnSpan((control as Control), 2); _controls.Add(control); } }
private bool _IsExpired(TimeSpan currentTime, EffectNode effectNode) { return(currentTime > effectNode.EndTime); }
public UVAffector(UVAnimation frame, float time, EffectNode node) : base(node) { Frames = frame; UVTime = time; }
public VortexAffector(AnimationCurve vortexCurve, Vector3 dir, EffectNode node) : base(node) { VortexCurve = vortexCurve; Direction = dir; UseCurve = true; }
public void AddActiveNode(EffectNode node) { if (AvailableNodeCount == 0) Debug.LogError("out index!"); if (AvailableENodes[node.Index] == null) //already added return; ActiveENodes[node.Index] = node; AvailableENodes[node.Index] = null; AvailableNodeCount--; }
public ColorAffector(Color[] colorArr, float gradualLen, COLOR_GRADUAL_TYPE type, EffectNode node) : base(node) { this.ColorArr = colorArr; this.Type = type; this.GradualLen = gradualLen; if (this.GradualLen < 0f) { this.IsNodeLife = true; } }
protected void Init() { //added 2012.6.24 InitCollision(); Owner = transform.parent.gameObject.GetComponent<XffectComponent>(); if (Owner == null) Debug.LogError("you must set EffectLayer to be XffectComponent's child."); //fixed 2012.6.2. ignoring the red errors. if (ClientTransform == null) { Debug.LogWarning("effect layer: "+ gameObject.name + " haven't assign a client transform, automaticly set to itself."); ClientTransform = transform; } AvailableENodes = new EffectNode[MaxENodes]; ActiveENodes = new EffectNode[MaxENodes]; for (int i = 0; i < MaxENodes; i++) { EffectNode n = new EffectNode(i, ClientTransform, SyncClient, this); List<Affector> afts = InitAffectors(n); n.SetAffectorList(afts); if (RenderType == 0) n.SetType(SpriteWidth, SpriteHeight, (STYPE)SpriteType, (ORIPOINT)OriPoint, SpriteUVStretch, 60f); else if (RenderType == 1) { float rwidth = RibbonWidth; float rlen = RibbonLen; if (UseRandomRibbon) { rwidth = Random.Range(RibbonWidthMin, RibbonWidthMax); rlen = Random.Range(RibbonLenMin, RibbonLenMax); } n.SetType(FaceToObject, FaceObject, rwidth, MaxRibbonElements, rlen, ClientTransform.position + EmitPoint, StretchType, 60f); } else if (RenderType == 2) { n.SetType(ConeSize,ConeSegment,ConeAngle, transform.rotation * OriVelocityAxis,0,60f,UseConeAngleChange,ConeDeltaAngle); } else if (RenderType == 3) { Vector3 dir = Vector3.zero; if (OriVelocityAxis == Vector3.zero) { OriVelocityAxis = Vector3.up; } dir = transform.rotation * OriVelocityAxis; n.SetType(CMesh,dir,60f); } AvailableENodes[i] = n; } AvailableNodeCount = MaxENodes; emitter = new Emitter(this); }
/// <summary> /// Populates the TimelineControl grid with a new TimedSequenceElement for the given EffectNode. /// Will add a single TimedSequenceElement to in each row that each targeted element of /// the EffectNode references. It will also add callbacks to event handlers for the element. /// </summary> /// <param name="node">The EffectNode to make element(s) in the grid for.</param> private TimedSequenceElement AddElementForEffectNodeTpl(EffectNode node) { TimedSequenceElement element = SetupNewElementFromNode(node); // for the effect, make a single element and add it to every row that represents its target elements node.Effect.TargetNodes.AsParallel().WithCancellation(_cancellationTokenSource.Token) .ForAll(target => { if (_elementNodeToRows.ContainsKey(target)) { // Add the element to each row that represents the element this command is in. foreach (Row row in _elementNodeToRows[target]) { if (!_effectNodeToElement.ContainsKey(node)) { _effectNodeToElement[node] = element; } row.AddElement(element); } } else { // we don't have a row for the element this effect is referencing; most likely, the row has // been deleted, or we're opening someone else's sequence, etc. Big fat TODO: here for that, then. // dunno what we want to do: prompt to add new elements for them? map them to others? etc. const string message = "TimedSequenceEditor: <AddElementForEffectNodeTpl> - No Timeline.Row is associated with a target ElementNode for this EffectNode. It now exists in the sequence, but not in the GUI."; Logging.Error(message); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm(message, @"", false, false); messageBox.ShowDialog(); } }); TimelineControl.grid.RenderElement(element); return element; }
public UVAffector(UVAnimation frame, float time, EffectNode node) : base(node) { this.Frames = frame; this.UVTime = time; }
/// <summary> /// Removes the Effect Node and Element /// </summary> /// <param name="node"></param> public void RemoveEffectNodeAndElement(EffectNode node) { //Debug.WriteLine("{0} RemoveEffectNodeAndElement(InstanceId={1})", (int)DateTime.Now.TimeOfDay.TotalMilliseconds, node.Effect.InstanceId); // Lookup this effect node's Timeline Element if (_effectNodeToElement.ContainsKey(node)) { TimedSequenceElement tse = (TimedSequenceElement) _effectNodeToElement[node]; foreach (Row row in TimelineControl) // Remove the element from all rows row.RemoveElement(tse); // TODO: Unnecessary? tse.ContentChanged -= ElementContentChangedHandler; // Unregister event handlers tse.TimeChanged -= ElementTimeChangedHandler; _effectNodeToElement.Remove(node); // Remove the effect node from the map _sequence.RemoveData(node); // Remove the effect node from sequence Sequence.GetSequenceLayerManager().RemoveEffectNodeFromLayers(node); } else { Logging.Error("Missing node on remove attempt in RemoveEffectNodeAndElement."); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm("Node to remove not found, the editor is in a bad state! Please close the editor and restart it.", "Error", false, false); messageBox.ShowDialog(); } }
public JetAffector(float min, float max, EffectNode node) : base(node) { MinAcceleration = min; MaxAcceleration = max; }
public void RemoveActiveNode(EffectNode node) { if (AvailableNodeCount == MaxENodes) Debug.LogError("out index!"); if (ActiveENodes[node.Index] == null) //already removed return; ActiveENodes[node.Index] = null; AvailableENodes[node.Index] = node; AvailableNodeCount++; }
public LinearForceAffector(Vector3 force, EffectNode node) : base(node) { Force = force; }
protected List<Affector> InitAffectors(EffectNode node) { List<Affector> AffectorList = new List<Affector>(); if (UVAffectorEnable) { UVAnimation uvAnim = new UVAnimation(); if (UVType == 1) { float perWidth = OriUVDimensions.x / Cols; float perHeight = Mathf.Abs(OriUVDimensions.y / Rows); Vector2 cellSize = new Vector2(perWidth, perHeight); uvAnim.BuildUVAnim(OriTopLeftUV, cellSize, Cols, Rows, Cols * Rows); } UVDimension = uvAnim.UVDimensions[0]; UVTopLeft = uvAnim.frames[0]; if (uvAnim.frames.Length != 1) { uvAnim.loopCycles = LoopCircles; Affector aft = new UVAffector(uvAnim, UVTime, node, RandomStartFrame); AffectorList.Add(aft); } } else { UVDimension = OriUVDimensions; UVTopLeft = OriTopLeftUV; } if (RotAffectorEnable && RotateType != RSTYPE.NONE) { Affector aft; if (RotateType == RSTYPE.CURVE) aft = new RotateAffector(RotateCurve, node); else aft = new RotateAffector(DeltaRot, node); AffectorList.Add(aft); } if (ScaleAffectorEnable && ScaleType != RSTYPE.NONE) { Affector aft; if (UseSameScaleCurve) ScaleYCurve = ScaleXCurve; if (ScaleType == RSTYPE.CURVE) aft = new ScaleAffector(ScaleXCurve, ScaleYCurve, node); else aft = new ScaleAffector(DeltaScaleX, DeltaScaleY, node); AffectorList.Add(aft); } if (ColorAffectorEnable /*&& ColorAffectType != 0*/) { ColorAffector aft = new ColorAffector(this, node); AffectorList.Add(aft); } if (JetAffectorEnable) { Affector aft = new JetAffector(JetMag,JetMagType,JetCurve,node); AffectorList.Add(aft); } if (VortexAffectorEnable) { Affector aft; aft = new VortexAffector(VortexObj, VortexMagType, VortexMag, VortexCurve, VortexDirection, VortexInheritRotation, node); AffectorList.Add(aft); } if (UVRotAffectorEnable) { Affector aft; float xscroll = UVRotXSpeed; float yscroll = UVRotYSpeed; if (RandomUVRotateSpeed) { xscroll = Random.Range(UVRotXSpeed,UVRotXSpeedMax); yscroll = Random.Range(UVRotYSpeed,UVRotYSpeedMax); } aft = new UVRotAffector(xscroll, yscroll, node); AffectorList.Add(aft); } if (GravityAffectorEnable) { Affector aft; aft = new GravityAffector(GravityObject, GravityAftType, GravityMagType, IsGravityAccelerate,GravityDirection, GravityMag, GravityCurve, node); AffectorList.Add(aft); if (GravityAftType == GAFTTYPE.Spherical && GravityObject == null) { Debug.LogWarning("Gravity Object is missing, automatically set to effect layer self:" + gameObject.name); GravityObject = transform; } } if (AirAffectorEnable) { Affector aft = new AirFieldAffector(AirObject, AirDirection, AirMagType, AirMagnitude, AirMagCurve, AirAttenuation, AirUseMaxDistance, AirMaxDistance, AirEnableSpread, AirSpread, AirInheritVelocity, AirInheritRotation, node); AffectorList.Add(aft); } if (BombAffectorEnable) { Affector aft = new BombAffector(BombObject, BombType, BombMagType, BombDecayType, BombMagnitude, BombMagCurve, BombDecay, BombAxis, node); AffectorList.Add(aft); } if (TurbulenceAffectorEnable) { Affector aft = new TurbulenceFieldAffector(TurbulenceObject, TurbulenceMagType, TurbulenceMagnitude, TurbulenceMagCurve, TurbulenceAttenuation, TurbulenceUseMaxDistance, TurbulenceMaxDistance, node); AffectorList.Add(aft); } if (DragAffectorEnable) { Affector aft = new DragAffector(DragObj,DragUseDir,DragDir,DragMag,DragUseMaxDist,DragMaxDist,DragAtten,node); AffectorList.Add(aft); } return AffectorList; }
public RotateAffector(AnimationCurve curve,EffectNode node) : base(node) { Type = RSTYPE.CURVE; RotateCurve = curve; }
public void SetEmitPosition(EffectNode node) { Vector3 retPos = Vector3.zero; if (Layer.EmitType == (int)EMITTYPE.BOX) { Vector3 center = Layer.EmitPoint; float x = Random.Range(center.x - Layer.BoxSize.x / 2, center.x + Layer.BoxSize.x / 2); float y = Random.Range(center.y - Layer.BoxSize.y / 2, center.y + Layer.BoxSize.y / 2); float z = Random.Range(center.z - Layer.BoxSize.z / 2, center.z + Layer.BoxSize.z / 2); retPos.x = x; retPos.y = y; retPos.z = z; if (!Layer.SyncClient) retPos = Layer.ClientTransform.position + retPos; } else if (Layer.EmitType == (int)EMITTYPE.POINT) { retPos = Layer.EmitPoint; if (!Layer.SyncClient) { retPos = Layer.ClientTransform.position + Layer.EmitPoint; } } else if (Layer.EmitType == (int)EMITTYPE.SPHERE) { retPos = Layer.EmitPoint; if (!Layer.SyncClient) {//ͬ���Ļ���NodeUpdate������λ�� retPos = Layer.ClientTransform.position + Layer.EmitPoint; } Vector3 r = Vector3.up * Layer.Radius; Quaternion rot = Quaternion.Euler(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360)); retPos = rot * r + retPos; } //NOTICE LINE Direction currently is based on ClientTransform's forward else if (Layer.EmitType == (int)EMITTYPE.LINE) { Vector3 left = Layer.EmitPoint + Layer.ClientTransform.localRotation * Vector3.forward * Layer.LineLengthLeft; Vector3 right = Layer.EmitPoint + Layer.ClientTransform.localRotation * Vector3.forward * Layer.LineLengthRight; Vector3 dir = right - left; float p = (float)(node.Index + 1) / Layer.MaxENodes; float length = dir.magnitude * p; retPos = left + dir.normalized * length; if (!Layer.SyncClient) retPos = Layer.ClientTransform.TransformPoint(retPos); } else if (Layer.EmitType == (int)EMITTYPE.CIRCLE) { float p = (float)(node.Index + 1) / Layer.MaxENodes; float rangle; rangle = 360 * p; Quaternion rotY = Quaternion.Euler(0, rangle, 0); Vector3 v = rotY * (Vector3.right * Layer.Radius); Quaternion rotTo = Quaternion.FromToRotation(Vector3.up, Layer.CircleDir); retPos = rotTo * v; if (!Layer.SyncClient) retPos = Layer.ClientTransform.position + retPos + Layer.EmitPoint; else retPos = retPos + Layer.EmitPoint; } node.SetLocalPosition(retPos); }
private List<Element> CloneElements(IEnumerable<Element> elements) { var newElements = new List<Element>(); foreach (var element in elements) { var newEffect = ApplicationServices.Get<IEffectModuleInstance>(element.EffectNode.Effect.TypeId); newEffect.ModuleData = element.EffectNode.Effect.ModuleData.Clone(); try { // get the target element var targetNode = (ElementNode)element.Row.Tag; // populate the given effect instance with the appropriate target node and times, and wrap it in an effectNode newEffect.TargetNodes = new[] { targetNode }; newEffect.TimeSpan = element.Duration; var effectNode = new EffectNode(newEffect, element.StartTime); // put it in the sequence and in the timeline display newElements.Add(AddEffectNode(effectNode)); } catch (Exception ex) { string msg = "TimedSequenceEditor CloneElements: error adding effect of type " + newEffect.Descriptor.TypeId + " to row " + ((element.Row == null) ? "<null>" : element.Row.Name); Logging.ErrorException(msg, ex); } } sequenceModified(); //Add elements as a group to undo var act = new EffectsAddedUndoAction(this, newElements.Select(x => x.EffectNode).ToArray()); _undoMgr.AddUndoAction(act); return newElements; }
public ScaleAffector(AnimationCurve curveX, AnimationCurve curveY, EffectNode node) : base(node) { Type = RSTYPE.CURVE; ScaleXCurve = curveX; ScaleYCurve = curveY; }
/// <summary> /// Adds an EffectNode to the sequence and the TimelineControl. /// </summary> /// <param name="node"></param> /// <returns>The TimedSequenceElement created and added to the TimelineControl.</returns> public TimedSequenceElement AddEffectNode(EffectNode node) { //Debug.WriteLine("{0} AddEffectNode({1})", (int)DateTime.Now.TimeOfDay.TotalMilliseconds, node.Effect.InstanceId); _sequence.InsertData(node); //return addElementForEffectNode(node); return addElementForEffectNodeTPL(node); }
public ScaleAffector(float x, float y, EffectNode node) : base(node) { Type = RSTYPE.SIMPLE; DeltaX = x; DeltaY = y; }
public void Execute(EffectNode[] data) { _dataSource.AddData(data); }
public RotateAffector(AnimationCurve curve, EffectNode node) : base(node) { Type = RSTYPE.CURVE; RotateCurve = curve; }