Esempio n. 1
0
 private static void RecursiveCreate(Armature armature, BodyCollisionTree tree, string prefix, List<BodyCollider> result)
 {
     foreach (ColliderTemplate collider in armature.Colliders)
         collider.InsertCollider(tree.GetNode(prefix + armature.Name), result);
     foreach (Armature child in armature.Children)
         RecursiveCreate(child, tree, prefix, result);
 }
Esempio n. 2
0
        /**
         * Creates a new Animation instance and attaches it to the passed Armature.
         * @param	An Armature to attach this Animation instance to.
         */
        public Animation(Armature armature)
        {
            _armature = armature;
            _animationLayer = new List<List<AnimationState>>();
            _animationList = new List<string>();

            _isPlaying = false;
            _isActive = false;
            TweenEnabled = true;
        }
 protected override void _OnClear()
 {
     this.time           = 0.0f;
     this.type           = string.Empty;
     this.name           = string.Empty;
     this.armature       = null;
     this.bone           = null;
     this.slot           = null;
     this.animationState = null;
     this.data           = null;
 }
 /**
  * Cleans up any resources used by this DBObject instance.
  */
 public virtual void Dispose()
 {
     UserData = null;
     _parent = null;
     _armature = null;
     _global = null;
     _origin = null;
     _offset = null;
     _tween = null;
     _globalTransformMatrix = null;
 }
Esempio n. 5
0
 /**
  * @private
  */
 protected override void _onClear()
 {
     type           = null;
     name           = null;
     frame          = null;
     data           = null;
     armature       = null;
     bone           = null;
     slot           = null;
     animationState = null;
 }
        /// <private/>
        protected override void _OnClear()
        {
            this.globalTransformMatrix.Identity();
            this.global.Identity();
            this.offset.Identity();
            this.origin   = null; //
            this.userData = null;

            this._globalDirty = false;
            this._armature    = null; //
        }
        public ActionResult Edit(int productID = 0)
        {
            Armature armature = new Armature()
            {
                id = productID, Label = "Asus4510", ArmatureName = "Laminated Armature"
            };

            //use Base class's GetParameters method
            armature.GetParameters();
            armature.FillTheSelectLists();
            return(View(armature));
        }
 /** @private */
 public virtual void setArmature(Armature value)
 {
     if(_armature!=null)
     {
         _armature.removeDBObject(this);
     }
     _armature = value;
     if(_armature!=null)
     {
         _armature.addDBObject(this);
     }
 }
Esempio n. 9
0
            private Armature(XElement element, BodyCollisionTree tree)
            {
                Name = element.Attribute("name").Value;
                var collidersEnumerator = element.Elements("Collider");
                Colliders = new ColliderTemplate[collidersEnumerator.Count()];
                int i = 0;
                foreach (XElement colliderElement in collidersEnumerator)
                    Colliders[i++] = CreateColliderTemplate(colliderElement);

                var childEnumerator = element.Elements("Armature");
                Children = new Armature[childEnumerator.Count()];
                i = 0;
                foreach (XElement childElement in childEnumerator)
                    Children[i++] = new Armature(childElement, tree);
            }
Esempio n. 10
0
        private void _switchWeaponLeft()
        {
            _weaponLeftIndex++;
            if (_weaponLeftIndex >= WEAPON_LEFT_LIST.Length)
            {
                _weaponLeftIndex = 0;
            }

            _weaponLeft.eventDispatcher.RemoveDBEventListener(DragonBones.EventObject.FRAME_EVENT, _frameEventHandler);

            var weaponName = WEAPON_LEFT_LIST[_weaponLeftIndex];

            _weaponLeft = UnityFactory.factory.BuildArmature(weaponName);
            _armatureComponent.armature.GetSlot("weapon_l").childArmature = _weaponLeft;
            _weaponLeft.eventDispatcher.AddDBEventListener(DragonBones.EventObject.FRAME_EVENT, _frameEventHandler);
        }
Esempio n. 11
0
        private void _switchWeaponRight()
        {
            _weaponRightIndex++;
            if (_weaponRightIndex >= WEAPON_RIGHT_LIST.Length)
            {
                _weaponRightIndex = 0;
            }

            _weaponRight.eventDispatcher.RemoveEventListener(EventObject.FRAME_EVENT, _frameEventHandler);

            var weaponName = WEAPON_RIGHT_LIST[_weaponRightIndex];

            _weaponRight = UnityFactory.factory.BuildArmature(weaponName);
            _armatureComponent.armature.GetSlot("weapon_r").childArmature = _weaponRight;
            _weaponRight.eventDispatcher.AddEventListener(EventObject.FRAME_EVENT, _frameEventHandler);
        }
Esempio n. 12
0
    /// <summary>
    /// Check if two armatures are exact copies, with respect to all bone names.
    /// </summary>
    /// <param name="a1">Armature 1</param>
    /// <param name="a2">Armature 2</param>
    /// <returns></returns>
    private bool ArmatureExactMatch(Armature a1, Armature a2)
    {
        foreach (string boneKey in a1._bonesByName.Keys)
        {
            if (!a2._bonesByName.ContainsKey(boneKey))
            {
                return(false);
            }
        }

        foreach (string boneKey in a2._bonesByName.Keys)
        {
            if (!a1._bonesByName.ContainsKey(boneKey))
            {
                return(false);
            }
        }

        return(true);
    }
