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


C# MyEntity.GetWorldRotation方法代码示例

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


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

示例1: MoveAndRotateObject

        /// <summary>
        /// Moves and Rotates entity
        /// </summary>
        /// <param name="newPosition"></param>
        /// <param name="newOrientation"></param>
        /// <param name="entity"></param>
        public static void MoveAndRotateObject(Vector3 newPosition, Matrix newOrientation, MyEntity entity)
        {
            BoundingSphere sphere = new BoundingSphere(newPosition + entity.LocalVolumeOffset, entity.WorldVolume.Radius);

            if (MyMwcSectorConstants.SECTOR_SIZE_FOR_PHYS_OBJECTS_BOUNDING_BOX.Contains(sphere) == MinerWarsMath.ContainmentType.Contains)
            {
                Matrix entityBeforeMoveOrientation = entity.GetWorldRotation();
                Vector3 entityBeforeMovePosition = entity.GetPosition();

                if (entityBeforeMovePosition != newPosition || entityBeforeMoveOrientation != newOrientation)
                {
                    // Move object
                    bool moveSuccesfull = entity.MoveAndRotate(newPosition, newOrientation);
                    Vector3 currentPosition = entity.GetPosition();
                    Matrix currentOrientation = entity.GetWorldRotation();

                    if (moveSuccesfull)
                    {
                        //entity.UpdateWorldMatrix();
                        //  Play movement or rotation sounds
                        if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_delayMovementSoundInMillis)
                        {
                            if (entityBeforeMovePosition != currentPosition)
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveStep);
                            }

                            if (entityBeforeMoveOrientation != currentOrientation)
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectRotateStep);
                            }

                            m_delayMovementSoundInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyEditorConstants.DELAY_OBJECT_MOVEMENT_SOUND_IN_MILLIS;
                        }

                        MyEditor.Static.RecheckAllColidingEntitesAndClearNonColiding();//check all coliding entites to see if any went out of collision state
                        
                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("CheckAllCollidingObjectsForEntity");

                        // This was taking up to 170ms for 800 prefabs, so its replaced by void CheckCollisions(IEnumerable<MyEntity> entities) in HandleInput().
                        //MyEditor.Static.CheckAllCollidingObjectsForEntity(entity);//check all colliding state of entity after move

                        //MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); 
                    }
                    else
                    {
                        if (MyMinerGame.TotalGamePlayTimeInMilliseconds > m_delayMovementSoundInMillis)
                        {
                            if ((entityBeforeMovePosition != currentPosition) || (entityBeforeMoveOrientation != currentOrientation))
                            {
                                MyAudio.AddCue2D(MySoundCuesEnum.GuiEditorObjectMoveInvalid);
                                m_delayMovementSoundInMillis = MyMinerGame.TotalGamePlayTimeInMilliseconds + 1000;
                            }
                        }
                    }

                }
            }
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:65,代码来源:MyEditorGizmo.cs

示例2: GetRotationAndPosition

        /// <summary>
        /// This method calculates new object position when its being rotated - in case only one object is selected and rotated
        /// only rotation is changed, but for multiple selected object, rotation is calculated based on the objects selected center
        /// </summary>
        static void GetRotationAndPosition(MyEntity entity, Matrix rotation, out Vector3 newPosition, out Matrix newRotation)
        {
            Matrix entityOrientation = entity.GetWorldRotation();
            Vector3 entityPosition = entity.GetPosition();
            Vector3 gizmoPosition = Position;

            if (ActivePivot == PivotType.OBJECT_CENTER)
            {
                //gizmoPosition = entityPosition;
            }

            Matrix localRot = Matrix.Identity;
            localRot.Forward = entityOrientation.Forward;
            localRot.Up = entityOrientation.Up;
            localRot.Right = entityOrientation.Right;
            m_localRight = MyMwcUtils.Normalize(m_localRight);
            localRot.Translation = entityPosition - gizmoPosition;

            Matrix rot = localRot * rotation;
            newPosition = rot.Translation + gizmoPosition;
            entityOrientation.Forward = rot.Forward;
            entityOrientation.Up = rot.Up;
            entityOrientation.Right = rot.Right;
            entityOrientation.Translation = Vector3.Zero;
            newRotation = entityOrientation;
        }
开发者ID:Bunni,项目名称:Miner-Wars-2081,代码行数:30,代码来源:MyEditorGizmo.cs


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