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


C# BitStream.WriteNormalizedSignedVector3方法代码示例

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


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

示例1: Serialize

        public override void Serialize(BitStream stream, MyClientStateBase forClient, byte packetId, int maxBitPosition)
        {
            base.Serialize(stream, forClient, packetId, maxBitPosition);

            if (stream.Writing)
            {
                stream.WriteHalf(Entity.Physics.LinearVelocity.Length());
                // Head and spine stuff, 36 - 152b (4.5B - 19 B)
                stream.WriteHalf(Entity.HeadLocalXAngle); // 2B
                stream.WriteHalf(Entity.HeadLocalYAngle); // 2B

                // TODO: Spine has only one angle (bending forward backward)
                // Getting EULER angles from Matrix seems good way to get it (z-component)
                stream.WriteQuaternionNormCompressedIdentity(Entity.GetAdditionalRotation(Entity.Definition.SpineBone)); // 1b / 30b
                stream.WriteQuaternionNormCompressedIdentity(Entity.GetAdditionalRotation(Entity.Definition.HeadBone)); // 1b / 30b

                // Movement state, 2B
                stream.WriteUInt16((ushort)Entity.GetCurrentMovementState());
                // Movement flag.
                stream.WriteUInt16((ushort)Entity.MovementFlags);

                // Flags, 6 bits
                bool hasJetpack = Entity.JetpackComp != null;
                stream.WriteBool(hasJetpack ? Entity.JetpackComp.TurnedOn : false);
                stream.WriteBool(hasJetpack ? Entity.JetpackComp.DampenersTurnedOn : false);
                stream.WriteBool(Entity.LightEnabled); // TODO: Remove
                stream.WriteBool(Entity.ZoomMode == MyZoomModeEnum.IronSight);
                stream.WriteBool(Entity.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove
                stream.WriteBool(Entity.TargetFromCamera);

                stream.WriteNormalizedSignedVector3(Entity.MoveIndicator, 8);

                if (MyFakes.CHARACTER_SERVER_SYNC)
                {
                    Vector2 rotation = Entity.RotationIndicator;
                    stream.WriteHalf(rotation.X);
                    stream.WriteHalf(rotation.Y);

                    stream.WriteHalf(Entity.RollIndicator);

                }

            }
            else
            {
                Vector3 move;
                MyCharacterNetState charNetState = ReadCharacterState(stream, out move);


                if (MyFakes.CHARACTER_SERVER_SYNC)
                {
                    charNetState.Rotation.X = stream.ReadHalf();
                    charNetState.Rotation.Y = stream.ReadHalf();
                    charNetState.Roll = stream.ReadHalf();
                }

                if (!IsControlledLocally && !Entity.Closed)
                {
                    Entity.SetStateFromNetwork(ref charNetState);
                    Entity.MoveIndicator = move;
                }             
            }
        }
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:63,代码来源:MyCharacterPhysicsStateGroup.cs

示例2: Serialize

        public override bool Serialize(BitStream stream, EndpointId forClient,uint timeStamp, byte packetId, int maxBitPosition)
        {
            base.Serialize(stream, forClient,timeStamp, packetId, maxBitPosition);

            if (stream.Writing)
            {
                // Head and spine stuff, 36 - 152b (4.5B - 19 B)
                stream.WriteHalf(Entity.HeadLocalXAngle); // 2B
                stream.WriteHalf(Entity.HeadLocalYAngle); // 2B

                // TODO: Spine has only one angle (bending forward backward)
                // Getting EULER angles from Matrix seems good way to get it (z-component)
                stream.WriteQuaternionNormCompressedIdentity(Entity.GetAdditionalRotation(Entity.Definition.SpineBone)); // 1b / 30b
                stream.WriteQuaternionNormCompressedIdentity(Entity.GetAdditionalRotation(Entity.Definition.HeadBone)); // 1b / 30b

                // Movement state, 2B
                stream.WriteUInt16((ushort)Entity.GetCurrentMovementState());
                // Movement flag.
                stream.WriteUInt16((ushort)Entity.MovementFlags);

                // Flags, 6 bits
                bool hasJetpack = Entity.JetpackComp != null;
                stream.WriteBool(hasJetpack ? Entity.JetpackComp.TurnedOn : false);
                stream.WriteBool(hasJetpack ? Entity.JetpackComp.DampenersTurnedOn : false);
                stream.WriteBool(Entity.LightEnabled); // TODO: Remove
                stream.WriteBool(Entity.ZoomMode == MyZoomModeEnum.IronSight);
                stream.WriteBool(Entity.RadioBroadcaster.WantsToBeEnabled); // TODO: Remove
                stream.WriteBool(Entity.TargetFromCamera);

                stream.WriteNormalizedSignedVector3(Entity.MoveIndicator, 8);

                float speed = Entity.Physics.CharacterProxy != null ? Entity.Physics.CharacterProxy.Speed : 0.0f;
                stream.WriteFloat(speed);

                stream.WriteFloat(Entity.RotationIndicator.X);
                stream.WriteFloat(Entity.RotationIndicator.Y);
                stream.WriteFloat(Entity.RollIndicator);

            }
            else
            {
                Vector3 move;
                MyCharacterNetState charNetState = ReadCharacterState(stream);

                if (!IsControlledLocally && !Entity.Closed)
                {
                   Entity.SetStateFromNetwork(ref charNetState);
                }
            }
            return true;
        }
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:51,代码来源:MyCharacterPhysicsStateGroup.cs


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