Esempio n. 13
0
        void Start()
        {
            _armatureComponent = this.gameObject.GetComponent <UnityArmatureComponent>();
            _armatureComponent.AddEventListener(EventObject.FADE_IN_COMPLETE, _animationEventHandler);
            _armatureComponent.AddEventListener(EventObject.FADE_OUT_COMPLETE, _animationEventHandler);

            // Effects only controled by normalAnimation.
            _armatureComponent.armature.GetSlot("effects_1").displayController = NORMAL_ANIMATION_GROUP;
            _armatureComponent.armature.GetSlot("effects_2").displayController = NORMAL_ANIMATION_GROUP;

            // Get weapon childArmature.
            _weaponLeft  = _armatureComponent.armature.GetSlot("weapon_l").childArmature;
            _weaponRight = _armatureComponent.armature.GetSlot("weapon_r").childArmature;
            _weaponLeft.eventDispatcher.AddEventListener(EventObject.FRAME_EVENT, _frameEventHandler);
            _weaponRight.eventDispatcher.AddEventListener(EventObject.FRAME_EVENT, _frameEventHandler);

            _armatureComponent.animation.Reset();

            _updateAnimation();
        }
Esempio n. 14
0
        protected override void _FoldBones(BuildArmaturePackage dataPackage, Armature armature)
        {
            var armatureDisplay = armature.display as Node2D;

            if (armatureDisplay == null)
            {
                return;
            }
            List <Node> childrenArmatureDisplay = armatureDisplay.GetChildren().OfType <Node>().ToList();

            foreach (var slot in armature.GetSlots()) // slots
            {
                var boneParentName = slot.parent?.name;
                if (boneParentName == null)
                {
                    continue;
                }

                var parentNode = childrenArmatureDisplay.Find(node => node.Name == boneParentName);
                var godotSlot  = slot as GodotSlot;
                var slotNode   = godotSlot?.GetSlotNode();
                armatureDisplay.RemoveChild(slotNode);
                parentNode.AddChild(slotNode);
            }

            foreach (var bone in dataPackage.armature.bones) // bones
            {
                var boneData = bone.Value;
                var(boneName, boneParentName) = (bone.Key, boneData.parent?.name);
                var isRoot = boneParentName == null;

                if (isRoot)
                {
                    continue;
                }
                var parentNode = childrenArmatureDisplay.Find(node => node.Name == boneParentName);
                var boneNode   = childrenArmatureDisplay.Find(node => node.Name == boneName);
                armatureDisplay.RemoveChild(boneNode);
                parentNode.AddChild(boneNode);
            }
        }
        public ActionResult Edit(Armature armature)
        {
            if (ModelState.IsValid)
            {
                //Access and save product info
                //armature.id;
                //armature.armatureName
                //..

                //Refill the select list of the parameters (thanks to selectListCSV property of the parameter returned from the view) again
                armature.FillTheSelectLists();
                //use Base class's CheckAndUpdateParameters method
                ViewBag.message = armature.CheckAndUpdateParameters(ModelState);
                return(View(armature));
            }
            else
            {
                //to see modal state errors
                //IEnumerable<ModelError> allErrors = ModelState.Values.SelectMany(v => v.Errors);
            }
            return(View(armature));
        }
        private void clearVaribles()
        {
            _armature         = null;
            _currentFrame     = null;
            _clip             = null;
            _mixingTransforms = null;

            String[] keys = new string[_timelineStates.Count];
            int      i    = 0;

            foreach (KeyValuePair <string, TimelineState> timelineState in _timelineStates)
            {
                keys[i] = timelineState.Key;
                i++;
                //removeTimelineState(timelineState.Key);
            }

            for (int j = 0; j < keys.Length; j++)
            {
                removeTimelineState(keys[j]);
            }
        }
Esempio n. 17
0
        internal Pose GetIkLessPose(VpdPose vpdPose)
        {
            var ikPose           = vpdPose.GetIkPose(this);
            var normalPose       = new Pose(ikPose.NormalPose);
            var restArmature     = GetRestArmature();
            var morphed_armature = new Armature(restArmature);

            restArmature.Morph(morphed_armature, normalPose);

            var ikArmaturesAndOtherInfo = new List <Tuple <int, string, IKArmature, string, string> >();

            for (int i = 0; i < ikChains.Count; i++)
            {
                var ik_chain          = ikChains[i];
                var v                 = GetIkChainIkArmature(i);
                var ik_armature       = v.Item1;
                var root_name         = v.Item2;
                var end_effector_name = v.Item3;
                ikArmaturesAndOtherInfo.Add(Tuple.Create(i, bones[ik_chain.IkBoneIndex].Name, ik_armature, root_name, end_effector_name));
            }
            ikArmaturesAndOtherInfo = TopologicallySortIkArmatures(ikArmaturesAndOtherInfo);

            foreach (var data_quadruple in ikArmaturesAndOtherInfo)
            {
                var ik_chain_index    = data_quadruple.Item1;
                var ik_bone_name      = data_quadruple.Item2;
                var ik_armature       = data_quadruple.Item3;
                var root_name         = data_quadruple.Item4;
                var end_effector_name = data_quadruple.Item5;
                ComputeIkChainIk(normalPose,
                                 restArmature, morphed_armature,
                                 vpdPose,
                                 ik_bone_name, ik_armature,
                                 root_name, end_effector_name);
            }
            return(normalPose);
        }
