当前位置: 首页>>代码示例>>C#>>正文


C# Bone类代码示例

本文整理汇总了C#中Bone的典型用法代码示例。如果您正苦于以下问题:C# Bone类的具体用法?C# Bone怎么用?C# Bone使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bone类属于命名空间,在下文中一共展示了Bone类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Arm

    public Arm(int p, Entity.Gender g)
    {
        if(p > 9 || p < 1)
        {
            throw new System.OverflowException("Position: " + p + " is invalid for arm!");
        }
        position = p;

        switch(g){
        case Entity.Gender.MALE: //placeholder
            {
                break;
            }
        case Entity.Gender.FEMALE: //females have weaker bone structure than males
            {
                Bone Scapula = new Bone (.7, 20, 1);
                Bone Humerus = new Bone (.65, 14, 2);
                Bone Radius = new Bone (.25, 10, 3);
                Bone Ulna = new Bone (.25, 10, 3);
                Bone Carpus = new Bone (.35, 12, 4);
                Bone Thumb = new Bone (.12, 8, 5);
                Bone Pointer = new Bone (.12, 8, 5);
                Bone Middle = new Bone (.12, 8, 5);
                Bone Ring = new Bone (.12, 8, 5);
                Bone Pinky = new Bone (.12, 5, 5);
                break;
            }

        }
    }
开发者ID:Battlespud,项目名称:ducking-octo-shame,代码行数:30,代码来源:Arm.cs

示例2: LateUpdate

    public void LateUpdate()
    {
        if (!valid) {
            Reset();
            return;
        }

        if (bone == null) {
            if (boneName == null || boneName.Length == 0) return;
            bone = skeletonRenderer.skeleton.FindBone(boneName);
            if (bone == null) {
                Debug.LogError("Bone not found: " + boneName, this);
                return;
            }
        }

        if (cachedTransform.parent == skeletonTransform) {
            cachedTransform.localPosition = new Vector3(bone.worldX, bone.worldY, cachedTransform.localPosition.z);
            Vector3 rotation = cachedTransform.localRotation.eulerAngles;
            cachedTransform.localRotation = Quaternion.Euler(rotation.x, rotation.y, bone.worldRotation);
        } else {
            cachedTransform.position = skeletonTransform.TransformPoint(new Vector3(bone.worldX, bone.worldY, cachedTransform.position.z));
            Vector3 rotation = skeletonTransform.rotation.eulerAngles;
            cachedTransform.rotation = Quaternion.Euler(rotation.x, rotation.y,
                skeletonTransform.rotation.eulerAngles.z + bone.worldRotation);
        }
    }
开发者ID:justinwyer,项目名称:spine-runtimes,代码行数:27,代码来源:BoneComponent.cs

示例3: CalculateBoneWeights

    public static Bone2DWeights CalculateBoneWeights(Transform owner, Bone[] bones, Mesh mesh)
    {
        if (bones != null) {
            Bone2DWeights boneWeights = new Bone2DWeights();
            boneWeights.weights = new Bone2DWeight[] { };

            int vIndex = 0;
            foreach (Vector3 v in mesh.vertices) {
                Bone closest = FindClosestBone(v, bones);
                if (closest != null) {
                    boneWeights.SetWeight(vIndex++, closest.name, Array.IndexOf(bones, closest), 1f);
                }
            }

            BoneWeight[] unitweights = boneWeights.GetUnityBoneWeights();
            mesh.boneWeights = unitweights;

            Transform[] bonesArr = bones.Select(b => b.transform).ToArray();
            Matrix4x4[] bindPoses = new Matrix4x4[bonesArr.Length];

            for (int i = 0; i < bonesArr.Length; i++) {
                bindPoses[i] = bonesArr[i].worldToLocalMatrix * owner.localToWorldMatrix;
            }

            mesh.bindposes = bindPoses;

            return boneWeights;
        }

        return null;
    }
开发者ID:shkilevk,项目名称:Jury-rig-a-2D-game-workshop,代码行数:31,代码来源:SpriteMesh.cs

