//----------------------Initialize---------------------------------// // <summary> // Initialize animation clip with it's root timeline. Crashes if root timeline is not present. // First operation that has to be performed to work with GAF playback. // Creating serializable data e.g. game objects of animation children. // </summary> // <param name="_Asset">Animation asset file.</param> //public virtual void initialize(GAFAnimationAssetInternal _Asset) //-------------------------------------------------------// //----------------------Initialize (overload)---------------------------------// // <summary> // Initialize animation clip. // First operation that has to be performed to work with GAF playback. // Creating serializable data e.g. game objects of animation children. // </summary> // <param name="_Asset">Animation asset file.</param> // <param name="_TimelineID">ID of timeline.</param> //public override void initialize(GAFAnimationAssetInternal _Asset, int _TimelineID) //-------------------------------------------------------// //---------------------Reload--------------------------// /// <summary> /// Reload animation view. /// Second opertation that has to be performed to work with GAF playback. /// Creating non-serializable data e.g. meshes, runtime materials. /// Updating animation view to a currently selected frame. /// Should be called every time when animation view has been changed e.g. setting animation color. /// </summary> //public override void reload() //-------------------------------------------------------// //-------------------Get object------------------------------// // <summary> // Getting reference to an object by ID // </summary> // <param name="_ID">ID of animation suboject e.g "2_27" - "27" is object ID.</param> // <returns>IGAFObject.</returns> //public abstract IGAFObject getObject (uint _ID); //-------------------------------------------------------// //-------------------Get object (overload)------------------------------// // <summary> // Get object by name. If your object has custom name in inspector you can get it here. // </summary> // <param name="_PartName">Name of part.</param> // <returns></returns> //public virtual IGAFObject getObject(string _PartName) //-------------------------------------------------------// //---------------Object ID to part name------------------// // <summary> // Get object name by it's ID. // </summary> // <param name="_ID">ID of object.</param> // <returns></returns> //public string objectIDToPartName(uint _ID) //-------------------------------------------------------// //---------------Part name to object ID------------------// // <summary> // Get object id by name. // </summary> // <param name="_PartName">Named part name.</param> // <returns></returns> //public uint partNameToObjectID(string _PartName) //-------------------------------------------------------// //--------------------Get objects count------------------------------// // <summary> // Get number of animation objects // </summary> // <returns>System.Int32.</returns> //public override int getObjectsCount() //-------------------------------------------------------// //---------------------Clear--------------------------// // <summary> // Clear all information about objects in animation. // Moves animation to not initialized state. // </summary> // <param name="destroyChildren">Destroy game objects from scene.</param> //public void clear(bool destroyChildren = false) //-------------------------------------------------------// //---------------------Clean view--------------------------// // <summary> // Clean up animation non-serialized data. // Calling reload resets animation state. // </summary> //public void cleanView() //-------------------------------------------------------// //---------------------Get shared material--------------------------// // <summary> // Returns reference to a shared material // </summary> // <param name="_Name">Name of material (without .mat)</param> // <returns></returns> //public Material getSharedMaterial(string _Name) //-------------------------------------------------------// //------------------Register external material---------------------// // <summary> // Registering material as one that is used in this clip // </summary> // <param name="_Material">Material to register</param> //public void registerExternalMaterial(Material _Material) //-------------------------------------------------------// #endregion /////// GAFBaseClip /////// #region //////// GAFMovieClip ///////// //---------------------Play--------------------------// // <summary> // Start playing animation. // </summary> //public void play() //-------------------------------------------------------// //---------------------Pause--------------------------// // <summary> // Pause animation. // </summary> //public void pause() //-------------------------------------------------------// //---------------------Stop--------------------------// // <summary> // Stop playing animation. Moving playback to a first frame in a current sequence. // </summary> //public void stop() //-------------------------------------------------------// //---------------------Go to and stop--------------------------// // <summary> // Go to the desired frame. // </summary> // <param name="_FrameNumber">Number of frame.</param> //public void gotoAndStop(uint _FrameNumber) //-------------------------------------------------------// //---------------------Go to and play--------------------------// // <summary> // Go to the desired frame and start playing. // </summary> // <param name="_FrameNumber">Number of frame.</param> //public void gotoAndPlay(uint _FrameNumber) //-------------------------------------------------------// //---------------------Sequence index to name--------------------------// // <summary> // Get sequence name by index. // </summary> // <param name="_Index">Index of sequence.</param> // <returns>System.String.</returns> //public string sequenceIndexToName(uint _Index) //-------------------------------------------------------// //---------------------Sequence name to index--------------------------// // <summary> // Get sequence index by name. // </summary> // <param name="_Name">Name of sequence.</param> // <returns>System.UInt32.</returns> //public uint sequenceNameToIndex(string _Name) //-------------------------------------------------------// //---------------------Set sequence--------------------------// // <summary> // Set sequence for playing. // </summary> // <param name="_SequenceName">Name of desired sequence.</param> // <param name="_PlayImmediately">Run this sequence immediately.</param> //public void setSequence(string _SequenceName, bool _PlayImmediately = false) //-------------------------------------------------------// //---------------------Set default sequence--------------------------// // <summary> // Set playback to a default sequence. // </summary> // <param name="_PlayImmediately">Run this sequence immediately.</param> //public void setDefaultSequence(bool _PlayImmediately = false) //-------------------------------------------------------// //-------------Get current sequence index-----------------// // <summary> // Get index of current sequence. // </summary> // <returns>System.UInt32.</returns> //public uint getCurrentSequenceIndex() //-------------------------------------------------------// //---------------------Get current frame number--------------------------// // <summary> // Get current frame number. // </summary> // <returns>System.UInt32.</returns> //public uint getCurrentFrameNumber() //-------------------------------------------------------// //---------------------Get frames count--------------------------// // <summary> // Get count of frames in current timeline. // </summary> // <returns>System.UInt32.</returns> //public uint getFramesCount() //-------------------------------------------------------// //---------------------Get animation wrap mode--------------------------// // <summary> // Get wrap mode. // </summary> // <returns>GAFWrapMode.</returns> //public GAFWrapMode getAnimationWrapMode() //-------------------------------------------------------// //---------------Set animation wrap mode-----------------// // <summary> // Set wrap mode. // </summary> // <param name="_Mode">Type of wrap mode.</param> //public void setAnimationWrapMode(GAFWrapMode _Mode) //-------------------------------------------------------// //---------------------Is playing--------------------------// // <summary> // Check if animation is playing. // </summary> // <returns><c>true</c> if this instance is playing; otherwise, <c>false</c>.</returns> //public bool isPlaying() //-------------------------------------------------------// //---------------------Duration--------------------------// // <summary> // Get duration of current sequence. // </summary> // <returns>System.Single.</returns> //public float duration() //-------------------------------------------------------// //---------------------Add trigger--------------------------// // <summary> // Add event trigger on a desired frame. // Used for defining callbacks e.g. sounds, custom effects. // Returns ID of current event. // </summary> // <param name="_Callback">Event will been call on selected frame.</param> // <param name="_FrameNumber">Frame number.</param> // <returns>System.String.</returns> //public string addTrigger(Action<IGAFMovieClip> _Callback, uint _FrameNumber) //-------------------------------------------------------// //---------------------Remove trigger--------------------------// // <summary> // Remove event trigger by its ID. // </summary> // <param name="_ID">ID of trigger.</param> //public void removeTrigger(string _ID) //-------------------------------------------------------// //----------------Remove all triggers--------------------// // <summary> // Remove all event triggers on selected frame. // </summary> // <param name="_FrameNumber">Number of frame.</param> //public void removeAllTriggers(uint _FrameNumber) //-------------------------------------------------------// //----------------Remove all triggers (overload)--------------------// // <summary> // Remove all event triggers in current animation. // </summary> //public void removeAllTriggers() //-------------------------------------------------------// protected override void setState(ref GAFObjectStateData _State, Dictionary <uint, IGAFObject> _Objects) { if (settings.cacheStates) { _State.vertices = new Vector3[4]; float scale = settings.pixelsPerUnit / settings.scale; var matrix = Matrix4x4.identity; var obj = _Objects[_State.id].impl; matrix[0, 0] = _State.a; matrix[0, 1] = _State.c; matrix[1, 0] = _State.b; matrix[1, 1] = _State.d; matrix[0, 3] = _State.localPosition.x / scale + obj.serializedProperties.offset.x + settings.pivotOffset.x; matrix[1, 3] = -_State.localPosition.y / scale + obj.serializedProperties.offset.y + settings.pivotOffset.y; matrix[2, 3] = 0; for (int j = 0; j < obj.initialVertices.Length; j++) { _State.vertices[j] = matrix.MultiplyPoint3x4(obj.initialVertices[j]); } } else { _State.vertices = null; } }
//----------------------------------------------------// //---------------------Update to state--------------------------// /// <summary> /// Update object to desired state. /// </summary> /// <param name="_State">State data.</param> /// <param name="_Refresh">Force refresh state.</param> public override void updateToState(GAFObjectStateData _State, bool _Refresh) { base.updateToState(_State, _Refresh); if (hasController()) { m_Controller.updateToState(currentMesh, currentMaterial); } }
public override void updateToState(GAFObjectStateData _State, bool _Refresh) { currentState = _State; if (movieClip != null) { float scale = movieClip.settings.pixelsPerUnit / movieClip.settings.scale; transform.localPosition = new Vector3(_State.tX / scale, -_State.tY / scale, -_State.zOrder / scale); } }
private void updateObjectState(GAFObjectStateData _State) { currentState.tX = _State.tY; currentState.tY = _State.tY; currentState.zOrder = _State.zOrder; currentState.a = _State.a; currentState.b = _State.b; currentState.c = _State.c; currentState.d = _State.d; }
public virtual void updateToState(GAFObjectStateData _State, bool _Refresh) { gameObject.SetActive(_State.alpha > 0); if (renderer != null) { renderer.enabled = visible; } foreach (var component in m_Components) { component.updateToState(_State, _Refresh); } }
public override void updateToState(GAFObjectStateData _State, bool _Refresh) { updateMasking(_State, _Refresh); if (material != m_SharedMaterial) { updateMaterialColor(_State, _Refresh); } else { updateMeshColor(_State, _Refresh); } updateTransform(_State, _Refresh); }
protected virtual void updateTransform(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha > 0) { if (_Refresh || currentState.a != _State.a || currentState.b != _State.b || currentState.c != _State.c || currentState.d != _State.d || currentState.tX != _State.tX || currentState.tY != _State.tY || currentState.zOrder != _State.zOrder) { var clip = serializedProperties.clip; var pivotOffset = clip.settings.pivotOffset; float scale = clip.settings.pixelsPerUnit / clip.settings.scale; Matrix4x4 _transform = Matrix4x4.identity; _transform[0, 0] = _State.a; _transform[0, 1] = -_State.c; _transform[1, 0] = -_State.b; _transform[1, 1] = _State.d; _transform[0, 3] = _State.tX / scale + serializedProperties.offset.x + pivotOffset.x; _transform[1, 3] = -_State.tY / scale + serializedProperties.offset.y + pivotOffset.y; _transform[2, 3] = _State.zOrder / scale * clip.settings.zLayerScale; serializedProperties.statePosition = new Vector3(_State.tX / scale, -_State.tY / scale, _State.zOrder / scale * clip.settings.zLayerScale); for (int i = 0; i < initialVertices.Length; i++) { currentVertices[i] = _transform.MultiplyPoint3x4(initialVertices[i]); } if (currentState.zOrder != _State.zOrder) { renderProcessor.pushSortRequest(); } currentState.tX = _State.tY; currentState.tY = _State.tY; currentState.zOrder = _State.zOrder; currentState.a = _State.a; currentState.b = _State.b; currentState.c = _State.c; currentState.d = _State.d; } } }
protected virtual void updateTransform(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha > 0) { if (_Refresh || currentState.zOrder != _State.zOrder || currentState.tX != _State.tX || currentState.tY != _State.tY) { var clip = serializedProperties.clip; var scale = clip.settings.pixelsPerUnit / clip.settings.scale; serializedProperties.statePosition = new Vector3(_State.tX / scale, -_State.tY / scale, _State.zOrder / scale * clip.settings.zLayerScale); m_Object.transform.localPosition = serializedProperties.statePosition + serializedProperties.offset + (Vector3)clip.settings.pivotOffset; currentState.zOrder = _State.zOrder; } if (_Refresh || currentState.a != _State.a || currentState.b != _State.b || currentState.c != _State.c || currentState.d != _State.d) { Matrix4x4 _transform = Matrix4x4.identity; _transform[0, 0] = _State.a; _transform[0, 1] = -_State.c; _transform[1, 0] = -_State.b; _transform[1, 1] = _State.d; _transform[2, 3] = 0; for (int i = 0; i < initialVertices.Length; i++) { currentVertices[i] = _transform.MultiplyPoint3x4(initialVertices[i]); } filter.sharedMesh.vertices = currentVertices; currentState.tX = _State.tY; currentState.tY = _State.tY; currentState.zOrder = _State.zOrder; currentState.a = _State.a; currentState.b = _State.b; currentState.c = _State.c; currentState.d = _State.d; } } }
protected override void updateMeshColor(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha != _State.alpha || _Refresh) { if (_State.alpha == 0f || !serializedProperties.visible) { disableMask(); } else { enableMask(); } } base.updateMeshColor(_State, _Refresh); }
public virtual void init(GAFMovieClip _Player) { m_Components.Clear(); m_CurrentState = null; visible = initialVisible; initBaseData(_Player); initMesh(); initRenderer(); addComponent(new GAFTransform(this)); if (movieClip.asset.coloredObjects.Contains((int)objectID)) { addComponent(new GAFColorTransform(this)); } updateToState(currentState, true); }
public override void updateToState(GAFObjectStateData _State, bool _Refresh) { animationObject.transform.localRotation = Quaternion.identity; animationObject.transform.localScale = Vector3.one; if (_Refresh || currentState.tX != _State.tX || currentState.tY != _State.tY || currentState.zOrder != _State.zOrder) { float scale = movieClip.settings.pixelsPerUnit / movieClip.settings.scale; animationObject.transform.localPosition = new Vector3(_State.tX / scale, -_State.tY / scale, -_State.zOrder / scale); } if (_Refresh || currentState.a != _State.a || currentState.b != _State.b || currentState.c != _State.c || currentState.d != _State.d) { Matrix4x4 _transform = Matrix4x4.identity; _transform[0, 0] = _State.a; _transform[0, 1] = -_State.c; _transform[1, 0] = -_State.b; _transform[1, 1] = _State.d; Vector3 [] vertices = new Vector3[m_Vertices.Length]; for (int i = 0; i < vertices.Length; i++) { vertices[i] = _transform * m_Vertices[i]; } if (animationObject.filter.sharedMesh != null) { animationObject.filter.sharedMesh.vertices = vertices; animationObject.filter.sharedMesh.RecalculateBounds(); } } updateObjectState(_State); }
public override void updateToState(GAFObjectStateData _State, bool _Refresh) { if (animationObject.currentState.alpha != _State.alpha) { if (animationObject.renderer.sharedMaterial != null) { animationObject.renderer.sharedMaterial.SetFloat("_Alpha", _State.alpha); } } if (animationObject.currentState.colorMatrix != _State.colorMatrix) { if (animationObject.renderer.sharedMaterial != null) { animationObject.renderer.sharedMaterial.SetColor("_ColorMult", _State.colorMatrix != null ? _State.colorMatrix.multipliers : Color.white); animationObject.renderer.sharedMaterial.SetColor("_ColorShift", _State.colorMatrix != null ? _State.colorMatrix.offsets : m_sDisabledOffset); } } updateObjectState(_State); }
protected virtual void initBaseData(GAFMovieClip _Player) { m_Player = _Player; if (m_ObjectID < 0 || m_AtlasElementID < 0) { string [] names = gameObject.name.Split('_'); m_AtlasElementID = int.Parse(names[0]); m_ObjectID = int.Parse(names[1]); } if (m_CurrentState == null) { m_CurrentState = new GAFObjectStateData(objectID); } m_TextureAtlas = movieClip.asset.getAtlases(movieClip.timelineID).Find(atlas => atlas.scale == movieClip.settings.scale); m_AtlasElement = textureAtlas.getElement(atlasElementID); m_TextureInfo = textureAtlas.getAtlas(atlasElement.atlasID); }
protected virtual void initializeBaseData() { var clip = serializedProperties.clip; m_AtlasData = clip.asset.getAtlases(clip.timelineID).Find(atlas => atlas.scale == clip.settings.scale); m_AtlasElementData = m_AtlasData.getElement(serializedProperties.atlasElementID); m_TexturesData = m_AtlasData.getAtlas(m_AtlasElementData.atlasID); m_Texture = hasCustomTexture ? serializedProperties.material.mainTexture as Texture2D : clip.resource.getTexture(System.IO.Path.GetFileNameWithoutExtension(texturesData.getFileName(clip.settings.csf))); m_Material = hasCustomTexture ? serializedProperties.material : clip.getSharedMaterial(System.IO.Path.GetFileNameWithoutExtension(texturesData.getFileName(clip.settings.csf))); m_Material.renderQueue = 3000; m_CurrentState = new GAFObjectStateData(serializedProperties.objectID); m_Colors = new Color32[4] { initialColor, initialColor, initialColor, initialColor }; m_ColorShift = new Vector4[4]; calcInitialVertices(); calcUV(); }
//----------------------Initialize---------------------------------// // <summary> // Initialize animation clip with it's root timeline. Crashes if root timeline is not present. // <para />First operation that has to be performed to work with GAF playback. // <para />Creating serializable data e.g. game objects of animation children. // </summary> // <param name="_Asset">Animation asset file.</param> //public virtual void initialize(GAFAnimationAssetInternal _Asset) //-------------------------------------------------------// //----------------------Initialize (overload)---------------------------------// // <summary> // Initialize animation clip. // <para />First operation that has to be performed to work with GAF playback. // <para />Creating serializable data e.g. game objects of animation children. // </summary> // <param name="_Asset">Animation asset file.</param> // <param name="_TimelineID">ID of timeline.</param> //public override void initialize(GAFAnimationAssetInternal _Asset, int _TimelineID) //-------------------------------------------------------// //---------------------Reload--------------------------// /// <summary> /// Reload animation view. /// <para />Second opertation that has to be performed to work with GAF playback. /// <para />Creating non-serializable data e.g. meshes, runtime materials. /// <para />Updating animation view to a currently selected frame. /// <para />Should be called every time when animation view has been changed e.g. setting animation color. /// </summary> //public override void reload() //-------------------------------------------------------// //-------------------Get object------------------------------// // <summary> // Getting reference to an object by ID // </summary> // <param name="_ID">ID of animation suboject e.g "2_27" - "27" is object ID.</param> // <returns>IGAFObject.</returns> //public abstract IGAFObject getObject (uint _ID); //-------------------------------------------------------// //-------------------Get object (overload)------------------------------// // <summary> // Get object by name. If your object has custom name in inspector you can get it here. // </summary> // <param name="_PartName">Name of part.</param> // <returns></returns> //public virtual IGAFObject getObject(string _PartName) //-------------------------------------------------------// //---------------Object ID to part name------------------// // <summary> // Get object name by it's ID. // </summary> // <param name="_ID">ID of object.</param> // <returns></returns> //public string objectIDToPartName(uint _ID) //-------------------------------------------------------// //---------------Part name to object ID------------------// // <summary> // Get object id by name. // </summary> // <param name="_PartName">Named part name.</param> // <returns></returns> //public uint partNameToObjectID(string _PartName) //-------------------------------------------------------// //--------------------Get objects count------------------------------// // <summary> // Get number of animation objects // </summary> // <returns>System.Int32.</returns> //public override int getObjectsCount() //-------------------------------------------------------// //---------------------Clear--------------------------// // <summary> // Clear all information about objects in animation. // <para />Moves animation to not initialized state. // </summary> // <param name="destroyChildren">Destroy game objects from scene.</param> //public void clear(bool destroyChildren = false) //-------------------------------------------------------// //---------------------Clean view--------------------------// // <summary> // Clean up animation non-serialized data. // <para />Calling reload resets animation state. // </summary> //public void cleanView() //-------------------------------------------------------// //---------------------Get shared material--------------------------// // <summary> // Returns reference to a shared material // </summary> // <param name="_Name">Name of material (without .mat)</param> // <returns></returns> //public Material getSharedMaterial(string _Name) //-------------------------------------------------------// //------------------Register external material---------------------// // <summary> // Registering material as one that is used in this clip // </summary> // <param name="_Material">Material to register</param> //public void registerExternalMaterial(Material _Material) //-------------------------------------------------------// #endregion /////// GAFBaseClip /////// #region //////// GAFMovieClip ///////// //---------------------Play--------------------------// // <summary> // Start playing animation. // </summary> //public void play() //-------------------------------------------------------// //---------------------Pause--------------------------// // <summary> // Pause animation. // </summary> //public void pause() //-------------------------------------------------------// //---------------------Stop--------------------------// // <summary> // Stop playing animation. Moving playback to a first frame in a current sequence. // </summary> //public void stop() //-------------------------------------------------------// //---------------------Go to and stop--------------------------// // <summary> // Go to the desired frame. // </summary> // <param name="_FrameNumber">Number of frame.</param> //public void gotoAndStop(uint _FrameNumber) //-------------------------------------------------------// //---------------------Go to and play--------------------------// // <summary> // Go to the desired frame and start playing. // </summary> // <param name="_FrameNumber">Number of frame.</param> //public void gotoAndPlay(uint _FrameNumber) //-------------------------------------------------------// //---------------------Sequence index to name--------------------------// // <summary> // Get sequence name by index. // </summary> // <param name="_Index">Index of sequence.</param> // <returns>System.String.</returns> //public string sequenceIndexToName(uint _Index) //-------------------------------------------------------// //---------------------Sequence name to index--------------------------// // <summary> // Get sequence index by name. // </summary> // <param name="_Name">Name of sequence.</param> // <returns>System.UInt32.</returns> //public uint sequenceNameToIndex(string _Name) //-------------------------------------------------------// //---------------------Set sequence--------------------------// // <summary> // Set sequence for playing. // </summary> // <param name="_SequenceName">Name of desired sequence.</param> // <param name="_PlayImmediately">Run this sequence immediately.</param> //public void setSequence(string _SequenceName, bool _PlayImmediately = false) //-------------------------------------------------------// //---------------------Set default sequence--------------------------// // <summary> // Set playback to a default sequence. // </summary> // <param name="_PlayImmediately">Run this sequence immediately.</param> //public void setDefaultSequence(bool _PlayImmediately = false) //-------------------------------------------------------// //-------------Get current sequence index-----------------// // <summary> // Get index of current sequence. // </summary> // <returns>System.UInt32.</returns> //public uint getCurrentSequenceIndex() //-------------------------------------------------------// //---------------------Get current frame number--------------------------// // <summary> // Get current frame number. // </summary> // <returns>System.UInt32.</returns> //public uint getCurrentFrameNumber() //-------------------------------------------------------// //---------------------Get frames count--------------------------// // <summary> // Get count of frames in current timeline. // </summary> // <returns>System.UInt32.</returns> //public uint getFramesCount() //-------------------------------------------------------// //---------------------Get animation wrap mode--------------------------// // <summary> // Get wrap mode. // </summary> // <returns>GAFWrapMode.</returns> //public GAFWrapMode getAnimationWrapMode() //-------------------------------------------------------// //---------------Set animation wrap mode-----------------// // <summary> // Set wrap mode. // </summary> // <param name="_Mode">Type of wrap mode.</param> //public void setAnimationWrapMode(GAFWrapMode _Mode) //-------------------------------------------------------// //---------------------Is playing--------------------------// // <summary> // Check if animation is playing. // </summary> // <returns><c>true</c> if this instance is playing; otherwise, <c>false</c>.</returns> //public bool isPlaying() //-------------------------------------------------------// //---------------------Duration--------------------------// // <summary> // Get duration of current sequence. // </summary> // <returns>System.Single.</returns> //public float duration() //-------------------------------------------------------// //---------------------Add trigger--------------------------// // <summary> // Add event trigger on a desired frame. // <para />Used for defining callbacks e.g. sounds, custom effects. // <para />Returns ID of current event. // </summary> // <param name="_Callback">Event will been call on selected frame.</param> // <param name="_FrameNumber">Frame number.</param> // <returns>System.String.</returns> //public string addTrigger(Action<IGAFMovieClip> _Callback, uint _FrameNumber) //-------------------------------------------------------// //---------------------Remove trigger--------------------------// // <summary> // Remove event trigger by its ID. // </summary> // <param name="_ID">ID of trigger.</param> //public void removeTrigger(string _ID) //-------------------------------------------------------// //----------------Remove all triggers--------------------// // <summary> // Remove all event triggers on selected frame. // </summary> // <param name="_FrameNumber">Number of frame.</param> //public void removeAllTriggers(uint _FrameNumber) //-------------------------------------------------------// //----------------Remove all triggers (overload)--------------------// // <summary> // Remove all event triggers in current animation. // </summary> //public void removeAllTriggers() //-------------------------------------------------------// protected override void setState(ref GAFObjectStateData _State, Dictionary <uint, IGAFObject> _Objects) { if (settings.cacheStates) { _State.vertices = new Vector3[4]; var matrix = Matrix4x4.identity; var obj = _Objects[_State.id].impl; matrix[0, 0] = _State.a; matrix[0, 1] = _State.c; matrix[1, 0] = _State.b; matrix[1, 1] = _State.d; for (int j = 0; j < obj.initialVertices.Length; j++) { _State.vertices[j] = matrix.MultiplyPoint3x4(obj.initialVertices[j]); } } else { _State.vertices = null; } }
public void updateMasking(GAFObjectStateData _State, bool _Refresh) { if (_State.maskID != currentState.maskID || _Refresh) { if (currentState.maskID >= 0) { var oldMask = GAFStencilMaskManager.getMask(serializedProperties.clip.GetInstanceID(), (uint)currentState.maskID); m_StencilID = 0; oldMask.unregisterMaskedObject(this); disableMasking(); } if (_State.maskID >= 0) { var newMask = GAFStencilMaskManager.getMask(serializedProperties.clip.GetInstanceID(), (uint)_State.maskID); m_StencilID = newMask.getStencilID(); newMask.registerMaskedObject(this); enableMasking(); } currentState.maskID = _State.maskID; } }
public abstract void updateToState(GAFObjectStateData _State, bool _Refresh);
protected virtual void updateMeshColor(GAFObjectStateData _State, bool _Refresh) { if (_Refresh || currentState.alpha != _State.alpha) { if (!serializedProperties.visible) { if (renderProcessor.contains(serializedProperties.objectID)) { renderProcessor.remove(serializedProperties.objectID); } } else if (_State.alpha == 0f) { renderProcessor.remove(serializedProperties.objectID); } else { for (int i = 0; i < colors.Length; ++i) { colors[i].a = (byte)(_State.alpha * 255f); } if (!renderProcessor.contains(serializedProperties.objectID)) { renderProcessor.add(serializedProperties.clip.getObject(serializedProperties.objectID)); } } currentState.alpha = _State.alpha; } if (_Refresh || currentState.colorTransformData != _State.colorTransformData) { if (_State.colorTransformData != null) { for (int i = 0; i < colors.Length; ++i) { colors[i] = _State.colorTransformData.multipliers; } for (int i = 0; i < colorsShift.Length; ++i) { colorsShift[i] = _State.colorTransformData.offsets; } } else { for (int i = 0; i < colors.Length; ++i) { colors[i].r = (byte)255; colors[i].g = (byte)255; colors[i].b = (byte)255; } var offset = new Vector4(0f, 0f, 0f, 0f); for (int i = 0; i < colorsShift.Length; ++i) { colorsShift[i] = offset; } } currentState.colorTransformData = _State.colorTransformData; } if (serializedProperties.clip.settings.hasIndividualMaterial) { material.SetColor("_CustomColor", serializedProperties.clip.settings.animationColor); } }
public override void updateToState(GAFObjectStateData _State, bool _Refresh) { updateMeshColor(_State, _Refresh); updateTransform(_State, _Refresh); }
protected virtual void updateMaterialColor(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha != _State.alpha || _Refresh) { renderer.enabled = _State.alpha > 0f && serializedProperties.visible; for (int i = 0; i < colors.Length; ++i) { colors[i].a = (byte)(_State.alpha * 255f); } var color = new Color( (float)colors[0].r / 255f , (float)colors[0].g / 255f , (float)colors[0].b / 255f , (float)colors[0].a / 255f); material.SetColor("_TintColor", color); currentState.alpha = _State.alpha; } if (currentState.colorTransformData != _State.colorTransformData || _Refresh) { if (_State.colorTransformData != null) { for (int i = 0; i < colors.Length; ++i) { colors[i] = _State.colorTransformData.multipliers; } for (int i = 0; i < colorsShift.Length; ++i) { colorsShift[i] = _State.colorTransformData.offsets; } } else { for (int i = 0; i < colors.Length; ++i) { colors[i].r = (byte)255; colors[i].g = (byte)255; colors[i].b = (byte)255; } var offset = new Vector4(0f, 0f, 0f, 0f); for (int i = 0; i < colorsShift.Length; ++i) { colorsShift[i] = offset; } } var color = new Color( (float)colors[0].r / 255f , (float)colors[0].g / 255f , (float)colors[0].b / 255f , (float)colors[0].a / 255f); material.SetColor("_TintColor", color); material.SetVector("_TintColorOffset", colorsShift[0]); currentState.colorTransformData = _State.colorTransformData; } if (serializedProperties.clip.settings.hasIndividualMaterial) { material.SetColor("_CustomColor", serializedProperties.clip.settings.animationColor); } }
protected virtual void updateMeshColor(GAFObjectStateData _State, bool _Refresh) { var setColors = false; var setColorsShift = false; if (currentState.alpha != _State.alpha || _Refresh) { if (_State.alpha == 0f) { renderer.enabled = false; } else { renderer.enabled = serializedProperties.visible; for (int i = 0; i < colors.Length; ++i) colors[i].a = (byte)(_State.alpha * 255f); } setColors = true; currentState.alpha = _State.alpha; } if (currentState.colorTransformData != _State.colorTransformData || _Refresh) { if (_State.colorTransformData != null) { for (int i = 0; i < colors.Length; ++i) colors[i] = _State.colorTransformData.multipliers; for (int i = 0; i < colorsShift.Length; ++i) colorsShift[i] = _State.colorTransformData.offsets; } else { for (int i = 0; i < colors.Length; ++i) { colors[i].r = (byte)255; colors[i].g = (byte)255; colors[i].b = (byte)255; } var offset = new Vector4(0f, 0f, 0f, 0f); for (int i = 0; i < colorsShift.Length; ++i) colorsShift[i] = offset; } setColors = true; setColorsShift = true; currentState.colorTransformData = _State.colorTransformData; } if (setColors) filter.sharedMesh.colors32 = colors; if (setColorsShift) filter.sharedMesh.tangents = colorsShift; if (serializedProperties.clip.settings.hasIndividualMaterial) material.SetColor("_CustomColor", serializedProperties.clip.settings.animationColor); }
protected virtual void updateMaterialColor(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha != _State.alpha || _Refresh) { renderer.enabled = _State.alpha > 0f && serializedProperties.visible; for (int i = 0; i < colors.Length; ++i) colors[i].a = (byte)(_State.alpha * 255f); var color = new Color( (float)colors[0].r / 255f , (float)colors[0].g / 255f , (float)colors[0].b / 255f , (float)colors[0].a / 255f); material.SetColor("_TintColor", color); currentState.alpha = _State.alpha; } if (currentState.colorTransformData != _State.colorTransformData || _Refresh) { if (_State.colorTransformData != null) { for (int i = 0; i < colors.Length; ++i) colors[i] = _State.colorTransformData.multipliers; for (int i = 0; i < colorsShift.Length; ++i) colorsShift[i] = _State.colorTransformData.offsets; } else { for (int i = 0; i < colors.Length; ++i) { colors[i].r = (byte)255; colors[i].g = (byte)255; colors[i].b = (byte)255; } var offset = new Vector4(0f, 0f, 0f, 0f); for (int i = 0; i < colorsShift.Length; ++i) colorsShift[i] = offset; } var color = new Color( (float)colors[0].r / 255f , (float)colors[0].g / 255f , (float)colors[0].b / 255f , (float)colors[0].a / 255f); material.SetColor("_TintColor", color); material.SetVector("_TintColorOffset", colorsShift[0]); currentState.colorTransformData = _State.colorTransformData; } if (serializedProperties.clip.settings.hasIndividualMaterial) material.SetColor("_CustomColor", serializedProperties.clip.settings.animationColor); }
public abstract void updateToState( GAFObjectStateData _State , bool _Refresh);
public void addState(GAFObjectStateData state) { m_States.Add(state.id, state); }
protected virtual void updateTransform(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha > 0) { if (_Refresh || currentState.zOrder != _State.zOrder || currentState.tX != _State.tX || currentState.tY != _State.tY) { var clip = serializedProperties.clip; var scale = clip.settings.pixelsPerUnit / clip.settings.scale; serializedProperties.statePosition = new Vector3(_State.tX / scale, -_State.tY / scale, _State.zOrder / scale * clip.settings.zLayerScale); m_Object.transform.localPosition = serializedProperties.statePosition + serializedProperties.offset + (Vector3)clip.settings.pivotOffset; currentState.zOrder = _State.zOrder; } if (_Refresh || currentState.a != _State.a || currentState.b != _State.b || currentState.c != _State.c || currentState.d != _State.d) { Matrix4x4 _transform = Matrix4x4.identity; _transform[0, 0] = _State.a; _transform[0, 1] = -_State.c; _transform[1, 0] = -_State.b; _transform[1, 1] = _State.d; _transform[2, 3] = 0; for (int i = 0; i < initialVertices.Length; i++) { currentVertices[i] = _transform.MultiplyPoint3x4(initialVertices[i]); } filter.sharedMesh.vertices = currentVertices; filter.sharedMesh.RecalculateBounds(); currentState.tX = _State.tY; currentState.tY = _State.tY; currentState.zOrder = _State.zOrder; currentState.a = _State.a; currentState.b = _State.b; currentState.c = _State.c; currentState.d = _State.d; } } }
protected virtual void updateMeshColor(GAFObjectStateData _State, bool _Refresh) { var setColors = false; var setColorsShift = false; if (currentState.alpha != _State.alpha || _Refresh) { if (_State.alpha == 0f) { renderer.enabled = false; } else { renderer.enabled = serializedProperties.visible; for (int i = 0; i < colors.Length; ++i) { colors[i].a = (byte)(_State.alpha * 255f); } } setColors = true; currentState.alpha = _State.alpha; } if (currentState.colorTransformData != _State.colorTransformData || _Refresh) { if (_State.colorTransformData != null) { for (int i = 0; i < colors.Length; ++i) { colors[i] = _State.colorTransformData.multipliers; } for (int i = 0; i < colorsShift.Length; ++i) { colorsShift[i] = _State.colorTransformData.offsets; } } else { for (int i = 0; i < colors.Length; ++i) { colors[i].r = (byte)255; colors[i].g = (byte)255; colors[i].b = (byte)255; } var offset = new Vector4(0f, 0f, 0f, 0f); for (int i = 0; i < colorsShift.Length; ++i) { colorsShift[i] = offset; } } setColors = true; setColorsShift = true; currentState.colorTransformData = _State.colorTransformData; } if (setColors) { filter.sharedMesh.colors32 = colors; } if (setColorsShift) { filter.sharedMesh.tangents = colorsShift; } if (serializedProperties.clip.settings.hasIndividualMaterial) { material.SetColor("_CustomColor", serializedProperties.clip.settings.animationColor); } }
protected virtual void updateMaterialColor(GAFObjectStateData _State, bool _Refresh) { if (_Refresh || currentState.alpha != _State.alpha) { if (!serializedProperties.visible) { if (renderProcessor.contains(serializedProperties.objectID)) renderProcessor.remove(serializedProperties.objectID); } else if (_State.alpha == 0f) { renderProcessor.remove(serializedProperties.objectID); } else { for (int i = 0; i < colors.Length; ++i) colors[i].a = (byte)(_State.alpha * 255f); if (!renderProcessor.contains(serializedProperties.objectID)) renderProcessor.add(serializedProperties.clip.getObject(serializedProperties.objectID)); var color = new Color( (float)colors[0].r / 255f , (float)colors[0].g / 255f , (float)colors[0].b / 255f , (float)colors[0].a / 255f); material.SetColor("_TintColor", color); } currentState.alpha = _State.alpha; } if (_Refresh || currentState.colorTransformData != _State.colorTransformData) { if (_State.colorTransformData != null) { for (int i = 0; i < colors.Length; ++i) colors[i] = _State.colorTransformData.multipliers; for (int i = 0; i < colorsShift.Length; ++i) colorsShift[i] = _State.colorTransformData.offsets; } else { for (int i = 0; i < colors.Length; ++i) { colors[i].r = (byte)255; colors[i].g = (byte)255; colors[i].b = (byte)255; } var offset = new Vector4(0f, 0f, 0f, 0f); for (int i = 0; i < colorsShift.Length; ++i) colorsShift[i] = offset; } if (serializedProperties.visible) { var color = new Color( (float)colors[0].r / 255f , (float)colors[0].g / 255f , (float)colors[0].b / 255f , (float)colors[0].a / 255f); material.SetColor("_TintColor", color); material.SetVector("_TintColorOffset", colorsShift[0]); } currentState.colorTransformData = _State.colorTransformData; } if (serializedProperties.clip.settings.hasIndividualMaterial) material.SetColor("_CustomColor", serializedProperties.clip.settings.animationColor); }
protected virtual void updateTransform(GAFObjectStateData _State, bool _Refresh) { if (currentState.alpha > 0) { if (_Refresh || currentState.a != _State.a || currentState.b != _State.b || currentState.c != _State.c || currentState.d != _State.d || currentState.tX != _State.tX || currentState.tY != _State.tY || currentState.zOrder != _State.zOrder) { var clip = serializedProperties.clip; var pivotOffset = clip.settings.pivotOffset; float scale = clip.settings.pixelsPerUnit / clip.settings.scale; Matrix4x4 _transform = Matrix4x4.identity; _transform[0, 0] = _State.a; _transform[0, 1] = -_State.c; _transform[1, 0] = -_State.b; _transform[1, 1] = _State.d; _transform[0, 3] = _State.tX / scale + serializedProperties.offset.x + pivotOffset.x; _transform[1, 3] = -_State.tY / scale + serializedProperties.offset.y + pivotOffset.y; _transform[2, 3] = _State.zOrder / scale * clip.settings.zLayerScale; serializedProperties.statePosition = new Vector3(_State.tX / scale, -_State.tY / scale, _State.zOrder / scale * clip.settings.zLayerScale); for (int i = 0; i < initialVertices.Length; i++) { currentVertices[i] = _transform.MultiplyPoint3x4(initialVertices[i]); } if (currentState.zOrder != _State.zOrder) renderProcessor.pushSortRequest(); currentState.tX = _State.tY; currentState.tY = _State.tY; currentState.zOrder = _State.zOrder; currentState.a = _State.a; currentState.b = _State.b; currentState.c = _State.c; currentState.d = _State.d; } } }
public void updateToState(GAFObjectStateData _State, bool _Refresh) { m_Impl.updateToState(_State, _Refresh); }
public void updateToState(GAFObjectStateData _State, bool _Refresh) { gameObject.SetActive(_State.alpha > 0); m_Impl.updateToState(_State, _Refresh); }
private void updateObjectState(GAFObjectStateData _State) { currentState.alpha = _State.alpha; currentState.colorMatrix = _State.colorMatrix; }
protected virtual void setState(ref GAFObjectStateData _State, Dictionary <uint, IGAFObject> _Objects) { }
public override void updateToState(GAFObjectStateData _State, bool _Refresh) { updateMasking(_State, _Refresh); if (material != m_SharedMaterial) updateMaterialColor(_State, _Refresh); else updateMeshColor(_State, _Refresh); updateTransform(_State, _Refresh); }
private GAFObjectStateData ExctractState(BinaryReader _Reader) { bool hasColorTransform = System.Convert.ToBoolean(_Reader.ReadByte()); bool hasMasks = System.Convert.ToBoolean(_Reader.ReadByte()); bool hasEffect = System.Convert.ToBoolean(_Reader.ReadByte()); GAFObjectStateData state = new GAFObjectStateData(_Reader.ReadUInt32()); state.zOrder = _Reader.ReadInt32(); state.alpha = _Reader.ReadSingle(); state.a = _Reader.ReadSingle(); state.b = _Reader.ReadSingle(); state.c = _Reader.ReadSingle(); state.d = _Reader.ReadSingle(); state.tX = _Reader.ReadSingle(); state.tY = _Reader.ReadSingle(); if (hasColorTransform) { float [] ctxMul = new float[(int)GAFColorTransformIndex.COUNT]; float [] ctxOff = new float[(int)GAFColorTransformIndex.COUNT]; ctxMul[(int)GAFColorTransformIndex.GAFCTI_A] = state.alpha; ctxOff[(int)GAFColorTransformIndex.GAFCTI_A] = _Reader.ReadSingle(); ctxMul[(int)GAFColorTransformIndex.GAFCTI_R] = _Reader.ReadSingle(); ctxOff[(int)GAFColorTransformIndex.GAFCTI_R] = _Reader.ReadSingle(); ctxMul[(int)GAFColorTransformIndex.GAFCTI_G] = _Reader.ReadSingle(); ctxOff[(int)GAFColorTransformIndex.GAFCTI_G] = _Reader.ReadSingle(); ctxMul[(int)GAFColorTransformIndex.GAFCTI_B] = _Reader.ReadSingle(); ctxOff[(int)GAFColorTransformIndex.GAFCTI_B] = _Reader.ReadSingle(); Color colorMult = new Color( ctxMul[(int)GAFColorTransformIndex.GAFCTI_R] , ctxMul[(int)GAFColorTransformIndex.GAFCTI_G] , ctxMul[(int)GAFColorTransformIndex.GAFCTI_B] , ctxMul[(int)GAFColorTransformIndex.GAFCTI_A]); Color colorOff = new Color( ctxOff[(int)GAFColorTransformIndex.GAFCTI_R] , ctxOff[(int)GAFColorTransformIndex.GAFCTI_G] , ctxOff[(int)GAFColorTransformIndex.GAFCTI_B] , ctxOff[(int)GAFColorTransformIndex.GAFCTI_A]); state.colorMatrix = new GAFColorTransformationMatrix(colorMult, colorOff); } if (hasEffect) { byte effectsCount = _Reader.ReadByte(); for (byte e = 0; e < effectsCount; ++e) { // skip all GAFFilterType type = (GAFFilterType)_Reader.ReadUInt32(); switch (type) { case GAFFilterType.GFT_DropShadow: _Reader.BaseStream.Position += sizeof(uint) + 5 * sizeof(float) + 2 * sizeof(byte); break; case GAFFilterType.GFT_Blur: _Reader.BaseStream.Position += 2 * sizeof(float); break; case GAFFilterType.GFT_Glow: _Reader.BaseStream.Position += sizeof(uint) + 3 * sizeof(float) + 2 * sizeof(byte); break; case GAFFilterType.GFT_ColorMatrix: _Reader.BaseStream.Position += 20 * sizeof(float); break; } } } if (hasMasks) { state.maskID = (int)_Reader.ReadUInt32(); } return(state); }
//----------------------------------------------------// //---------------------Update to state--------------------------// /// <summary> /// Update object to desired state. /// </summary> /// <param name="_State">State data.</param> /// <param name="_Refresh">Force refresh state.</param> public override void updateToState(GAFObjectStateData _State, bool _Refresh) { base.updateToState(_State, _Refresh); if (hasController()) m_Controller.updateToState(currentMesh, currentMaterial); }