Esempio n. 18
0
        private void defineFields()
        {
            // определение наличия торцов
            defineEnds();

            ApertureWidth       = Block.GetPropValue <int>(PropNameApertureWidth);
            ApertureHeight      = Block.GetPropValue <int>(PropNameApertureHeight);
            ApertureHeightUnder = Block.GetPropValue <int>(PropNameApertureHeightAbove, isRequired: false);
            Height    = Block.GetPropValue <int>(PropNameHeight);
            Thickness = Block.GetPropValue <int>(PropNameThickness);
            Outline   = Block.GetPropValue <int>(PropNameOutline);

            // Бетон
            defineConcrete();

            // Определние вертикальной арматуры усиления
            defineAddVerticArm();

            // Определние горизонтальной арматуры усиления
            defineAddHorArm();

            // Определение стержней над проемом - Скоба, Хомут, Гор погонная, Вертик погонная если надо
            defineAbove();
            defineUnder();

            // Скобы
            defineSideBrackets();

            // Диагональные стержни
            int    diamDiag       = 10;
            int    lapLenDiagonal = Armature.GetLapLength(diamDiag, Concrete);
            string posDiag        = Block.GetPropValue <string>(PropNameArmDiagonalPos);
            int    countDiagArm   = 4 + (hasBottomArm ? 4 : 0);

            BarDiagonal = new Bar(diamDiag, lapLenDiagonal * 2, countDiagArm, posDiag, this, "Диагональные стержни проема");
            BarDiagonal.Calc();
        }
Esempio n. 19
0
		/** @private */
		public virtual void setArmature(Armature value)
		{
			if(_armature!=null)
			{
				_armature.removeDBObject(this);
			}
			_armature = value;
			if(_armature!=null)
			{
				_armature.addDBObject(this);
			}
		}
Esempio n. 20
0
 /// <summary>
 /// Attach a slot to this bone.
 /// </summary>
 public void AddSlot(DbSlot slot)
 {
     Slots.Add(slot);
     Armature.AddSlot(slot);
 }
Esempio n. 21
0
 /// <summary>
 /// Add the given bone to this bone as its child.
 /// Also adds the bone to this bones armature for fast lookups.
 /// </summary>
 public void AddBone(DbBone bone)
 {
     Bones.Add(bone);
     Armature.AddBone(bone);
 }
        /**
         * Build and returns a new Armature instance.
         * @example
         * <listing>
         * var armature:Armature = factory.buildArmature('dragon');
         * </listing>
         * @param	armatureName The name of this Armature instance.
         * @param	The name of this animation.
         * @param	The name of this SkeletonData.
         * @param	The name of this textureAtlas.
         * @param	The name of this skin.
         * @return A Armature instance.
         */
        public Armature BuildArmature(string armatureName, string animationName = null, string skeletonName = null, string textureAtlasName = null, string skinName = null)
        {
            SkeletonData data                  = null;
            ArmatureData armatureData          = null;
            ArmatureData animationArmatureData = null;

            if (skeletonName != null)
            {
                data = _dataDic[skeletonName];
                if (data != null)
                {
                    armatureData = data.GetArmatureData(armatureName);
                }
            }
            else
            {
                foreach (KeyValuePair <string, SkeletonData> skeleton in _dataDic)
                {
                    data         = _dataDic[skeleton.Key];
                    armatureData = data.GetArmatureData(armatureName);
                    if (armatureData != null)
                    {
                        break;
                    }
                }
            }

            if (armatureData == null)
            {
                return(null);
            }

            _currentDataName = skeletonName;

            if (textureAtlasName != null)
            {
                _currentTextureAtlasName = textureAtlasName;
            }
            else
            {
                _currentTextureAtlasName = skeletonName;
            }

            Armature armature = generateArmature();

            armature.Name = armatureName;
            Bone bone;

            foreach (BoneData boneData in armatureData.BoneDataList)
            {
                bone               = new Bone();
                bone.Name          = boneData.Name;
                bone.FixedRotation = boneData.FixedRotation;
                bone.ScaleMode     = boneData.ScaleMode;
                bone.Origin.Copy(boneData.Transform);

                if (armatureData.GetBoneData(boneData.Parent) != null)
                {
                    armature.AddBone(bone, boneData.Parent);
                }
                else
                {
                    armature.AddBone(bone);
                }
            }

            if (animationName != null && animationName != armatureName)
            {
                animationArmatureData = data.GetArmatureData(animationName);
                if (animationArmatureData == null)
                {
                    foreach (KeyValuePair <string, SkeletonData> skeleton in _dataDic)
                    {
                        data = _dataDic[skeleton.Key];
                        animationArmatureData = data.GetArmatureData(animationName);
                        if (animationArmatureData != null)
                        {
                            break;
                        }
                    }
                }
            }

            if (animationArmatureData != null)
            {
                armature.Animation.AnimationDataList = animationArmatureData.AnimationDataList;
            }
            else
            {
                armature.Animation.AnimationDataList = armatureData.AnimationDataList;
            }

            SkinData skinData = armatureData.GetSkinData(skinName);

            if (skinData == null)
            {
                throw new ArgumentException();
            }

            Slot          slot;
            DisplayData   displayData;
            Armature      childArmature;
            int           i;
            List <object> helpArray = new List <object>();

            foreach (SlotData slotData in skinData.SlotDataList)
            {
                bone = armature.GetBone(slotData.Parent);
                if (bone == null)
                {
                    continue;
                }
                slot                 = generateSlot();
                slot.Name            = slotData.Name;
                slot.BlendMode       = slotData.BlendMode;
                slot._originZOrder   = slotData.ZOrder;
                slot._dislayDataList = slotData.DisplayDataList;

                helpArray.Clear();
                i = slotData.DisplayDataList.Count;
                while (i-- > 0)
                {
                    displayData = slotData.DisplayDataList[i];

                    switch (displayData.Type)
                    {
                    case DisplayData.ARMATURE:
                        childArmature = BuildArmature(displayData.Name, null, _currentDataName, _currentTextureAtlasName);
                        if (childArmature != null)
                        {
                            helpArray.Insert(0, childArmature);
                        }
                        break;

                    case DisplayData.IMAGE:
                    default:
                        helpArray.Insert(0, generateDisplay(_textureAtlasDic[_currentTextureAtlasName], displayData.Name, displayData.Pivot.X, displayData.Pivot.Y));
                        break;
                    }
                }
                slot.DisplayList = helpArray;
                slot.changeDisplay(0);
                bone.AddChild(slot);
            }

            //
            i = armature._boneList.Count;
            while (i-- > 0)
            {
                armature._boneList[i].update();
            }

            i = armature._slotList.Count;
            while (i-- > 0)
            {
                slot = armature._slotList[i];
                slot.update();
            }
            armature.UpdateSlotsZOrder();

            return(armature);
        }
