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


C# Entity.ApplyAngularImpulse方法代码示例

本文整理汇总了C#中BEPUphysics.Entities.Entity.ApplyAngularImpulse方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.ApplyAngularImpulse方法的具体用法?C# Entity.ApplyAngularImpulse怎么用?C# Entity.ApplyAngularImpulse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BEPUphysics.Entities.Entity的用法示例。


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

示例1: PreStep


//.........这里部分代码省略.........
            //Compute inverse effective mass matrix
            float entryA, entryB;
            float entryA2, entryB2;

            //these are the transformed coordinates
            float tX, tY, tZ;
            float tX2, tY2, tZ2;
            if (parentA.isDynamic)
            {
                tX = angularAX * parentA.inertiaTensorInverse.M11 + angularAY * parentA.inertiaTensorInverse.M21 + angularAZ * parentA.inertiaTensorInverse.M31;
                tY = angularAX * parentA.inertiaTensorInverse.M12 + angularAY * parentA.inertiaTensorInverse.M22 + angularAZ * parentA.inertiaTensorInverse.M32;
                tZ = angularAX * parentA.inertiaTensorInverse.M13 + angularAY * parentA.inertiaTensorInverse.M23 + angularAZ * parentA.inertiaTensorInverse.M33;
                entryA = tX * angularAX + tY * angularAY + tZ * angularAZ + 1 / parentA.mass;

                tX2 = angularAX2 * parentA.inertiaTensorInverse.M11 + angularAY2 * parentA.inertiaTensorInverse.M21 + angularAZ2 * parentA.inertiaTensorInverse.M31;
                tY2 = angularAX2 * parentA.inertiaTensorInverse.M12 + angularAY2 * parentA.inertiaTensorInverse.M22 + angularAZ2 * parentA.inertiaTensorInverse.M32;
                tZ2 = angularAX2 * parentA.inertiaTensorInverse.M13 + angularAY2 * parentA.inertiaTensorInverse.M23 + angularAZ2 * parentA.inertiaTensorInverse.M33;
                entryA2 = tX2 * angularAX2 + tY2 * angularAY2 * tZ2 * angularAZ2 + 1 / parentA.mass;
            }
            else
            {
                entryA = 0;
                entryA2 = 0;
            }

            if (parentB.isDynamic)
            {
                tX = angularBX * parentB.inertiaTensorInverse.M11 + angularBY * parentB.inertiaTensorInverse.M21 + angularBZ * parentB.inertiaTensorInverse.M31;
                tY = angularBX * parentB.inertiaTensorInverse.M12 + angularBY * parentB.inertiaTensorInverse.M22 + angularBZ * parentB.inertiaTensorInverse.M32;
                tZ = angularBX * parentB.inertiaTensorInverse.M13 + angularBY * parentB.inertiaTensorInverse.M23 + angularBZ * parentB.inertiaTensorInverse.M33;
                entryB = tX * angularBX + tY * angularBY + tZ * angularBZ + 1 / parentB.mass;

                tX2 = angularBX2 * parentB.inertiaTensorInverse.M11 + angularBY2 * parentB.inertiaTensorInverse.M21 + angularBZ2 * parentB.inertiaTensorInverse.M31;
                tY2 = angularBX2 * parentB.inertiaTensorInverse.M12 + angularBY2 * parentB.inertiaTensorInverse.M22 + angularBZ2 * parentB.inertiaTensorInverse.M32;
                tZ2 = angularBX2 * parentB.inertiaTensorInverse.M13 + angularBY2 * parentB.inertiaTensorInverse.M23 + angularBZ2 * parentB.inertiaTensorInverse.M33;
                entryB2 = tX2 * angularBX2 + tY2 * angularBY2 + tZ2 * angularBZ2 + 1 / parentB.mass;
            }
            else
            {
                entryB = 0;
                entryB2 = 0;
            }
            velocityToImpulse = -1 / (entryA + entryB); //Softness?
            velocityToImpulse2 = -1 / (entryA2 + entryB2);


            //Warm starting
#if !WINDOWS
            Vector3 linear = new Vector3();
            Vector3 angular = new Vector3();
#else
            Vector3 linear, angular;
#endif
            linear.X = accumulatedImpulse * linearAX;
            linear.Y = accumulatedImpulse * linearAY;
            linear.Z = accumulatedImpulse * linearAZ;
            if (parentA.isDynamic)
            {
                angular.X = accumulatedImpulse * angularAX;
                angular.Y = accumulatedImpulse * angularAY;
                angular.Z = accumulatedImpulse * angularAZ;
                parentA.ApplyLinearImpulse(ref linear);
                parentA.ApplyAngularImpulse(ref angular);
            }
            if (parentB.isDynamic)
            {
                linear.X = -linear.X;
                linear.Y = -linear.Y;
                linear.Z = -linear.Z;
                angular.X = accumulatedImpulse * angularBX;
                angular.Y = accumulatedImpulse * angularBY;
                angular.Z = accumulatedImpulse * angularBZ;
                parentB.ApplyLinearImpulse(ref linear);
                parentB.ApplyAngularImpulse(ref angular);
            }

            //Warm starting 2
            linear.X = accumulatedImpulse2 * linearAX2;
            linear.Y = accumulatedImpulse2 * linearAY2;
            linear.Z = accumulatedImpulse2 * linearAZ2;
            if (parentA.isDynamic)
            {
                angular.X = accumulatedImpulse2 * angularAX2;
                angular.Y = accumulatedImpulse2 * angularAY2;
                angular.Z = accumulatedImpulse2 * angularAZ2;
                parentA.ApplyLinearImpulse(ref linear);
                parentA.ApplyAngularImpulse(ref angular);
            }
            if (parentB.isDynamic)
            {
                linear.X = -linear.X;
                linear.Y = -linear.Y;
                linear.Z = -linear.Z;
                angular.X = accumulatedImpulse2 * angularBX2;
                angular.Y = accumulatedImpulse2 * angularBY2;
                angular.Z = accumulatedImpulse2 * angularBZ2;
                parentB.ApplyLinearImpulse(ref linear);
                parentB.ApplyAngularImpulse(ref angular);
            }
        }
开发者ID:dsmo7206,项目名称:Lemma,代码行数:101,代码来源:SlidingFrictionTwoAxisObsolete.cs


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