示例4: BackwardReaching

        /// <summary>
        /// The backwards reaching phase
        /// </summary>
        /// <param name="bones"></param>
        /// <param name="distances"></param>
        /// <param name="root"></param>
        /// <param name="parent"></param>
        private void BackwardReaching(ref Bone[] bones, ref float[] distances, Vector3 root, Bone parent)
        {
            bones[0].Pos = root;

            for (int i = 0; i < bones.Length - 1; i++)
            {
                SamePosCheck(ref bones, i);
                Vector3 newPos;
                // Position
                float r = (bones[i + 1].Pos - bones[i].Pos).Length;
                float l = distances[i] / r;

                newPos = (1 - l) * bones[i].Pos + l * bones[i + 1].Pos;

                Bone prevBone = (i > 0) ? bones[i - 1] : parent;
                bones[i + 1].Pos = newPos;
                // Orientation
                bones[i].RotateTowards(bones[i + 1].Pos - bones[i].Pos,bones[i].Stiffness);
                if (bones[i].HasConstraints)
                {
                    Quaternion rot;
                    if (constraints.CheckOrientationalConstraint(bones[i], prevBone, out rot))
                    {
                        bones[i].Rotate(rot);
                    }

                }
            }
        }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:36,代码来源:FABRIK.cs

示例5: SolveBoneChain

        public override bool SolveBoneChain(Bone[] bones, Bone target, Bone parent)
        {
            // Calculate distances
            float[] distances = GetDistances(ref bones);

            double dist = Math.Abs((bones[0].Pos - target.Pos).Length);
            if (dist > distances.Sum()) // the target is unreachable
            {
                TargetUnreachable(bones, target.Pos, parent);
                return true;
            }

            // The target is reachable
            int numberOfBones = bones.Length;
            bones[numberOfBones - 1].Orientation = target.Orientation;
            Vector3 root = bones[0].Pos;
            int iterations = 0;
            float lastDistToTarget = float.MaxValue;

            float distToTarget = (bones[bones.Length - 1].Pos - target.Pos).Length;
            while (distToTarget > threshold && iterations++ < MaxIterations && distToTarget < lastDistToTarget)
            {
                // Forward reaching
                ForwardReaching(ref bones, ref distances, target);
                // Backward reaching
                BackwardReaching(ref bones, ref distances, root, parent);

                lastDistToTarget = distToTarget;
                distToTarget = (bones[bones.Length - 1].Pos - target.Pos).Length;
            }
            bones[bones.Length - 1].Orientation = target.Orientation;

            return (distToTarget <= threshold);
        }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:34,代码来源:FABRIK.cs

示例6: MirrorNode

 public MirrorNode(Node parentNode, Bone referenceBone)
 {
     this.ReferenceBone = referenceBone;
     Node = parentNode.CreateChild(ReferenceBone.InitialPosition, ReferenceBone.InitialOrientation);
     Children = new List<MirrorNode>(ReferenceBone.NumChildren());
     foreach (Bone bone in referenceBone.GetChildIterator().OfType<Bone>())
         Children.Add(new MirrorNode(Node, bone));
 }
开发者ID:nigelchanyk,项目名称:Archetype,代码行数:8,代码来源:BodyCollisionTree.cs

示例7: SceneAnimator

 public SceneAnimator() {
     _skeleton = null;
     CurrentAnimationIndex = -1;
     _bonesByName = new Dictionary<string, Bone>();
     _bonesToIndex = new Dictionary<string, int>();
     _animationNameToId = new Dictionary<string, int>();
     _bones = new List<Bone>();
     Animations = new List<AnimEvaluator>();
 }
开发者ID:amitprakash07,项目名称:dx11,代码行数:9,代码来源:SceneAnimator.cs

示例8: ContainsDuplicateBone

 /// <summary>
 /// Checks if an array of objects contains any duplicates.
 /// </summary>
 public static Transform ContainsDuplicateBone(Bone[] bones)
 {
     for (int i = 0; i < bones.Length; i++) {
         for (int i2 = 0; i2 < bones.Length; i2++) {
             if (i != i2 && bones[i].transform == bones[i2].transform) return bones[i].transform;
         }
     }
     return null;
 }
开发者ID:nickgirardo,项目名称:KADAPT,代码行数:12,代码来源:IKSolver.cs

示例9: GetDistances

 /// <summary>
 /// Gets the total length from the root of each bone in the kinematic chain (the bone chain)
 /// </summary>
 /// <param name="distances"></param>
 /// <param name="bones"></param>
 protected float[] GetDistances(ref Bone[] bones)
 {
     float[] distances = new float[bones.Length - 1];
     for (int i = 0; i < distances.Length; i++)
     {
         distances[i] = (bones[i].Pos - bones[i + 1].Pos).Length;
     }
     return distances;
 }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:14,代码来源:IKSolver.cs