Esempio n. 23
0
 public void DBClear()
 {
     armature = null;
 }
		/** @private */
		public void fadeIn(Armature armature, AnimationData clip, float fadeInTime, float timeScale, int loop, uint layer, bool displayControl, bool pauseBeforeFadeInComplete)
		{

			_armature = armature;
			_clip = clip;
			_name = _clip.Name;
			_layer = layer;
			
			_totalTime = _clip.Duration;
			if(Math.Round(_clip.Duration * _clip.FrameRate) < 2 || timeScale == float.PositiveInfinity)
			{
				_timeScale = 1;
				_currentTime = _totalTime;
				if(_loop >= 0)
				{
					_loop = 1;
				}
				else
				{
					_loop = -1;
				}
			}
			else
			{
				_timeScale = timeScale;
				_currentTime = 0;
				_loop = loop;
			}
			
			if(pauseBeforeFadeInComplete)
			{
				_pauseBeforeFadeInCompleteState = -1;
			}
			else
			{
				_pauseBeforeFadeInCompleteState = 1;
			}
			
			_fadeInTime = fadeInTime * _timeScale;
			
			
			_loopCount = -1;
			_fadeState = 1;
			_fadeOutBeginTime = 0;
			_fadeOutWeight = -1;
			_fadeWeight = 0;
			_isPlaying = true;
			_isComplete = false;
			_fadeIn = true;
			_fadeOut = false;
			
			this.DisplayControl = displayControl;
			
			Weight = 1;
			Blend = true;
			TweenEnabled = true;
			
			updateTimelineStates();

		}
Esempio n. 25
0
        public Armature GetRestArmature()
        {
            var armature  = new Armature();
            var necessary = Enumerable.Repeat(false, bones.Count).ToArray();

            foreach (var ikChain in ikChains)
            {
                foreach (var index in ikChain.AffectedBoneIndices)
                {
                    necessary[index] = true;
                }
                necessary[ikChain.EndEffectorIndex] = true;
            }

            foreach (var vertex in vertices)
            {
                necessary[vertex.Bone0Number] = true;
                necessary[vertex.Bone1Number] = true;
            }

            for (int boneIndex = 0; boneIndex < bones.Count; boneIndex++)
            {
                var bone = bones[boneIndex];

                if (necessary[boneIndex] ||
                    (new int[] {
                    Bone.BONE_ROTATE,
                    Bone.BONE_ROTATE_TRANSLATE,
                    Bone.BONE_IK_ROTATION_INFLUENCED,
                    Bone.BONE_IK_TARGET,
                    Bone.BONE_ROTATION_INFLUENCED
                }.Contains(bone.BoneType)))
                {
                    var current = boneIndex;
                    while (current >= 0)
                    {
                        necessary[current] = true;
                        current            = bones[current].ParentIndex;
                    }
                }
            }

            for (int boneIndex = 0; boneIndex < bones.Count; boneIndex++)
            {
                var bone = bones[boneIndex];
                if (necessary[boneIndex])
                {
                    Vector3D position;
                    if (bone.ParentIndex >= 0)
                    {
                        var parent = bones[bone.ParentIndex];
                        position = bone.Position - parent.Position;
                        position = new Vector3D(position.X, position.Y, -position.Z);
                    }
                    else
                    {
                        position = new Vector3D(bone.Position.X, bone.Position.Y, -bone.Position.Z);
                    }
                    var joint = new Joint(bone.Name, position, Quaternion.Identity);
                    armature.AppendJoint(joint);
                }
            }

            for (int boneIndex = 0; boneIndex < bones.Count; boneIndex++)
            {
                var   bone = bones[boneIndex];
                Joint joint;
                try
                {
                    joint = armature.GetJoint(bone.Name);
                }
                catch (ValueException)
                {
                    continue;
                }
                if (bone.ParentIndex >= 0)
                {
                    armature.SetParent(joint.Name, bones[bone.ParentIndex].Name);
                }
            }

            return(armature);
        }
