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


C# PhysicsActor.SubscribeEvents方法代码示例

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


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

示例1: UpdatePrimFlags


//.........这里部分代码省略.........
            else // Not phantom
            {
                RemFlag(PrimFlags.Phantom);

                PhysicsActor pa = PhysActor;
                if (pa == null)
                {
                    // It's not phantom anymore. So make sure the physics engine get's knowledge of it
                    PhysActor = m_parentGroup.Scene.PhysicsScene.AddPrimShape(
                        Name,
                        Shape,
                        AbsolutePosition,
                        Scale,
                        RotationOffset,
                        UsePhysics);

                    pa = PhysActor;
                    if (pa != null)
                    {
                        pa.LocalID = LocalId;
                        DoPhysicsPropertyUpdate(UsePhysics, true);
                        if (m_parentGroup != null)
                        {
                            if (!m_parentGroup.IsDeleted)
                            {
                                if (LocalId == m_parentGroup.RootPart.LocalId)
                                {
                                    m_parentGroup.CheckSculptAndLoad();
                                }
                            }
                        }
                        if (
                            ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
                            ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
                            ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
                            (CollisionSound != UUID.Zero)
                            )
                        {
                                PhysActor.OnCollisionUpdate += PhysicsCollision;
                                PhysActor.SubscribeEvents(1000);
                        }
                    }
                }
                else // it already has a physical representation
                {
                    pa.IsPhysical = UsePhysics;

                    DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. If it's phantom this will remove the prim
                    if (m_parentGroup != null)
                    {
                        if (!m_parentGroup.IsDeleted)
                        {
                            if (LocalId == m_parentGroup.RootPart.LocalId)
                            {
                                m_parentGroup.CheckSculptAndLoad();
                            }
                        }
                    }
                }
            }

            if (IsVD)
            {
                // If the above logic worked (this is urgent candidate to unit tests!)
                // we now have a physicsactor.
                // Defensive programming calls for a check here.
                // Better would be throwing an exception that could be catched by a unit test as the internal 
                // logic should make sure, this Physactor is always here.
                if (this.PhysActor != null)
                {
                    PhysActor.SetVolumeDetect(1);
                    AddFlag(PrimFlags.Phantom); // We set this flag also if VD is active
                    this.VolumeDetectActive = true;
                }
            }
            else
            {   // Remove VolumeDetect in any case. Note, it's safe to call SetVolumeDetect as often as you like
                // (mumbles, well, at least if you have infinte CPU powers :-))
                PhysicsActor pa = this.PhysActor;
                if (pa != null)
                {
                    PhysActor.SetVolumeDetect(0);
                }
                this.VolumeDetectActive = false;
            }


            if (IsTemporary)
            {
                AddFlag(PrimFlags.TemporaryOnRez);
            }
            else
            {
                RemFlag(PrimFlags.TemporaryOnRez);
            }
            //            m_log.Debug("Update:  PHY:" + UsePhysics.ToString() + ", T:" + IsTemporary.ToString() + ", PHA:" + IsPhantom.ToString() + " S:" + CastsShadows.ToString());

            ParentGroup.HasGroupChanged = true;
            ScheduleFullUpdate();
        }
开发者ID:intari,项目名称:OpenSimMirror,代码行数:101,代码来源:SceneObjectPart.cs

示例2: AddToPhysicalScene

        /// <summary>
        /// Adds a physical representation of the avatar to the Physics plugin
        /// </summary>
        public void AddToPhysicalScene(bool isFlying, bool AddAvHeightToPosition)
        {
            //Make sure we arn't already doing this
            if (m_creatingPhysicalRepresentation)
                return;

            //Set this so we don't do it multiple times
            m_creatingPhysicalRepresentation = true;

            IAvatarAppearanceModule appearance = RequestModuleInterface<IAvatarAppearanceModule> ();
            if (appearance != null)
            {
                if (appearance.Appearance.AvatarHeight == 0)
                    appearance.Appearance.SetHeight ();

                if (appearance.Appearance.AvatarHeight != 0)
                    m_avHeight = appearance.Appearance.AvatarHeight;
            }

            PhysicsScene scene = m_scene.PhysicsScene;

            Vector3 pVec = AbsolutePosition;

            if(AddAvHeightToPosition) //This is here so that after teleports, you arrive just slightly higher so that you don't fall through the ground/objects
                pVec.Z += m_avHeight;

            m_physicsActor = scene.AddAvatar(Name, pVec, Rotation,
                                                 new Vector3 (0f, 0f, m_avHeight), isFlying, LocalId);

            scene.AddPhysicsActorTaint(m_physicsActor);
            m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
            m_physicsActor.OnSignificantMovement += CheckForSignificantMovement;
            m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
            m_physicsActor.OnPositionAndVelocityUpdate += PhysicsUpdatePosAndVelocity;

            m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
            m_physicsActor.SubscribeEvents(500);
            m_physicsActor.Orientation = Rotation;

            //Tell any events about it
            if (OnAddPhysics != null)
                OnAddPhysics();

            //All done, reset this
            m_creatingPhysicalRepresentation = false;
        }
开发者ID:kow,项目名称:Aurora-Sim,代码行数:49,代码来源:ScenePresence.cs

示例3: AddToPhysicalScene

        /// <summary>
        /// Adds a physical representation of the avatar to the Physics plugin
        /// </summary>
        public void AddToPhysicalScene(bool isFlying)
        {
            if (m_appearance.AvatarHeight == 0)
                m_appearance.SetHeight();

            PhysicsScene scene = m_scene.PhysicsScene;

            Vector3 pVec = AbsolutePosition;

            // Old bug where the height was in centimeters instead of meters
            m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec,
                                                 new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying);

            scene.AddPhysicsActorTaint(m_physicsActor);
            //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
            m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
            m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
            m_physicsActor.SubscribeEvents(500);
            m_physicsActor.LocalID = LocalId;
        }
开发者ID:phantasmagoric,项目名称:InfiniteGrid-Opensim,代码行数:23,代码来源:ScenePresence.cs

示例4: AddToPhysicalScene

        /// <summary>
        /// Adds a physical representation of the avatar to the Physics plugin
        /// </summary>
        public void AddToPhysicalScene(bool isFlying)
        {
//            m_log.DebugFormat(
//                "[SCENE PRESENCE]: Adding physics actor for {0}, ifFlying = {1} in {2}",
//                Name, isFlying, Scene.RegionInfo.RegionName);

            if (m_appearance.AvatarHeight == 0)
                m_appearance.SetHeight();

            PhysicsScene scene = m_scene.PhysicsScene;

            Vector3 pVec = AbsolutePosition;

            // Old bug where the height was in centimeters instead of meters
            m_physicsActor = scene.AddAvatar(LocalId, Firstname + "." + Lastname, pVec,
                                                 new Vector3(0f, 0f, m_appearance.AvatarHeight), isFlying);

            scene.AddPhysicsActorTaint(m_physicsActor);
            //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients;
            m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
            m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
            m_physicsActor.SubscribeEvents(500);
            m_physicsActor.LocalID = LocalId;

            SetHeight(m_appearance.AvatarHeight);
        }
开发者ID:NovaGrid,项目名称:opensim,代码行数:29,代码来源:ScenePresence.cs


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