• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Bone类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: ForwardKinematics

 /// <summary>
 /// Forward kinamatic function
 /// </summary>
 /// <param name="bones">The kinamatic chain, array of bones</param>
 /// <param name="rotation">The rotation to be alplied to the chain</param>
 /// <param name="i">An index of where in the chain the rotation should starts</param>
 /// <param name="length">The amount of bones in the chain the kinamatics should be applied to</param>
 protected void ForwardKinematics(ref Bone[] bones, Quaternion rotation, int i, int length)
 {
     for (int j = length; j >= i; j--)
     {
         if (j > i)
         {
             bones[j].Pos = bones[i].Pos +
                 Vector3.Transform((bones[j].Pos - bones[i].Pos), rotation);
         }
         // rotate orientation
         bones[j].Rotate(rotation);
     }
 }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:20,代码来源:IKSolver.cs


示例17: GetData

    void GetData()
    {
        try
        {
            this.client.Update(ref this.data);
            UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER();
            dec.Source = this.data;

            //データ格納
            this.List_Humans.Clear();

            int MaxofHuman = (int)dec.get_byte();
            int NumofHuman = (int)dec.get_byte();

            this.List_Humans = new List<Human>();

            for (int i = 0; i < NumofHuman; i++)
            {
                Human human = new Human();
                human.id = i;
                human.numofBone = (int)dec.get_byte();
                human.bones = new Bone[human.numofBone];

                for (int j = 0; j < human.numofBone; j++)
                {
                    Bone bone = new Bone();

                    bone.dimensiton = (int)dec.get_byte();
                    bone.position.x = dec.get_float();
                    bone.position.y = dec.get_float();
                    bone.position.z = dec.get_float();
                    bone.quaternion.x = dec.get_float();
                    bone.quaternion.y = dec.get_float();
                    bone.quaternion.z = dec.get_float();
                    bone.quaternion.w = dec.get_float();
                    bone.IsTracking = dec.get_byte();

                    human.bones[j] = bone;

                }

                this.List_Humans.Add(human);
            }
        }
        catch
        {
            Debug.Log("Error:ReceiveData");
        }

    
    }
开发者ID:0tsukq,项目名称:LabLife,代码行数:51,代码来源:CIPCReceiver.cs


示例18: Bone

    /// <summary>
    /// TODO:
    /// </summary>
    /// <param name="Parent"></param>
    /// <param name="Localvec"></param>
    public Bone(Bone Parent, Vector3f Localvec, TrackingState ts)
    {
        if (Parent != null)
        {
            this.Parent = Parent;
            this.LocalVec = Localvec;
        }
        else
        {
            this.GlobalVec = LocalVec;
        }
        this.trackingstate = ts;

    }
开发者ID:YusukeKajita,项目名称:ShadowMedia3D,代码行数:19,代码来源:Bone.cs


