Exemplo n.º 1
0
        public Skeleton CollectSkeleton()
        {
            //System.Diagnostics.Debugger.Launch();
            Skeleton skele = new Skeleton();

            List<Joint> joints = new List<Joint>();
            List<LimbNodeProperty<LimbNodeNodeAttributeType>> attrType = new List<LimbNodeProperty<LimbNodeNodeAttributeType>>();
            List<LimbNodeProperty<LimbNodeJointType>> jointTypes = new List<LimbNodeProperty<LimbNodeJointType>>();
            List<DeformerProperty<JointPropertyType>> deformTypes = new List<DeformerProperty<JointPropertyType>>();

            for (int i = 0; i < _properties.Count; i++)
            {
                IObjectProperty type = _properties[i];

                if (type.GetType() == typeof(LimbNodeProperty<LimbNodeJointType>))
                    jointTypes.Add((LimbNodeProperty<LimbNodeJointType>)type);
                else if (type.GetType() == typeof(LimbNodeProperty<LimbNodeNodeAttributeType>))
                    attrType.Add((LimbNodeProperty<LimbNodeNodeAttributeType>)type);
                else if (type.GetType() == typeof(DeformerProperty<JointPropertyType>))
                    deformTypes.Add((DeformerProperty<JointPropertyType>)type);
            }

            for (int i = 0; i < attrType.Count; i++)
            {
                for (int q = 0; q < jointTypes.Count; q++)
                {
                    ObjectConnection con = _connections.Find(obj => (attrType[i].ID == obj.Id1) && (jointTypes[q].ID == obj.Id2));

                    if (con != null)
                    {
                        if (!attrType[i].PropertyType.IsSkeletonType)
                            break;

                        for (int w = 0; w < deformTypes.Count; w++)
                        {
                            ObjectConnection con2 = _connections.Find(obj => (jointTypes[q].ID == obj.Id1) && (deformTypes[w].ID == obj.Id2));

                            if (con2 != null)
                            {
                                //System.Diagnostics.Debugger.Launch();
                                int parentId = FindParentOfJoint(jointTypes[q].ID, jointTypes);
                                skele.AddJoint(new Joint(jointTypes[q].Name, jointTypes[q].ID, parentId, jointTypes[q].PropertyType.Translation,
                                    jointTypes[q].PropertyType.Rotation, jointTypes[q].PropertyType.Scale, deformTypes[w].Indicies, deformTypes[w].PropertyType.Weights));
                                break;
                            }
                        }

                        break;
                    }
                }
            }

            skele.FinaliseJointTree();

            return skele;
        }