Example #1
0
        public static MatrixFrame ReadMatrixFrameFromPacket(ref bool bufferReadValid)
        {
            Vec3        o             = GameNetworkMessage.ReadVec3FromPacket(CompressionBasic.PositionCompressionInfo, ref bufferReadValid);
            Vec3        scalingVector = GameNetworkMessage.ReadVec3FromPacket(CompressionBasic.ScaleCompressionInfo, ref bufferReadValid);
            MatrixFrame matrixFrame   = new MatrixFrame(GameNetworkMessage.ReadRotationMatrixFromPacket(ref bufferReadValid), o);

            matrixFrame.Scale(scalingVector);
            return(matrixFrame);
        }
Example #2
0
        public static void WriteMatrixFrameToPacket(MatrixFrame frame)
        {
            Vec3        scaleVector = frame.rotation.GetScaleVector();
            MatrixFrame matrixFrame = frame;

            matrixFrame.Scale(new Vec3(1f / scaleVector.x, 1f / scaleVector.y, 1f / scaleVector.z));
            GameNetworkMessage.WriteVec3ToPacket(matrixFrame.origin, CompressionBasic.PositionCompressionInfo);
            GameNetworkMessage.WriteVec3ToPacket(scaleVector, CompressionBasic.ScaleCompressionInfo);
            GameNetworkMessage.WriteRotationMatrixToPacket(matrixFrame.rotation);
        }
Example #3
0
        protected override void OnWrite()
        {
            Vec3        scaleVector = this.Frame.rotation.GetScaleVector();
            MatrixFrame frame       = this.Frame;

            frame.Scale(new Vec3(1f / scaleVector.x, 1f / scaleVector.y, 1f / scaleVector.z));
            GameNetworkMessage.WriteMissionObjectReferenceToPacket(this.MissionObject);
            GameNetworkMessage.WriteVec3ToPacket(frame.rotation.f, CompressionBasic.UnitVectorCompressionInfo);
            GameNetworkMessage.WriteVec3ToPacket(frame.rotation.s, CompressionBasic.UnitVectorCompressionInfo);
            GameNetworkMessage.WriteVec3ToPacket(frame.rotation.u, CompressionBasic.UnitVectorCompressionInfo);
            GameNetworkMessage.WriteVec3ToPacket(scaleVector, CompressionBasic.ScaleCompressionInfo);
            GameNetworkMessage.WriteVec3ToPacket(frame.origin, CompressionBasic.PositionCompressionInfo);
        }
Example #4
0
        protected internal override void OnTick(float dt)
        {
            if ((double)dt == 0.0)
            {
                return;
            }
            MatrixFrame globalFrame = this.GameEntity.GetGlobalFrame();
            MetaMesh    metaMesh    = this.GameEntity.GetMetaMesh(0);

            if ((NativeObject)metaMesh == (NativeObject)null)
            {
                return;
            }
            Vec3 vec3_1 = globalFrame.origin - this._prevFlagMeshFrame;

            vec3_1.x /= dt;
            vec3_1.y /= dt;
            vec3_1.z /= dt;
            Vec3 vec3_2 = new Vec3(20f, z: -10f) * 0.1f - vec3_1;

            if ((double)vec3_2.LengthSquared < 9.99999993922529E-09)
            {
                return;
            }
            Vec3 local = globalFrame.rotation.TransformToLocal(vec3_2);

            local.z = 0.0f;
            double num1  = (double)local.Normalize();
            float  theta = (float)Math.Atan2((double)local.y, (double)local.x);

            this.SmoothTheta(ref theta, dt);
            Vec3        scaleVector = metaMesh.Frame.rotation.GetScaleVector();
            MatrixFrame identity    = MatrixFrame.Identity;

            identity.Scale(scaleVector);
            identity.rotation.RotateAboutUp(theta);
            this._prevTheta = theta;
            float num2 = this._prevSkew + Math.Min((float)Math.Acos((double)Vec3.DotProduct(vec3_2, globalFrame.rotation.u) / (double)vec3_2.Length) - this._prevSkew, 150f * dt) * 0.05f;

            this._prevSkew = num2;
            float num3 = MBMath.ClampFloat(vec3_2.Length, 1f / 1000f, 10000f);

            this._time             += (float)((double)dt * (double)num3 * 0.5);
            metaMesh.Frame          = identity;
            metaMesh.VectorUserData = new Vec3((float)Math.Cos((double)num2), 1f - (float)Math.Sin((double)num2), w: this._time);
            this._prevFlagMeshFrame = globalFrame.origin;
        }
        private void UpdateIndicatorDecal()
        {
            if (GameNetwork.IsDedicatedServer)
            {
                return;
            }
            this._distanceIndicator = this.GameEntity.GetChildren().SingleOrDefault <GameEntity>((Func <GameEntity, bool>)(q => q.HasTag("interaction_decal_mesh")));
            if (!((NativeObject)this._distanceIndicator != (NativeObject)null))
            {
                return;
            }
            MatrixFrame localFrame = this._distanceIndicator.GetFirstMesh().GetLocalFrame();

            localFrame.Scale(new Vec3(this.InteractionDistance, this.InteractionDistance, 1f));
            localFrame.origin += new Vec3(y: this.InteractionDistance);
            this._distanceIndicator.GetFirstMesh().SetLocalFrame(localFrame);
            this._distanceIndicator.SetBoundingboxDirty();
            this.GameEntity.SetBoundingboxDirty();
        }
Example #6
0
        public void Init(
            Vec3 startingPosition,
            Vec3 startingVelocity,
            float simulationTime,
            float pointCount)
        {
            this.trajectoryPointList.Clear();
            this.collisionEntity = new GameEntity[0];
            for (int index = 0; index < this.collisionEntity.Length; ++index)
            {
                this.collisionEntity[index] = GameEntity.Instantiate(this._scene, "trajectory_entity", true);
                this.collisionEntity[index].SetMobility(GameEntity.Mobility.dynamic);
                MatrixFrame frame = this.collisionEntity[index].GetFrame();
                frame.Scale(new Vec3(2f, 2f, 2f));
                this.collisionEntity[index].SetFrame(ref frame);
                this.collisionEntity[index].EntityFlags |= EntityFlags.NonModifiableFromEditor;
                this.collisionEntity[index].EntityFlags |= EntityFlags.DontSaveToScene;
                this.collisionEntity[index].EntityFlags |= EntityFlags.DoesNotAffectParentsLocalBb;
                this.collisionEntity[index].EntityFlags |= EntityFlags.NotAffectedBySeason;
            }
            float num1 = simulationTime / pointCount;

            for (float num2 = 0.0f; (double)num2 < (double)simulationTime && (double)this.trajectoryPointList.Count < (double)pointCount; num2 += num1)
            {
                Vec3       vec3_1     = startingVelocity + MBGlobals.GravityVec3 * num2;
                Vec3       vec3_2     = startingPosition + vec3_1 * num2;
                GameEntity gameEntity = GameEntity.Instantiate(this._scene, "trajectory_entity", true);
                gameEntity.SetMobility(GameEntity.Mobility.dynamic);
                gameEntity.EntityFlags |= EntityFlags.NonModifiableFromEditor;
                gameEntity.EntityFlags |= EntityFlags.DontSaveToScene;
                gameEntity.EntityFlags |= EntityFlags.DoesNotAffectParentsLocalBb;
                gameEntity.EntityFlags |= EntityFlags.NotAffectedBySeason;
                MatrixFrame frame = gameEntity.GetFrame();
                frame.origin = vec3_2;
                gameEntity.SetFrame(ref frame);
                this.trajectoryPointList.Add(gameEntity);
            }
        }