コード例 #1
0
ファイル: DisplayData.cs プロジェクト: soldiers1989/XLXQP
        public BoundingBoxData boundingBox = null; // Initial value.

        protected override void _OnClear()
        {
            base._OnClear();

            if (this.boundingBox != null)
            {
                this.boundingBox.ReturnToPool();
            }

            this.type        = DisplayType.BoundingBox;
            this.boundingBox = null;
        }
コード例 #2
0
ファイル: ArmatureData.cs プロジェクト: zyz120/AfterDeath
        protected override void _onClear()
        {
            if (boundingBox != null)
            {
                boundingBox.ReturnToPool();
            }

            isRelativePivot = false;
            type            = DisplayType.Image;
            name            = null;
            path            = null;
            share           = null;
            pivot.Clear();
            transform.Identity();
            texture     = null;
            armature    = null;
            mesh        = null;
            boundingBox = null;
        }
コード例 #3
0
        /**
         * @private
         */
        protected void _updateDisplayData()
        {
            var prevDisplayData        = _displayData;
            var prevReplaceDisplayData = _replacedDisplayData;
            var prevTextureData        = _textureData;
            var prevMeshData           = _meshData;
            var currentDisplay         = _displayIndex >= 0 && _displayIndex < _displayList.Count ? _displayList[_displayIndex] : null;

            if (_displayIndex >= 0 && _displayIndex < _skinSlotData.displays.Count)
            {
                _displayData = _skinSlotData.displays[_displayIndex];
            }
            else
            {
                _displayData = null;
            }

            if (_displayIndex >= 0 && _displayIndex < _replacedDisplayDatas.Count)
            {
                _replacedDisplayData = _replacedDisplayDatas[_displayIndex];
            }
            else
            {
                _replacedDisplayData = null;
            }

            if (_displayData != prevDisplayData || _replacedDisplayData != prevReplaceDisplayData || this._display != currentDisplay)
            {
                var currentDisplayData = _replacedDisplayData != null ? _replacedDisplayData : _displayData;
                if (currentDisplayData != null && (currentDisplay == _rawDisplay || currentDisplay == _meshDisplay))
                {
                    _textureData = _replacedDisplayData != null ? _replacedDisplayData.texture : _displayData.texture;
                    if (currentDisplay == _meshDisplay)
                    {
                        if (_replacedDisplayData != null && _replacedDisplayData.mesh != null)
                        {
                            _meshData = _replacedDisplayData.mesh;
                        }
                        else
                        {
                            _meshData = _displayData.mesh;
                        }
                    }
                    else
                    {
                        _meshData = null;
                    }

                    // Update pivot offset.
                    if (_meshData != null)
                    {
                        _pivotX = 0.0f;
                        _pivotY = 0.0f;
                    }
                    else if (_textureData != null)
                    {
                        var scale = _armature.armatureData.scale;
                        _pivotX = currentDisplayData.pivot.x;
                        _pivotY = currentDisplayData.pivot.y;

                        if (currentDisplayData.isRelativePivot)
                        {
                            var rect   = _textureData.frame != null ? _textureData.frame : _textureData.region;
                            var width  = rect.width * scale;
                            var height = rect.height * scale;

                            if (_textureData.rotated)
                            {
                                width  = rect.height;
                                height = rect.width;
                            }

                            _pivotX *= width;
                            _pivotY *= height;
                        }

                        if (_textureData.frame != null)
                        {
                            _pivotX += _textureData.frame.x * scale;
                            _pivotY += _textureData.frame.y * scale;
                        }
                    }
                    else
                    {
                        _pivotX = 0.0f;
                        _pivotY = 0.0f;
                    }

                    if (
                        _displayData != null && currentDisplayData != _displayData &&
                        (_meshData == null || _meshData != _displayData.mesh)
                        )
                    {
                        _displayData.transform.ToMatrix(_helpMatrix);
                        _helpMatrix.Invert();
                        _helpMatrix.TransformPoint(0.0f, 0.0f, _helpPoint);
                        _pivotX -= _helpPoint.x;
                        _pivotY -= _helpPoint.y;

                        currentDisplayData.transform.ToMatrix(_helpMatrix);
                        _helpMatrix.Invert();
                        _helpMatrix.TransformPoint(0.0f, 0.0f, _helpPoint);
                        _pivotX += _helpPoint.x;
                        _pivotY += _helpPoint.y;
                    }

                    if (_meshData != prevMeshData) // Update mesh bones and ffd vertices.
                    {
                        if (_meshData != null && _displayData != null && _meshData == _displayData.mesh)
                        {
                            if (_meshData.skinned)
                            {
                                DragonBones.ResizeList(_meshBones, _meshData.bones.Count, null);

                                for (int i = 0, l = _meshBones.Count; i < l; ++i)
                                {
                                    _meshBones[i] = _armature.GetBone(_meshData.bones[i].name);
                                }

                                int ffdVerticesCount = 0;
                                for (int i = 0, l = _meshData.boneIndices.Count; i < l; ++i)
                                {
                                    ffdVerticesCount += _meshData.boneIndices[i].Length;
                                }

                                DragonBones.ResizeList(_ffdVertices, ffdVerticesCount * 2, 0.0f);
                            }
                            else
                            {
                                _meshBones.Clear();
                                DragonBones.ResizeList(_ffdVertices, _meshData.vertices.Count, 0.0f);
                            }

                            for (int i = 0, l = _ffdVertices.Count; i < l; ++i)
                            {
                                _ffdVertices[i] = 0.0f;
                            }

                            _meshDirty = true;
                        }
                        else
                        {
                            _meshBones.Clear();
                            _ffdVertices.Clear();
                        }
                    }
                    else if (_textureData != prevTextureData)
                    {
                        _meshDirty = true;
                    }
                }
                else
                {
                    _textureData = null;
                    _meshData    = null;
                    _pivotX      = 0.0f;
                    _pivotY      = 0.0f;
                    _meshBones.Clear();
                    _ffdVertices.Clear();
                }

                _displayDirty  = true;
                _originalDirty = true;

                if (_displayData != null)
                {
                    origin = _displayData.transform;
                }
                else if (_replacedDisplayData != null)
                {
                    origin = _replacedDisplayData.transform;
                }
            }

            // Update bounding box data.
            if (_replacedDisplayData != null)
            {
                _boundingBoxData = _replacedDisplayData.boundingBox;
            }
            else if (_displayData != null)
            {
                _boundingBoxData = _displayData.boundingBox;
            }
            else
            {
                _boundingBoxData = null;
            }
        }