Esempio n. 26
0
		/** @private */
		override public void setArmature(Armature value)
		{
			base.setArmature(value);
			if(this._armature!=null)
			{
				this._armature._slotsZOrderChanged = true;
				_displayBridge.AddDisplay(this._armature.Display, this.ZOrder);
			}
			else
			{
				_displayBridge.RemoveDisplay();
			}
		}
Esempio n. 27
0
		/** @private */
		override public void setArmature(Armature value)
		{
			base.setArmature(value);
			int i = _children.Count;
			while(i -- >0)
			{
				_children[i].setArmature(this._armature);
			}
		}
Esempio n. 28
0
		/** @private */
		override protected Armature generateArmature()
		{
			UnityArmatureDisplay unityArmatureDisplay = new UnityArmatureDisplay (_textureAtlasDic[_currentTextureAtlasName]);
			Armature armature = new Armature(unityArmatureDisplay);
			return armature;
		}
Esempio n. 29
0
        private Tuple <IKArmature, string, string> GetIkChainIkArmature(int ik_chain_index)
        {
            var ik_chain      = ikChains[ik_chain_index];
            var rest_armature = new Armature();

            var joint_indices = ik_chain.AffectedBoneIndices.ToList();

            joint_indices.Add(ik_chain.EndEffectorIndex);

            foreach (var joint_index in joint_indices)
            {
                rest_armature.AppendJoint(new Joint(bones[joint_index].Name));
            }
            string root_name = null;

            foreach (var joint_index in joint_indices)
            {
                var bone = bones[joint_index];
                if (joint_indices.Contains(bone.ParentIndex))
                {
                    var child_name   = bones[joint_index].Name;
                    var parent_index = bones[joint_index].ParentIndex;
                    var parent_name  = bones[parent_index].Name;
                    rest_armature.SetParent(child_name, parent_name);
                    var joint = rest_armature.GetJoint(child_name);
                    var m     = Matrix3D.Identity;
                    m.Scale(new Vector3D(1, 1, -1));
                    var position = m.Transform(bones[joint_index].Position - bones[parent_index].Position);
                    joint.Position = position;
                }
                else
                {
                    root_name = bone.Name;
                }
            }

            var ik_bone_name      = bones[ik_chain.IkBoneIndex].Name;
            var ik_armature       = new IKArmature(rest_armature);
            var end_effector_name = bones[ik_chain.EndEffectorIndex].Name;

            ik_armature.MakeEndEffector(end_effector_name);
            foreach (var joint_index in ik_chain.AffectedBoneIndices)
            {
                var bone     = bones[joint_index];
                var ik_joint = ik_armature.MakeIkJoint(bone.Name);
                ik_armature.AddIkJointToEndEffector(bone.Name, end_effector_name);
                ik_joint.DisableParameter(IKJointParameters.XTranslate);
                ik_joint.DisableParameter(IKJointParameters.YTranslate);
                ik_joint.DisableParameter(IKJointParameters.ZTranslate);
            }

            if (new[] { "leg_ik.R", "leg_ik.L" }.Contains(ik_bone_name))
            {
                IKJoint knee_joint;
                IKJoint leg_joint;

                if (ik_bone_name == "leg_ik.R")
                {
                    knee_joint = ik_armature.GetIkJoint("knee.R");
                    leg_joint  = ik_armature.GetIkJoint("leg.R");
                }
                else
                {
                    leg_joint  = ik_armature.GetIkJoint("leg.L");
                    knee_joint = ik_armature.GetIkJoint("knee.L");
                }

                knee_joint.DisableParameter(IKJointParameters.YRotate);
                knee_joint.DisableParameter(IKJointParameters.ZRotate);
                knee_joint.SetLimit(IKJointParameters.XRotate, 0, 180);

                leg_joint.DisableParameter(IKJointParameters.YRotate);
                leg_joint.DisableParameter(IKJointParameters.ZRotate);
            }

            return(Tuple.Create(ik_armature, root_name, end_effector_name));
        }