示例10: IsReachable

 /// <summary>
 /// Checks wheter the target is reacheble for the bone chain or not
 /// </summary>
 /// <param name="bones">The chain of bone, the IK Chain</param>
 /// <param name="target">The target</param>
 /// <returns>True if target is reachable, false otherwise</returns>
 protected bool IsReachable(Bone[] bones, Bone target)
 {
     float acc = 0;
     for (int i = 0; i < bones.Length - 1; i++)
     {
         acc += (bones[i].Pos - bones[i + 1].Pos).Length;
     }
     float dist = System.Math.Abs((bones[0].Pos - target.Pos).Length);
     return dist < acc; // the target is unreachable
 }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:16,代码来源:IKSolver.cs

示例11: EditAttachedObjectEventArgs

 /// <summary>
 ///     Initializes a new instance of the EditAttachedObjectEventArgs class.
 /// </summary>
 /// <param name="response">EditObjectResponse.</param>
 /// <param name="index">Index of the attached object.</param>
 /// <param name="modelid">Model of the attached object.</param>
 /// <param name="bone">The bone the object was attached to.</param>
 /// <param name="offset">Offset of the attached object.</param>
 /// <param name="rotation">Rotation of the attached object.</param>
 /// <param name="scale">Scale of the attached object.</param>
 public EditAttachedObjectEventArgs(EditObjectResponse response, int index, int modelid, Bone bone,
     Vector3 offset, Vector3 rotation, Vector3 scale)
 {
     EditObjectResponse = response;
     Index = index;
     ModelId = modelid;
     Bone = bone;
     Offset = offset;
     Rotation = rotation;
     Scale = scale;
 }
开发者ID:Xalphox,项目名称:SampSharp,代码行数:21,代码来源:EditAttachedObjectEventArgs.cs

示例12: QMesh

 internal QMesh(Point3f[] v, TexCoord[] t, Color[] c, ushort[] f, Matrix m, Texture tx, string n, Bone[] pmBones, bool outline)
     : base(Matrix.IDENTITY, pmBones)
 {
     vertices=	v;
     texcoords=	t;
     colors=	c;
     faces=	f;
     pMatrix=	m;
     pTexture=	tx;
     name=	n;
     bRenderOutline=	outline;
 }
开发者ID:pgonzbecer,项目名称:GDToolkit,代码行数:12,代码来源:QMesh.cs

示例13: UpdateSegmentPosition

 void UpdateSegmentPosition(JointID j1, JointID j2, Segment seg)
 {
     var bone = new Bone(j1, j2);
     if (segments.ContainsKey(bone))
     {
         BoneData data = segments[bone];
         data.UpdateSegment(seg);
         segments[bone] = data;
     }
     else
         segments.Add(bone, new BoneData(seg));
 }
开发者ID:thoschmidt,项目名称:shoopdoup,代码行数:12,代码来源:Player.cs

示例14: HeadIK

			public HeadIK( FullBodyIK fullBodyIK )
			{
				_settings = fullBodyIK.settings;
				_internalValues = fullBodyIK.internalValues;

				_neckBone = _PrepareBone( fullBodyIK.headBones.neck );
				_headBone = _PrepareBone( fullBodyIK.headBones.head );
				_leftEyeBone = _PrepareBone( fullBodyIK.headBones.leftEye );
				_rightEyeBone = _PrepareBone( fullBodyIK.headBones.rightEye );
				_headEffector = fullBodyIK.headEffectors.head;
				_eyesEffector = fullBodyIK.headEffectors.eyes;
            }
开发者ID:Stereoarts,项目名称:SAFullBodyIK,代码行数:12,代码来源:HeadIK.cs

示例15: init

 protected override void init()
 {
     bones = new List<Bone>();
     Bone bone = new Bone();
     bone.Scale(new Vector3(0.2f, 1f, 0.2f));
     bones.Add(bone);
     bone = new Bone();
     bone.Scale(new Vector3(0.2f, 0.5f, 0.2f));
     bone.Move(new Vector3(0.3f, 0f, 0f));
     bones[0].AddChild(bone);
     bones.Add(bone);
     SetupDepthAndCull();
 }
开发者ID:j1s1e1,项目名称:GlslMonoOpenTkExamples,代码行数:13,代码来源:Tut_Skeleton.cs


注:本文中的Bone类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。