コード例 #4
0
        /**
         * @private
         */
        protected override void _onClear()
        {
            base._onClear();

            var disposeDisplayList = new List <object>();

            for (int i = 0, l = _displayList.Count; i < l; ++i)
            {
                var eachDisplay = _displayList[i];
                if (
                    eachDisplay != _rawDisplay && eachDisplay != _meshDisplay &&
                    !disposeDisplayList.Contains(eachDisplay)
                    )
                {
                    disposeDisplayList.Add(eachDisplay);
                }
            }

            for (int i = 0, l = disposeDisplayList.Count; i < l; ++i)
            {
                var eachDisplay = disposeDisplayList[i];
                if (eachDisplay is Armature)
                {
                    (eachDisplay as Armature).Dispose();
                }
                else
                {
                    _disposeDisplay(eachDisplay);
                }
            }

            if (_meshDisplay != null && _meshDisplay != _rawDisplay) // May be _meshDisplay and _rawDisplay is the same one.
            {
                _disposeDisplay(_meshDisplay);
            }

            if (_rawDisplay != null)
            {
                _disposeDisplay(_rawDisplay);
            }

            displayController = null;

            _displayDirty     = false;
            _zOrderDirty      = false;
            _blendModeDirty   = false;
            _colorDirty       = false;
            _originalDirty    = false;
            _transformDirty   = false;
            _meshDirty        = false;
            _updateState      = -1;
            _blendMode        = BlendMode.Normal;
            _displayIndex     = -1;
            _cachedFrameIndex = -1;
            _zOrder           = -1;
            _pivotX           = 0.0f;
            _pivotY           = 0.0f;
            _localMatrix.Identity();
            _colorTransform.Identity();
            _ffdVertices.Clear();
            _displayList.Clear();
            _replacedDisplayDatas.Clear();
            _meshBones.Clear();
            _skinSlotData        = null;
            _displayData         = null;
            _replacedDisplayData = null;
            _textureData         = null;
            _meshData            = null;
            _boundingBoxData     = null;
            _rawDisplay          = null;
            _meshDisplay         = null;
            _display             = null;
            _childArmature       = null;
            _cachedFrameIndices  = null;
        }