Esempio n. 30
0
        private void defineUnder()
        {
            // Определение арматуры снизу проема
            if (ApertureHeightUnder < 200)
            {
                return;
            }
            hasBottomArm = true;

            int diamVerticArm = Block.GetPropValue <int>(PropNameArmVerticDiam);
            int stepVerticArm = Block.GetPropValue <int>(PropNameArmVerticStep);
            // Длина нахлести вертик арм (для скобы)
            int lapLengthVerticArm = Armature.GetLapLength(diamVerticArm, Concrete);
            int widthRun           = ApertureWidth - 100;

            if (widthRun <= 0)
            {
                return;
            }

            int lengthVerticArm = ApertureHeightUnder - 20;
            int bracketLen      = lapLengthVerticArm;

            // Если высота подоконника больше двух длин нахлеста, то добавляется вертикальная погонная арматура
            if (ApertureHeightUnder > lapLengthVerticArm * 2)
            {
                // Добавление вертик погонной арм - без коэф нахлести погонной арм!!!
                string posArmVertic        = Block.GetPropValue <string>(PropNameArmVerticPos);
                var    barRunArmVerticTemp = new BarRunning(diamVerticArm, lengthVerticArm, widthRun, stepVerticArm, 2, posArmVertic, this, "Вертикальная погонная арматура");
                barRunArmVerticTemp.Calc();
                if (ArmVertic == null)
                {
                    ArmVertic = barRunArmVerticTemp;
                }
                else
                {
                    // Добавить метры к существующей верхней вертик погонной арм
                    var barRunArmVertic = (BarRunning)ArmVertic;
                    barRunArmVertic.Meters += barRunArmVerticTemp.Meters;
                    barRunArmVertic.Calc();
                }
            }
            else
            {
                // Скоба на всю высоту выпуска вертик стержней (без погонной арматуры)
                bracketLen = lengthVerticArm;
            }
            // Скоба нижняя
            int    tBracket   = Thickness - 2 * a - diamVerticArm;
            string posBracket = Block.GetPropValue <string>(PropNameBracketBottomPos);

            BracketBottom = new Bracket(diamVerticArm, bracketLen, tBracket, stepVerticArm, widthRun, 1, posBracket,
                                        this, "Скоба нижняя");
            BracketBottom.Calc();

            // Хомут
            int    stepShackle = Block.GetPropValue <int>(PropNameShackleStep);
            int    diamShackle = Block.GetPropValue <int>(PropNameShackleDiam);
            int    wShackle    = Thickness - 2 * a + diamVerticArm + AddArmHor.Diameter * 2;
            int    hShackle    = (addArmHorBottomCount == 4 ? 100 : 200) + AddArmHor.Diameter;
            string posShackle  = Block.GetPropValue <string>(PropNameShackleBottomPos);

            ShackleBottom = new Shackle(diamShackle, wShackle, hShackle, stepShackle, widthRun, 1, posShackle, this);
            ShackleBottom.Calc();

            // Горизонтальная погонная арм - Фоновая
            int stepHorArm  = Block.GetPropValue <int>(PropNameArmHorStep);
            int widthHorArm = ApertureHeightUnder - a - (addArmHorBottomCount == 4 ? 100 : 200) - stepHorArm - 50;

            if (widthHorArm > 0)
            {
                var armHorTemp = defineBarRunStep(ApertureWidth, widthHorArm, 2, PropNameArmHorDiam, PropNameArmHorPos,
                                                  PropNameArmHorStep, Concrete, "Горизонтальная фоновая арматура");
                armHorTemp.Calc();
                if (ArmHor == null)
                {
                    ArmHor = armHorTemp;
                }
                else
                {
                    ArmHor.Meters += armHorTemp.Meters;
                    ArmHor.Count  += armHorTemp.Count;
                    ArmHor.Width  += armHorTemp.Width;
                    ArmHor.Calc();
                }
            }
        }
Esempio n. 31
0
		/**
		 * Cleans up any resources used by this DBObject instance.
		 */
		public virtual void Dispose()
		{
			UserData = null;
			_parent = null;
			_armature = null;
			_global = null;
			_origin = null;
			_offset = null;
			_tween = null;
			_globalTransformMatrix = null;
		}
		private void clearVaribles()
		{
			_armature = null;
			_currentFrame = null;
			_clip = null;
			_mixingTransforms = null;

			String[] keys = new string[_timelineStates.Count];
			int i = 0;
			
			foreach(KeyValuePair<string, TimelineState> timelineState in _timelineStates)
			{
				keys[i] = timelineState.Key;
				i++;
				//removeTimelineState(timelineState.Key);
			}

			for(int j=0;j<keys.Length;j++)
			{
				removeTimelineState(keys[j]);
			}
		}
 private void Start()
 {
     armature = unityArmature.armature;
     unityArmature.armature.clock.Remove(unityArmature.armature);
 }