示例19: CheckOrientationalConstraint

        // An orientational constraint is the twist of the bone around its own direction vector
        // with respect to its parent
        // It is defined as an allowed range betwen angles [start,end]
        // where start != end && 0 < start, end <= 360
        // If both start and end is 0 no twist constraint exist
        /// <summary>
        /// Checks if the bone has a legal rotation in regards to its parent, returns true if legal, false otherwise.
        /// The out rotation gives the rotation the bone should be applied to to be inside the twist constraints
        /// </summary>
        /// <param name="b">The bone under consideration</param>
        /// <param name="refBone">The parent of the bone, to check whether the child has legal rotation</param>
        /// <param name="rotation">The rotation bone b should applie to be inside the constraints</param>
        /// <returns></returns>
        public bool CheckOrientationalConstraint(Bone b, Bone refBone, out Quaternion rotation)
        {
            if (b.Orientation.Xyz.IsNaN() || refBone.Orientation.Xyz.IsNaN())
            {
                rotation = Quaternion.Identity;
                return false;
            }
            Vector3 thisY = b.GetYAxis();
            Quaternion referenceRotation = refBone.Orientation * b.ParentPointer;
            Vector3 reference = Vector3.Transform(
                    Vector3.Transform(Vector3.UnitZ, referenceRotation),
                    QuaternionHelper2.GetRotationBetween(
                            Vector3.Transform(Vector3.UnitY, referenceRotation),
                            thisY));

            float twistAngle = MathHelper.RadiansToDegrees(Vector3.CalculateAngle(reference, b.GetZAxis()));

            if (Vector3.CalculateAngle(reference, b.GetXAxis()) > Mathf.PI / 2) // b is twisted left with respect to parent
                twistAngle = 360 - twistAngle;

            float leftLimit = b.StartTwistLimit;
            float rightLimit = b.EndTwistLimit;

            float precision = 0.5f;
            bool inside = (leftLimit >= rightLimit) ? // The allowed range is on both sides of the reference vector
                    inside = twistAngle - leftLimit >= precision || twistAngle - rightLimit <= precision :
                    inside = twistAngle - leftLimit >= precision && twistAngle - rightLimit <= precision;

            if (!inside) // not inside constraints
            {
                // Create a rotation to the closest limit
                float toLeft = Math.Min(360 - Math.Abs(twistAngle - leftLimit), Math.Abs(twistAngle - leftLimit));
                float toRight = Math.Min(360 - Math.Abs(twistAngle - rightLimit), Math.Abs(twistAngle - rightLimit));
                if (toLeft < toRight)
                {
                    // Anti-clockwise rotation to left limit
                    rotation = Quaternion.FromAxisAngle(thisY, -MathHelper.DegreesToRadians(toLeft));
                    return true;
                }
                else
                {
                    // Clockwise to right limit
                    rotation = Quaternion.FromAxisAngle(thisY, MathHelper.DegreesToRadians(toRight));
                    return true;
                }
            }
            rotation = Quaternion.Identity;
            return false;
        }
开发者ID:jamesrrowland,项目名称:Qualisys-Unity-SDK,代码行数:62,代码来源:ConstraintsFunctions.cs


示例20: Derpy

        public Derpy(ThingBlock block, ThingDefinition def)
            : base(block, def)
        {
            bodyComponent = ModelComponents[0];
            flagComponent = ModelComponents[1];
            startLightComponent = ModelComponents[2];

            bodyFacing = new Euler(0, 0, 0);
            neckFacing = new Euler(0, 0, 0);

            Skeleton skeleton = bodyComponent.Entity.Skeleton;
            skeleton.BlendMode = SkeletonAnimationBlendMode.ANIMBLEND_CUMULATIVE;

            blinkState = bodyComponent.Entity.GetAnimationState("Blink2");
            blinkState.Enabled = true;
            blinkState.Loop = true;
            blinkState.Weight = 1f;
            blinkState.AddTime(ID);

            neckBone = skeleton.GetBone("Neck");
            neckBone.SetManuallyControlled(true);
            foreach (var state in bodyComponent.Entity.AllAnimationStates.GetAnimationStateIterator())
            {
                // don't add a blend mask to the blink state because we'll make a different one for it
                if (state == blinkState)
                    continue;

                state.CreateBlendMask(skeleton.NumBones);
                state.SetBlendMaskEntry(neckBone.Handle, 0f);
            }
            neckBone.InheritOrientation = false;

            blinkState.CreateBlendMask(skeleton.NumBones, 0f);
            ushort handle = skeleton.GetBone("EyeBrowTop.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.R").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowTop.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);
            handle = skeleton.GetBone("EyeBrowBottom.L").Handle;
            blinkState.SetBlendMaskEntry(handle, 1f);

            LKernel.GetG<AnimationManager>().Add(blinkState);

            interpNode = LKernel.GetG<SceneManager>().RootSceneNode.CreateChildSceneNode("DerpyInterpNode" + ID, Vector3.ZERO);

            anim = DerpyAnimation.Hover1;
        }
开发者ID:CisciarpMaster,项目名称:PonyKart,代码行数:48,代码来源:Derpy.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Boo类代码示例发布时间:2022-05-24
下一篇:
C# Bond类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap