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


C# Manager.PhysicsJoint类代码示例

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


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

示例1: jointMoved

        // This callback allows the PhysicsScene to call back to its caller (the SceneGraph) and
        // update non-physical objects like the joint proxy objects that represent the position
        // of the joints in the scene.

        // This routine is normally called from within a lock (OdeLock) from within the OdePhysicsScene
        // WARNING: be careful of deadlocks here if you manipulate the scene. Remember you are being called
        // from within the OdePhysicsScene.

        protected internal void jointMoved(PhysicsJoint joint)
        {
            // m_parentScene.PhysicsScene.DumpJointInfo(); // non-thread-locked version; we should already be in a lock (OdeLock) when this callback is invoked
            SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene);
            if (jointProxyObject == null)
            {
                jointErrorMessage(joint, "WARNING, joint proxy not found, name " + joint.ObjectNameInScene);
                return;
            }

            // now update the joint proxy object in the scene to have the position of the joint as returned by the physics engine
            SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup
            if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy.
            jointProxyObject.Velocity = trackedBody.Velocity;
            jointProxyObject.AngularVelocity = trackedBody.AngularVelocity;
            switch (joint.Type)
            {
                case PhysicsJointType.Ball:
                    {
                        Vector3 jointAnchor = m_scene.PhysicsScene.GetJointAnchor(joint);
                        Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z);
                        jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos, true); // schedules the entire group for a terse update
                    }
                    break;

                case PhysicsJointType.Hinge:
                    {
                        Vector3 jointAnchor = m_scene.PhysicsScene.GetJointAnchor(joint);

                        // Normally, we would just ask the physics scene to return the axis for the joint.
                        // Unfortunately, ODE sometimes returns <0,0,0> for the joint axis, which should
                        // never occur. Therefore we cannot rely on ODE to always return a correct joint axis.
                        // Therefore the following call does not always work:
                        //PhysicsVector phyJointAxis = _PhyScene.GetJointAxis(joint);

                        // instead we compute the joint orientation by saving the original joint orientation
                        // relative to one of the jointed bodies, and applying this transformation
                        // to the current position of the jointed bodies (the tracked body) to compute the
                        // current joint orientation.

                        if (joint.TrackedBodyName == null)
                        {
                            jointErrorMessage(joint, "joint.TrackedBodyName is null, joint " + joint.ObjectNameInScene);
                        }

                        Vector3 proxyPos = new Vector3(jointAnchor.X, jointAnchor.Y, jointAnchor.Z);
                        Quaternion q = trackedBody.RotationOffset * joint.LocalRotation;

                        jointProxyObject.ParentGroup.UpdateGroupPosition(proxyPos, true); // schedules the entire group for a terse update
                        jointProxyObject.ParentGroup.UpdateGroupRotationR(q); // schedules the entire group for a terse update
                    }
                    break;
            }
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:62,代码来源:NinjaPhysicsModule.cs

示例2: jointErrorMessage

        // This callback allows the PhysicsScene to call back to its caller (the SceneGraph) and
        // alert the user of errors by using the debug channel in the same way that scripts alert
        // the user of compile errors.

        // This routine is normally called from within a lock (OdeLock) from within the OdePhysicsScene
        // WARNING: be careful of deadlocks here if you manipulate the scene. Remember you are being called
        // from within the OdePhysicsScene.
        public void jointErrorMessage(PhysicsJoint joint, string message)
        {
            if (joint != null)
            {
                if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
                    return;

                SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene);
                if (jointProxyObject != null)
                {
                    SimChat(Utils.StringToBytes("[NINJA]: " + message),
                        ChatTypeEnum.DebugChannel,
                        2147483647,
                        jointProxyObject.AbsolutePosition,
                        jointProxyObject.Name,
                        jointProxyObject.UUID,
                        false);

                    joint.ErrorMessageCount++;

                    if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
                    {
                        SimChat(Utils.StringToBytes("[NINJA]: Too many messages for this joint, suppressing further messages."),
                            ChatTypeEnum.DebugChannel,
                            2147483647,
                            jointProxyObject.AbsolutePosition,
                            jointProxyObject.Name,
                            jointProxyObject.UUID,
                            false);
                    }
                }
                else
                {
                    // couldn't find the joint proxy object; the error message is silently suppressed
                }
            }
        }
