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


C# RigidBody.GetVelocityInLocalPoint方法代码示例

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


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

示例1: UpdateWheel

        public void UpdateWheel(RigidBody chassis, RaycastInfo raycastInfo)
        {
            if (raycastInfo.IsInContact)
            {
                float project = Vector3.Dot(raycastInfo.ContactNormalWS, raycastInfo.WheelDirectionWS);
                Vector3 chassis_velocity_at_contactPoint;
                Vector3 relpos = raycastInfo.ContactPointWS - chassis.CenterOfMassPosition;
                chassis_velocity_at_contactPoint = chassis.GetVelocityInLocalPoint(relpos);
                float projVel = Vector3.Dot(raycastInfo.ContactNormalWS, chassis_velocity_at_contactPoint);
                if (project >= -0.1f)
                {
                    SuspensionRelativeVelocity = 0;
                    ClippedInvContactDotSuspension = 1.0f / 0.1f;
                }
                else
                {
                    float inv = -1.0f / project;
                    SuspensionRelativeVelocity = projVel * inv;
                    ClippedInvContactDotSuspension = inv;
                }

            }

            else    // Not in contact : position wheel in a nice (rest length) position
            {
                RaycastInfo.SuspensionLength = SuspensionRestLength;
                SuspensionRelativeVelocity = 0;
                RaycastInfo.ContactNormalWS = -raycastInfo.WheelDirectionWS;
                ClippedInvContactDotSuspension = 1.0f;
            }
        }
开发者ID:sinkingsugar,项目名称:BulletSharpPInvoke,代码行数:31,代码来源:WheelInfo.cs

示例2: ResolveSingleBilateral

        private void ResolveSingleBilateral(RigidBody body1, Vector3 pos1, RigidBody body2, Vector3 pos2, float distance, Vector3 normal, ref float impulse, float timeStep)
        {
            float normalLenSqr = normal.LengthSquared();
            Debug.Assert(Math.Abs(normalLenSqr) < 1.1f);
            if (normalLenSqr > 1.1f)
            {
                impulse = 0;
                return;
            }
            Vector3 rel_pos1 = pos1 - body1.CenterOfMassPosition;
            Vector3 rel_pos2 = pos2 - body2.CenterOfMassPosition;

            Vector3 vel1 = body1.GetVelocityInLocalPoint(rel_pos1);
            Vector3 vel2 = body2.GetVelocityInLocalPoint(rel_pos2);
            Vector3 vel = vel1 - vel2;

            Matrix world2A = body1.CenterOfMassTransform;
            world2A.Origin = Vector3.Zero;
            world2A = Matrix.Transpose(world2A);
            Matrix world2B = body2.CenterOfMassTransform;
            world2B.Origin = Vector3.Zero;
            world2B = Matrix.Transpose(world2B);
            Vector3 m_aJ = Vector3.TransformCoordinate(Vector3.Cross(rel_pos1, normal), world2A);
            Vector3 m_bJ = Vector3.TransformCoordinate(Vector3.Cross(rel_pos2, -normal), world2B);
            Vector3 m_0MinvJt = body1.InvInertiaDiagLocal * m_aJ;
            Vector3 m_1MinvJt = body2.InvInertiaDiagLocal * m_bJ;
            float jacDiagAB = body1.InvMass + Vector3.Dot(m_0MinvJt, m_aJ) + body2.InvMass + Vector3.Dot(m_1MinvJt, m_bJ);
            float jacDiagABInv = 1.0f / jacDiagAB;

            float rel_vel = Vector3.Dot(normal, vel);

            //todo: move this into proper structure
            const float contactDamping = 0.2f;

#if ONLY_USE_LINEAR_MASS
	        float massTerm = 1.0f / (body1.InvMass + body2.InvMass);
	        impulse = - contactDamping * rel_vel * massTerm;
#else
            float velocityImpulse = -contactDamping * rel_vel * jacDiagABInv;
            impulse = velocityImpulse;
#endif
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:42,代码来源:CustomVehicle.cs

示例3: CalcRollingFriction

        float CalcRollingFriction(RigidBody body0, RigidBody body1, Vector3 contactPosWorld, Vector3 frictionDirectionWorld, float maxImpulse)
        {
            float denom0 = body0.ComputeImpulseDenominator(contactPosWorld, frictionDirectionWorld);
            float denom1 = body1.ComputeImpulseDenominator(contactPosWorld, frictionDirectionWorld);
            const float relaxation = 1.0f;
            float jacDiagABInv = relaxation / (denom0 + denom1);

            float j1;

            Vector3 rel_pos1 = contactPosWorld - body0.CenterOfMassPosition;
            Vector3 rel_pos2 = contactPosWorld - body1.CenterOfMassPosition;

            Vector3 vel1 = body0.GetVelocityInLocalPoint(rel_pos1);
            Vector3 vel2 = body1.GetVelocityInLocalPoint(rel_pos2);
            Vector3 vel = vel1 - vel2;

            float vrel = Vector3.Dot(frictionDirectionWorld, vel);

            // calculate j that moves us to zero relative velocity
            j1 = -vrel * jacDiagABInv;
            j1 = Math.Min(j1, maxImpulse);
            j1 = Math.Max(j1, -maxImpulse);

            return j1;
        }
开发者ID:WebFreak001,项目名称:BulletSharp,代码行数:25,代码来源:CustomVehicle.cs


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