Esempio n. 34
0
        /// <internal/>
        /// <private/>
        /// <summary>
        /// - The armature that dispatch the event.
        /// </summary>
        /// <see cref="DragonBones.Armature"/>
        /// <version>DragonBones 4.5</version>
        /// <language>en_US</language>

        /// <summary>
        /// - 发出该事件的骨架。
        /// </summary>
        /// <see cref="DragonBones.Armature"/>
        /// <version>DragonBones 4.5</version>
        /// <language>zh_CN</language>
        /// <summary>
        /// - The custom data.
        /// </summary>
        /// <see cref="DragonBones.CustomData"/>
        /// <private/>
        /// <version>DragonBones 5.0</version>
        /// <language>en_US</language>

        /// <summary>
        /// - 自定义数据。
        /// </summary>
        /// <see cref="DragonBones.CustomData"/>
        /// <private/>
        /// <version>DragonBones 5.0</version>
        /// <language>zh_CN</language>
        public static void ActionDataToInstance(ActionData data, EventObject instance, Armature armature)
        {
            if (data.type == ActionType.Play)
            {
                instance.type = EventObject.FRAME_EVENT;
            }
            else
            {
                instance.type = data.type == ActionType.Frame ? EventObject.FRAME_EVENT : EventObject.SOUND_EVENT;
            }

            instance.name       = data.name;
            instance.armature   = armature;
            instance.actionData = data;
            instance.data       = data.data;

            if (data.bone != null)
            {
                instance.bone = armature.GetBone(data.bone.name);
            }

            if (data.slot != null)
            {
                instance.slot = armature.GetSlot(data.slot.name);
            }
        }
Esempio n. 35
0
        private void ComputeIkChainIk(Pose target_pose, Armature rest_armature, Armature morphed_armature, VpdPose vpd_pose, string ik_bone_name, IKArmature ik_armature, string root_name, string end_effector_name)
        {
            var root_bone        = bonesByName[root_name];
            var root_position    = morphed_armature.GetJointWorldPosition(root_bone.Name);
            var root_orientation = morphed_armature.GetJointWorldOrientation(root_bone.Name);

            var end_effector_bone     = bonesByName[end_effector_name];
            var end_effector_position = morphed_armature.GetJointWorldPosition(end_effector_name);

            var ik_bone          = bonesByName[ik_bone_name];
            var goal_position    = GetMorphedWorldPosition(ik_bone.Index, vpd_pose);
            var goal_orientation = GetMorphedWorldOrientation(ik_bone.Index, vpd_pose);

            if (new[] { "leg_ik.R", "leg_ik.L", "tiptoe_ik.R", "tiptoe_ik.L" }.Contains(ik_bone_name))
            {
                // calculate the rotation need to rotate the vector
                // (end_effector - root) to (goal - root)
                var root_to_end_effector        = end_effector_position - root_position;
                var root_to_end_effector_length = root_to_end_effector.Length;
                var root_to_goal        = goal_position - root_position;
                var root_to_goal_length = root_to_goal.Length;
                var dot_prod            = Vector3D.DotProduct(root_to_end_effector, root_to_goal);

                if (root_to_end_effector_length > 0.00001)
                {
                    dot_prod /= root_to_end_effector_length;
                }
                if (root_to_goal_length > 0.00001)
                {
                    dot_prod /= root_to_goal_length;
                }

                if (Math.Abs(dot_prod - 1) > 0.0001)
                {
                    var cos_theta = dot_prod;
                    var theta     = Math.Acos(cos_theta);
                    var axis      = Vector3D.CrossProduct(root_to_end_effector, root_to_goal);
                    axis.Normalize();

                    var rotation = new Quaternion(axis, theta * 180 / Math.PI);

                    root_orientation = rotation * root_orientation;
                }
            }
            var chain_rest_armature = ik_armature.GetRestArmature();

            chain_rest_armature.SetJointParameter(root_name,
                                                  (Vector3D)root_position,
                                                  root_orientation);

            // create a pose with joint changes
            // derived from the VPD pose.
            var chain_normal_pose = new Pose();

            foreach (var ik_joint in ik_armature.GetIkJoints())
            {
                var ik_joint_name = ik_joint.Name;
                chain_normal_pose.SetJointChange(
                    ik_joint_name,
                    target_pose.GetJointChange(ik_joint_name));
            }
            chain_normal_pose.SetJointChange(root_name, new JointChange());

            var chain_ik_pose = new IKPose();

            chain_ik_pose.SetNormalPose(chain_normal_pose);
            chain_ik_pose.EndEffectorGoals.SetEndEffectorPosition(end_effector_name, goal_position);

            var result_pose = new Pose();

            ik_armature.SolveForPose(result_pose, chain_ik_pose, 30, 0.0001);

            foreach (var ik_joint in ik_armature.GetIkJoints())
            {
                var joint_change = result_pose.GetJointChange(ik_joint.Name);
                target_pose.SetJointChange(ik_joint.Name, joint_change);
            }

            if (new[] { "leg_ik.R", "leg_ik.L", "tiptoe_ik.R", "tiptoe_ik.L" }.Contains(ik_bone_name))
            {
                // Fix the root joint change so that it is given
                // with respect to its parent.
                var root_parent_orientation = morphed_armature.GetJointWorldOrientation(bones[bonesByName[root_name].ParentIndex].Name);
                root_parent_orientation.Invert();
                var fixed_root_orientation = root_parent_orientation * root_orientation * result_pose.GetJointChange(root_name).Orientation;
                target_pose.SetJointChange(root_name,
                                           new JointChange(new Vector3D(0, 0, 0), fixed_root_orientation));
            }

            rest_armature.Morph(morphed_armature, target_pose);
        }