开发者ID:CCIR,项目名称:opensim,代码行数:44,代码来源:Scene.cs

示例3: jointDeactivated

        // This callback allows the PhysicsScene to call back to its caller (the SceneGraph) and
        // update non-physical objects like the joint proxy objects that represent the position
        // of the joints in the scene.

        // This routine is normally called from within a lock (OdeLock) from within the OdePhysicsScene
        // WARNING: be careful of deadlocks here if you manipulate the scene. Remember you are being called
        // from within the OdePhysicsScene.
        protected internal void jointDeactivated(PhysicsJoint joint)
        {
            //m_log.Debug("[NINJA] SceneGraph.jointDeactivated, joint:" + joint.ObjectNameInScene);
            SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene);
            if (jointProxyObject == null)
            {
                jointErrorMessage(joint, "WARNING, trying to deactivate (stop interpolation of) joint proxy, but not found, name " + joint.ObjectNameInScene);
                return;
            }

            // turn the proxy non-physical, which also stops its client-side interpolation
            bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0);
            if (wasUsingPhysics)
            {
                jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock
            }
        }
开发者ID:CCIR,项目名称:opensim,代码行数:24,代码来源:Scene.cs

示例4: GetJointAxis

 public virtual Vector3 GetJointAxis(PhysicsJoint joint)
 { return Vector3.Zero; }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:2,代码来源:PhysicsScene.cs