コード例 #5
0
        /// <private/>
        protected void _UpdateDisplayData()
        {
            var prevDisplayData  = this._displayData;
            var prevVerticesData = this._deformVertices != null ? this._deformVertices.verticesData : null;
            var prevTextureData  = this._textureData;

            DisplayData  rawDisplayData      = null;
            VerticesData currentVerticesData = null;

            this._displayData     = null;
            this._boundingBoxData = null;
            this._textureData     = null;

            if (this._displayIndex >= 0)
            {
                if (this._rawDisplayDatas != null)
                {
                    rawDisplayData = this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;
                }

                if (rawDisplayData == null)
                {
                    rawDisplayData = this._GetDefaultRawDisplayData(this._displayIndex);
                }

                if (this._displayIndex < this._displayDatas.Count)
                {
                    this._displayData = this._displayDatas[this._displayIndex];
                }
            }

            // Update texture and mesh data.
            if (this._displayData != null)
            {
                if (this._displayData.type == DisplayType.Mesh)
                {
                    currentVerticesData = (this._displayData as MeshDisplayData).vertices;
                }
                else if (this._displayData.type == DisplayType.Path)
                {
                    currentVerticesData = (this._displayData as PathDisplayData).vertices;
                }
                else if (rawDisplayData != null)
                {
                    if (rawDisplayData.type == DisplayType.Mesh)
                    {
                        currentVerticesData = (rawDisplayData as MeshDisplayData).vertices;
                    }
                    else if (rawDisplayData.type == DisplayType.Path)
                    {
                        currentVerticesData = (rawDisplayData as PathDisplayData).vertices;
                    }
                }

                if (this._displayData.type == DisplayType.BoundingBox)
                {
                    this._boundingBoxData = (this._displayData as BoundingBoxDisplayData).boundingBox;
                }
                else if (rawDisplayData != null)
                {
                    if (rawDisplayData.type == DisplayType.BoundingBox)
                    {
                        this._boundingBoxData = (rawDisplayData as BoundingBoxDisplayData).boundingBox;
                    }
                }

                if (this._displayData.type == DisplayType.Image)
                {
                    this._textureData = (this._displayData as ImageDisplayData).texture;
                }
                else if (this._displayData.type == DisplayType.Mesh)
                {
                    this._textureData = (this._displayData as MeshDisplayData).texture;
                }
            }

            if (this._displayData != prevDisplayData || currentVerticesData != prevVerticesData || this._textureData != prevTextureData)
            {
                // Update pivot offset.
                if (currentVerticesData == null && this._textureData != null)
                {
                    var imageDisplayData = this._displayData as ImageDisplayData;
                    var scale            = this._textureData.parent.scale * this._armature._armatureData.scale;
                    var frame            = this._textureData.frame;

                    this._pivotX = imageDisplayData.pivot.x;
                    this._pivotY = imageDisplayData.pivot.y;
                    //Debug.Log(_pivotX + "," + _pivotY);

                    var rect   = frame != null ? frame : this._textureData.region;
                    var width  = rect.width;
                    var height = rect.height;

                    if (this._textureData.rotated && frame == null)
                    {
                        width  = rect.height;
                        height = rect.width;
                    }

                    this._pivotX *= width * scale;
                    this._pivotY *= height * scale;
                    //Debug.Log(_pivotX + "," + _pivotY);
                    if (frame != null)
                    {
                        this._pivotX += frame.x * scale;
                        this._pivotY += frame.y * scale;
                    }

                    //Debug.Log("-----------");

                    // Update replace pivot. TODO
                    if (this._displayData != null && rawDisplayData != null && this._displayData != rawDisplayData)
                    {
                        rawDisplayData.transform.ToMatrix(Slot._helpMatrix);
                        Slot._helpMatrix.Invert();
                        Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                        this._pivotX -= Slot._helpPoint.x;
                        this._pivotY -= Slot._helpPoint.y;

                        this._displayData.transform.ToMatrix(Slot._helpMatrix);
                        Slot._helpMatrix.Invert();
                        Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                        this._pivotX += Slot._helpPoint.x;
                        this._pivotY += Slot._helpPoint.y;
                    }

                    if (!DragonBones.yDown)
                    {
                        this._pivotY = (this._textureData.rotated ? this._textureData.region.width : this._textureData.region.height) * scale - this._pivotY;
                    }
                }
                else
                {
                    this._pivotX = 0.0f;
                    this._pivotY = 0.0f;
                }

                // Update original transform.
                if (rawDisplayData != null)
                {
                    // Compatible.
                    this.origin = rawDisplayData.transform;
                }
                else if (this._displayData != null)
                {
                    // Compatible.
                    this.origin = this._displayData.transform;
                }
                else
                {
                    this.origin = null;
                }

                // Update vertices.
                if (currentVerticesData != prevVerticesData)
                {
                    if (this._deformVertices == null)
                    {
                        this._deformVertices = BaseObject.BorrowObject <DeformVertices>();
                    }

                    this._deformVertices.init(currentVerticesData, this._armature);
                }
                else if (this._deformVertices != null && this._textureData != prevTextureData)
                {
                    // Update mesh after update frame.
                    this._deformVertices.verticesDirty = true;
                }

                this._displayDirty   = true;
                this._transformDirty = true;
            }
        }
