예제 #1
0
        public static ActorIKTarget Read(Actor actor, BinaryReader reader, ActorIKTarget node = null)
        {
            if (node == null)
            {
                node = new ActorIKTarget();
            }

            ActorNode.Read(actor, reader, node);

            // discard old value
            int order = reader.ReadUInt16();

            node.m_Strength        = reader.ReadSingle();
            node.m_InvertDirection = reader.ReadByte() == 1;

            int numInfluencedBones = (int)reader.ReadByte();

            if (numInfluencedBones > 0)
            {
                node.m_InfluencedBones = new InfluencedBone[numInfluencedBones];

                for (int i = 0; i < numInfluencedBones; i++)
                {
                    InfluencedBone ib = new InfluencedBone();
                    ib.m_BoneIdx = reader.ReadUInt16();
                    node.m_InfluencedBones[i] = ib;
                }
            }

            return(node);
        }
예제 #2
0
        public override ActorComponent MakeInstance(Actor resetActor)
        {
            ActorIKTarget instanceNode = new ActorIKTarget();

            instanceNode.Copy(this, resetActor);
            return(instanceNode);
        }
예제 #3
0
 // Support old system.
 public ActorIKConstraint(ActorIKTarget target)
 {
     InfluencedBone[] bones = target.InfluencedBones;
     m_Actor           = target.Actor;
     m_InfluencedBones = target.InfluencedBones;
     m_TargetIdx       = target.Idx;
     m_ParentIdx       = bones[bones.Length - 1].m_BoneIdx;
     m_InvertDirection = target.InvertDirection;
     m_Strength        = target.m_Strength;
     m_IsEnabled       = true;
 }
예제 #4
0
        public void Copy(ActorIKTarget node, Actor resetActor)
        {
            base.Copy(node, resetActor);

            m_InvertDirection = node.m_InvertDirection;
            m_Strength        = node.m_Strength;
            m_InfluencedBones = new InfluencedBone[node.m_InfluencedBones.Length];
            for (int i = 0; i < m_InfluencedBones.Length; i++)
            {
                InfluencedBone ib = new InfluencedBone();
                ib.m_BoneIdx         = node.m_InfluencedBones[i].m_BoneIdx;
                m_InfluencedBones[i] = ib;
            }
        }
예제 #5
0
        private void ReadComponentsBlock(BlockReader block)
        {
            int componentCount = block.ReadUInt16();

            m_Components    = new ActorComponent[componentCount + 1];
            m_Components[0] = m_Root;

            // Guaranteed from the exporter to be in index order.
            BlockReader nodeBlock = null;

            int componentIndex = 1;

            m_NodeCount = 1;
            while ((nodeBlock = block.ReadNextBlock()) != null)
            {
                ActorComponent component = null;
                if (Enum.IsDefined(typeof(BlockTypes), nodeBlock.BlockType))
                {
                    BlockTypes type = (BlockTypes)nodeBlock.BlockType;
                    switch (type)
                    {
                    case BlockTypes.ActorNode:
                        component = ActorNode.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorBone:
                        component = ActorBone.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorRootBone:
                        component = ActorRootBone.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorImage:
                        m_ImageNodeCount++;
                        component = ActorImage.Read(this, nodeBlock, makeImageNode());
                        if ((component as ActorImage).TextureIndex > m_MaxTextureIndex)
                        {
                            m_MaxTextureIndex = (component as ActorImage).TextureIndex;
                        }
                        break;

                    case BlockTypes.ActorIKTarget:
                        component = ActorIKTarget.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorEvent:
                        component = ActorEvent.Read(this, nodeBlock);
                        break;

                    case BlockTypes.CustomIntProperty:
                        component = CustomIntProperty.Read(this, nodeBlock);
                        break;

                    case BlockTypes.CustomFloatProperty:
                        component = CustomFloatProperty.Read(this, nodeBlock);
                        break;

                    case BlockTypes.CustomStringProperty:
                        component = CustomStringProperty.Read(this, nodeBlock);
                        break;

                    case BlockTypes.CustomBooleanProperty:
                        component = CustomBooleanProperty.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorColliderRectangle:
                        component = ActorColliderRectangle.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorColliderTriangle:
                        component = ActorColliderTriangle.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorColliderCircle:
                        component = ActorColliderCircle.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorColliderPolygon:
                        component = ActorColliderPolygon.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorColliderLine:
                        component = ActorColliderLine.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorNodeSolo:
                        component = ActorNodeSolo.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorJellyBone:
                        component = ActorJellyBone.Read(this, nodeBlock);
                        break;

                    case BlockTypes.JellyComponent:
                        component = JellyComponent.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorIKConstraint:
                        component = ActorIKConstraint.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorDistanceConstraint:
                        component = ActorDistanceConstraint.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorTranslationConstraint:
                        component = ActorTranslationConstraint.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorScaleConstraint:
                        component = ActorScaleConstraint.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorRotationConstraint:
                        component = ActorRotationConstraint.Read(this, nodeBlock);
                        break;

                    case BlockTypes.ActorTransformConstraint:
                        component = ActorTransformConstraint.Read(this, nodeBlock);
                        break;
                    }
                }
                if (component is ActorNode)
                {
                    m_NodeCount++;
                }

                m_Components[componentIndex] = component;
                if (component != null)
                {
                    component.Idx = (ushort)(componentIndex);
                }
                componentIndex++;
            }

            m_ImageNodes = new ActorImage[m_ImageNodeCount];
            m_Nodes      = new ActorNode[m_NodeCount];
            m_Nodes[0]   = m_Root;

            // Resolve nodes.
            int imgIdx = 0;
            int anIdx  = 0;

            ActorComponent[] components = m_Components;
            for (int i = 1; i <= componentCount; i++)
            {
                ActorComponent c = components[i];
                // Nodes can be null if we read from a file version that contained nodes that we don't interpret in this runtime.
                if (c != null)
                {
                    c.ResolveComponentIndices(components);
                }

                ActorImage ain = c as ActorImage;
                if (ain != null)
                {
                    m_ImageNodes[imgIdx++] = ain;
                }

                ActorNode an = c as ActorNode;
                if (an != null)
                {
                    m_Nodes[anIdx++] = an;
                }
            }

            for (int i = 1; i <= componentCount; i++)
            {
                ActorComponent c = components[i];
                if (c != null)
                {
                    c.CompleteResolve();
                }
            }

            SortDependencies();
        }