Esempio n. 36
0
        protected override Slot _BuildSlot(BuildArmaturePackage dataPackage, SlotData slotData, Armature armature)
        {
            var slot            = BaseObject.BorrowObject <GodotSlot>();
            var armatureDisplay = armature.display as Node2D;

            if (armatureDisplay == null)
            {
                return(null);
            }

            var boneNode = CreateBoneNode(slotData);

            armatureDisplay.AddChild(boneNode);

            var slotNode = armatureDisplay.FindNode(slotData.name) as Sprite;

            if (slotNode == null)
            {
                slotNode = Helper.CreateSlotNodeWithName(slotData.name);
            }
            armatureDisplay.AddChild(slotNode);

            var atlasName = dataPackage.textureAtlasName ?? dataPackage.dataName;
            var atlasData = GetTextureAtlasData(atlasName).First() as GodotTextureAtlasData; // get first elem

            slot.SetCurrentTextureAtlasData(ref atlasData);
            slot.SetBoneNode(boneNode);
            slot.Init(slotData, armature, slotNode, slotNode);

            return(slot);
        }
Esempio n. 37
0
        private void defineAbove()
        {
            // Определение арматуры надпроемной части
            // Наличие вертик погонной арм - на выпуск

            int diamVerticArm = Block.GetPropValue <int>(PropNameArmVerticDiam);
            int stepVerticArm = Block.GetPropValue <int>(PropNameArmVerticStep);
            // Длина нахлести вертик арм (для скобы)
            int lapLengthVerticArm = Armature.GetLapLength(diamVerticArm, Concrete);
            int widthRun           = ApertureWidth - 100;

            if (widthRun <= 0)
            {
                return;
            }

            int lengthVerticArm = Height - ApertureHeight + Outline - 20;
            int bracketLen      = lapLengthVerticArm;

            // Если высота стены над проемом больше двух длин нахлеста, то добавляется вертикальная погонная арматура
            if (Height - ApertureHeight > lapLengthVerticArm * 2)
            {
                // Добавление вертик погонной арм - без коэф нахлести погонной арм!!!
                string posArmVertic = Block.GetPropValue <string>(PropNameArmVerticPos);
                ArmVertic = new BarRunning(diamVerticArm, lengthVerticArm, widthRun, stepVerticArm, 2, posArmVertic, this, "Вертикальная погонная арматура");
                ArmVertic.Calc();
            }
            else
            {
                // Скоба на всю высоту выпуска вертик стержней (без погонной арматуры)
                bracketLen = lengthVerticArm;
            }
            // Скоба верхняя
            int    tBracket   = Thickness - 2 * a - diamVerticArm;
            string posBracket = Block.GetPropValue <string>(PropNameBracketTopPos);

            BracketTop = new Bracket(diamVerticArm, bracketLen, tBracket, stepVerticArm, widthRun, 1, posBracket,
                                     this, "Скоба верхняя");
            BracketTop.Calc();

            // Хомут
            int    stepShackle = Block.GetPropValue <int>(PropNameShackleStep);
            int    diamShackle = Block.GetPropValue <int>(PropNameShackleDiam);
            int    wShackle    = Thickness - 2 * a + diamVerticArm + AddArmHor.Diameter * 2;
            int    hShackle    = (addArmHorTopCount == 4 ? 100: 200) + AddArmHor.Diameter;
            string posShackle  = Block.GetPropValue <string>(PropNameShackleTopPos);

            ShackleTop = new Shackle(diamShackle, wShackle, hShackle, stepShackle, widthRun, 1, posShackle, this);
            ShackleTop.Calc();

            // Горизонтальная погонная арм - Фоновая
            int stepHorArm  = Block.GetPropValue <int>(PropNameArmHorStep);
            int widthHorArm = Height - ApertureHeight - a - (addArmHorTopCount == 4 ? 100: 200) - stepHorArm - 50;

            if (widthHorArm > 0)
            {
                ArmHor = defineBarRunStep(ApertureWidth, widthHorArm, 2, PropNameArmHorDiam, PropNameArmHorPos,
                                          PropNameArmHorStep, Concrete, "Горизонтальная фоновая арматура");
                ArmHor.Calc();
            }
        }
Esempio n. 38
0
 public void DBInit(Armature armature)
 {
     this.armature = armature;
 }
Esempio n. 39
0
		/**
		 * Qualifies all resources used by this Animation instance for garbage collection.
		 */
		public void Dispose()
		{
			if(_armature ==  null)
			{
				return;
			}
			Stop();
			int i = _animationLayer.Count;
			while(i -- >0)
			{
				List<AnimationState> animationStateList = _animationLayer[i];
				int j = animationStateList.Count;
				while(j -- >0)
				{
					AnimationState.returnObject(animationStateList[j]);
				}
				animationStateList.Clear();
			}
			_animationLayer.Clear();
		    _animationList.Clear();
			
			_armature = null;
			_animationLayer = null;
			_animationDataList = null;
			_animationList = null;
		}
 /// <summary>
 /// Set the armature that this clothing item will follow. This will copy the bone transforms.
 /// </summary>
 /// <param name="armature">The target armature.</param>
 public void SetTargetArmature(Armature armature)
 {
     _armature.SetTargetArmature(armature);
 }