コード例 #6
0
        /// <inheritDoc/>
        protected override void _OnClear()
        {
            base._OnClear();

            var disposeDisplayList = new List <object>();

            for (int i = 0, l = _displayList.Count; i < l; ++i)
            {
                var eachDisplay = _displayList[i];
                if (eachDisplay != _rawDisplay && eachDisplay != _meshDisplay && !disposeDisplayList.Contains(eachDisplay))
                {
                    disposeDisplayList.Add(eachDisplay);
                }
            }

            for (int i = 0, l = disposeDisplayList.Count; i < l; ++i)
            {
                var eachDisplay = disposeDisplayList[i];
                if (eachDisplay is Armature)
                {
                    (eachDisplay as Armature).Dispose();
                }
                else
                {
                    this._DisposeDisplay(eachDisplay, true);
                }
            }

            if (this._deformVertices != null)
            {
                this._deformVertices.ReturnToPool();
            }

            if (this._meshDisplay != null && this._meshDisplay != this._rawDisplay)
            {
                // May be _meshDisplay and _rawDisplay is the same one.
                this._DisposeDisplay(this._meshDisplay, false);
            }

            if (this._rawDisplay != null)
            {
                this._DisposeDisplay(this._rawDisplay, false);
            }

            this.displayController = null;

            this._displayDirty          = false;
            this._zOrderDirty           = false;
            this._blendModeDirty        = false;
            this._colorDirty            = false;
            this._transformDirty        = false;
            this._visible               = true;
            this._blendMode             = BlendMode.Normal;
            this._displayIndex          = -1;
            this._animationDisplayIndex = -1;
            this._zOrder           = 0;
            this._cachedFrameIndex = -1;
            this._pivotX           = 0.0f;
            this._pivotY           = 0.0f;
            this._localMatrix.Identity();
            this._colorTransform.Identity();
            this._displayList.Clear();
            this._displayDatas.Clear();
            this._slotData           = null; //
            this._rawDisplayDatas    = null; //
            this._displayData        = null;
            this._boundingBoxData    = null;
            this._textureData        = null;
            this._deformVertices     = null;
            this._rawDisplay         = null;
            this._meshDisplay        = null;
            this._display            = null;
            this._childArmature      = null;
            this._parent             = null;
            this._cachedFrameIndices = null;
        }