示例5: jointErrorMessage

        // This callback allows the PhysicsScene to call back to its caller (the SceneGraph) and
        // alert the user of errors by using the debug channel in the same way that scripts alert
        // the user of compile errors.

        // This routine is normally called from within a lock (OdeLock) from within the OdePhysicsScene
        // WARNING: be careful of deadlocks here if you manipulate the scene. Remember you are being called
        // from within the OdePhysicsScene.
        public void jointErrorMessage(PhysicsJoint joint, string message)
        {
            if (joint != null)
            {
                if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
                    return;

                SceneObjectPart jointProxyObject = GetSceneObjectPart(joint.ObjectNameInScene);
                if (jointProxyObject != null)
                {
                    IChatModule chatModule = m_scene.RequestModuleInterface<IChatModule>();
                    if (chatModule != null)
                        chatModule.SimChat("[NINJA]: " + message,
                        ChatTypeEnum.DebugChannel,
                        2147483647,
                        jointProxyObject.AbsolutePosition,
                        jointProxyObject.Name,
                        jointProxyObject.UUID,
                        false, m_scene);

                    joint.ErrorMessageCount++;

                    if (joint.ErrorMessageCount > PhysicsJoint.maxErrorMessages)
                    {
                        if (chatModule != null)
                            chatModule.SimChat("[NINJA]: Too many messages for this joint, suppressing further messages.",
                            ChatTypeEnum.DebugChannel,
                            2147483647,
                            jointProxyObject.AbsolutePosition,
                            jointProxyObject.Name,
                            jointProxyObject.UUID,
                            false, m_scene);
                    }
                }
                else
                {
                    // couldn't find the joint proxy object; the error message is silently suppressed
                }
            }
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:47,代码来源:NinjaPhysicsModule.cs

示例6: DoJointDeactivated

 protected virtual void DoJointDeactivated(PhysicsJoint joint)
 {
     // We need this to allow subclasses (but not other classes) to invoke the event; C# does
     // not allow subclasses to invoke the parent class event.
     if (OnJointDeactivated != null)
     {
         OnJointDeactivated(joint);
     }
 }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:9,代码来源:PhysicsScene.cs

示例7: DoJointErrorMessage

 protected virtual void DoJointErrorMessage(PhysicsJoint joint, string message)
 {
     // We need this to allow subclasses (but not other classes) to invoke the event; C# does
     // not allow subclasses to invoke the parent class event.
     if (OnJointErrorMessage != null)
     {
         OnJointErrorMessage(joint, message);
     }
 }
开发者ID:AlphaStaxLLC,项目名称:taiga,代码行数:9,代码来源:PhysicsScene.cs

示例8: InternalRemoveActiveJoint

 // internal utility function: must be called within a lock (OdeLock)
 private void InternalRemoveActiveJoint(PhysicsJoint joint)
 {
     activeJoints.Remove(joint);
     SOPName_to_activeJoint.Remove(joint.ObjectNameInScene);
 }
开发者ID:UbitUmarov,项目名称:Ubit-opensim,代码行数:6,代码来源:OdeScene.cs

示例9: GetJointAxis

        /// <summary>
        /// Get joint axis.
        /// </summary>
        /// <remarks>
        /// normally called from within OnJointMoved, which is called from within a lock (OdeLock)
        /// WARNING: ODE sometimes returns <0,0,0> as the joint axis! Therefore this function
        /// appears to be unreliable. Fortunately we can compute the joint axis ourselves by
        /// keeping track of the joint's original orientation relative to one of the involved bodies.
        /// </remarks>
        /// <param name="joint"></param>
        /// <returns></returns>
        public override Vector3 GetJointAxis(PhysicsJoint joint)
        {
            Debug.Assert(joint.IsInPhysicsEngine);
            d.Vector3 axis = new d.Vector3();

            if (!(joint is OdePhysicsJoint))
            {
                DoJointErrorMessage(joint, "warning: non-ODE joint requesting anchor: " + joint.ObjectNameInScene);
            }
            else
            {
                OdePhysicsJoint odeJoint = (OdePhysicsJoint)joint;
                switch (odeJoint.Type)
                {
                    case PhysicsJointType.Ball:
                        DoJointErrorMessage(joint, "warning - axis requested for ball joint: " + joint.ObjectNameInScene);
                        break;
                    case PhysicsJointType.Hinge:
                        d.JointGetHingeAxis(odeJoint.jointID, out axis);
                        break;
                }
            }
            return new Vector3(axis.X, axis.Y, axis.Z);
        }
开发者ID:UbitUmarov,项目名称:Ubit-opensim,代码行数:35,代码来源:OdeScene.cs

示例10: InternalRemovePendingJoint

 // internal utility function: must be called within a lock (OdeLock)
 private void InternalRemovePendingJoint(PhysicsJoint joint)
 {
     pendingJoints.Remove(joint);
     SOPName_to_pendingJoint.Remove(joint.ObjectNameInScene);
 }
开发者ID:UbitUmarov,项目名称:Ubit-opensim,代码行数:6,代码来源:OdeScene.cs

示例11: InternalAddActiveJoint

 // internal utility function: must be called within a lock (OdeLock)
 private void InternalAddActiveJoint(PhysicsJoint joint)
 {
     activeJoints.Add(joint);
     SOPName_to_activeJoint.Add(joint.ObjectNameInScene, joint);
 }
开发者ID:UbitUmarov,项目名称:Ubit-opensim,代码行数:6,代码来源:OdeScene.cs

示例12: GetJointAnchor

        // normally called from within OnJointMoved, which is called from within a lock (OdeLock)
        public override Vector3 GetJointAnchor(PhysicsJoint joint)
        {
            Debug.Assert(joint.IsInPhysicsEngine);
            d.Vector3 pos = new d.Vector3();

            if (!(joint is AuroraODEPhysicsJoint))
            {
                DoJointErrorMessage(joint, "warning: non-ODE joint requesting anchor: " + joint.ObjectNameInScene);
            }
            else
            {
                AuroraODEPhysicsJoint odeJoint = (AuroraODEPhysicsJoint)joint;
                switch (odeJoint.Type)
                {
                    case PhysicsJointType.Ball:
                        d.JointGetBallAnchor(odeJoint.jointID, out pos);
                        break;
                    case PhysicsJointType.Hinge:
                        d.JointGetHingeAnchor(odeJoint.jointID, out pos);
                        break;
                }
            }
            return new Vector3((float)pos.X, (float)pos.Y, (float)pos.Z);
        }
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:25,代码来源:AODEPhysicsScene.cs

示例13: GetJointAxis

 public virtual PhysicsVector GetJointAxis(PhysicsJoint joint)
 { return null; }
开发者ID:Ideia-Boa,项目名称:diva-distribution,代码行数:2,代码来源:PhysicsScene.cs

示例14: GetJointAxis

 public virtual OpenMetaverse.Vector3 GetJointAxis(PhysicsJoint joint)
 { return OpenMetaverse.Vector3.Zero; }
开发者ID:zwagoth,项目名称:halcyon,代码行数:2,代码来源:PhysicsScene.cs


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