コード例 #7
0
ファイル: Slot.cs プロジェクト: La-Resistencia/gamejam2018
        /// <private/>
        protected void _UpdateDisplayData()
        {
            var prevDisplayData = this._displayData;
            var prevTextureData = this._textureData;
            var prevMeshData    = this._meshData;
            var rawDisplayData  = this._displayIndex >= 0 && this._rawDisplayDatas != null && this._displayIndex < this._rawDisplayDatas.Count ? this._rawDisplayDatas[this._displayIndex] : null;

            if (this._displayIndex >= 0 && this._displayIndex < this._displayDatas.Count)
            {
                this._displayData = this._displayDatas[this._displayIndex];
            }
            else
            {
                this._displayData = null;
            }

            // Update texture and mesh data.
            if (this._displayData != null)
            {
                if (this._displayData.type == DisplayType.Image || this._displayData.type == DisplayType.Mesh)
                {
                    this._textureData = (this._displayData as ImageDisplayData).texture;
                    if (this._displayData.type == DisplayType.Mesh)
                    {
                        this._meshData = this._displayData as MeshDisplayData;
                    }
                    else if (rawDisplayData != null && rawDisplayData.type == DisplayType.Mesh)
                    {
                        this._meshData = rawDisplayData as MeshDisplayData;
                    }
                    else
                    {
                        this._meshData = null;
                    }
                }
                else
                {
                    this._textureData = null;
                    this._meshData    = null;
                }
            }
            else
            {
                this._textureData = null;
                this._meshData    = null;
            }

            // Update bounding box data.
            if (this._displayData != null && this._displayData.type == DisplayType.BoundingBox)
            {
                this._boundingBoxData = (this._displayData as BoundingBoxDisplayData).boundingBox;
            }
            else if (rawDisplayData != null && rawDisplayData.type == DisplayType.BoundingBox)
            {
                this._boundingBoxData = (rawDisplayData as BoundingBoxDisplayData).boundingBox;
            }
            else
            {
                this._boundingBoxData = null;
            }

            if (this._displayData != prevDisplayData || this._textureData != prevTextureData || this._meshData != prevMeshData)
            {
                // Update pivot offset.
                if (this._meshData != null)
                {
                    this._pivotX = 0.0f;
                    this._pivotY = 0.0f;
                }
                else if (this._textureData != null)
                {
                    var imageDisplayData = this._displayData as ImageDisplayData;
                    var scale            = this._textureData.parent.scale * this._armature._armatureData.scale;
                    var frame            = this._textureData.frame;

                    this._pivotX = imageDisplayData.pivot.x;
                    this._pivotY = imageDisplayData.pivot.y;

                    var rect   = frame != null ? frame : this._textureData.region;
                    var width  = rect.width;
                    var height = rect.height;

                    if (this._textureData.rotated && frame == null)
                    {
                        width  = rect.height;
                        height = rect.width;
                    }

                    this._pivotX *= width * scale;
                    this._pivotY *= height * scale;

                    if (frame != null)
                    {
                        this._pivotX += frame.x * scale;
                        this._pivotY += frame.y * scale;
                    }
                }
                else
                {
                    this._pivotX = 0.0f;
                    this._pivotY = 0.0f;
                }

                // Update mesh bones and ffd vertices.
                if (this._meshData != prevMeshData)
                {
                    if (this._meshData != null)// && this._meshData === this._displayData
                    {
                        if (this._meshData.weight != null)
                        {
                            this._ffdVertices.ResizeList(this._meshData.weight.count * 2);
                            this._meshBones.ResizeList(this._meshData.weight.bones.Count);

                            for (int i = 0, l = this._meshBones.Count; i < l; ++i)
                            {
                                this._meshBones[i] = this._armature.GetBone(this._meshData.weight.bones[i].name);
                            }
                        }
                        else
                        {
                            var vertexCount = this._meshData.parent.parent.parent.intArray[this._meshData.offset + (int)BinaryOffset.MeshVertexCount];
                            this._ffdVertices.ResizeList(vertexCount * 2);
                            this._meshBones.Clear();
                        }

                        for (int i = 0, l = this._ffdVertices.Count; i < l; ++i)
                        {
                            this._ffdVertices[i] = 0.0f;
                        }

                        this._meshDirty = true;
                    }
                    else
                    {
                        this._ffdVertices.Clear();
                        this._meshBones.Clear();
                    }
                }
                else if (this._meshData != null && this._textureData != prevTextureData)
                {
                    // Update mesh after update frame.
                    this._meshDirty = true;
                }

                if (this._displayData != null && rawDisplayData != null && this._displayData != rawDisplayData && this._meshData == null)
                {
                    rawDisplayData.transform.ToMatrix(Slot._helpMatrix);
                    Slot._helpMatrix.Invert();
                    Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                    this._pivotX -= Slot._helpPoint.x;
                    this._pivotY -= Slot._helpPoint.y;

                    this._displayData.transform.ToMatrix(Slot._helpMatrix);
                    Slot._helpMatrix.Invert();
                    Slot._helpMatrix.TransformPoint(0.0f, 0.0f, Slot._helpPoint);
                    this._pivotX += Slot._helpPoint.x;
                    this._pivotY += Slot._helpPoint.y;
                }

                // Update original transform.
                if (rawDisplayData != null)
                {
                    this.origin = rawDisplayData.transform;
                }
                else if (this._displayData != null)
                {
                    this.origin = this._displayData.transform;
                }

                this._displayDirty             = true;
                this._transformDirty           = true;
                this._skinedMeshTransformDirty = true;
            }
        }