Exemplo n.º 1
0
            public override bool getNextTarget(
                ref ArmCursor offset, ref Collection <Key> keysDown, ref Collection <Key> keysToggle, float stepAmount, out ComData msg)
            {
                Vector3 dPos = Vector3.Zero;
                Vector3 dDir = Vector3.Zero;   // just for storing dRotation angles

                if (keysDown.Contains(Key.A))
                {
                    dPos.X += -1;
                }
                if (keysDown.Contains(Key.D))
                {
                    dPos.X += 1;
                }
                if (keysDown.Contains(Key.S))
                {
                    dPos.Y += -1;
                }
                if (keysDown.Contains(Key.W))
                {
                    dPos.Y += 1;
                }
                if (keysDown.Contains(Key.C))
                {
                    dPos.Z += -1;
                }
                if (keysDown.Contains(Key.Z))
                {
                    dPos.Z += 1;
                }

                // acting as temp rotation vector
                if (keysDown.Contains(Key.J))
                {
                    dDir.Y += -1;
                }
                if (keysDown.Contains(Key.L))
                {
                    dDir.Y += 1;
                }
                if (keysDown.Contains(Key.I))
                {
                    dDir.X += -1;
                }
                if (keysDown.Contains(Key.K))
                {
                    dDir.X += 1;
                }
                if (keysDown.Contains(Key.M))
                {
                    dDir.Z += -1;
                }
                if (keysDown.Contains(Key.OemPeriod))
                {
                    dDir.Z += 1;
                }

                if (dPos == Vector3.Zero && dDir == Vector3.Zero)
                {
                    msg = null;
                    return(false);
                }

                dPos = dPos.LengthSquared() != 0 ? Vector3.Normalize(dPos) * stepAmount * CTrans : dPos;
                dDir = dDir.LengthSquared() != 0 ? Vector3.Normalize(dDir) * stepAmount * CRot : dDir;

                Quaternion q = Quaternion.CreateFromYawPitchRoll(dDir.Y, dDir.X, dDir.Z);

                q *= offset.Dir;

                offset.Set(offset.Pos + dPos, q);

                msg = new ComData(new KeyFrame(offset, Time.Now()));
                if (VERBOSE)
                {
                    Console.WriteLine("Cursor: \n{0}\n", offset.ToString());
                }
                return(true);
            }
Exemplo n.º 2
0
        private static bool t(char key, ref ArmCursor target)
        {
            const float CTrans = 1;
            const float CRot   = (float)Math.PI / 12;

            Vector3 dPos = Vector3.Zero;
            Vector3 dDir = Vector3.Zero;   // just for storing dRotation angles

            if (key == 'A')
            {
                dPos.X += -1;
            }
            if (key == 'D')
            {
                dPos.X += 1;
            }
            if (key == 'S')
            {
                dPos.Y += -1;
            }
            if (key == 'W')
            {
                dPos.Y += 1;
            }
            if (key == 'C')
            {
                dPos.Z += -1;
            }
            if (key == 'Z')
            {
                dPos.Z += 1;
            }

            // acting as temp rotation vector
            if (key == 'J')
            {
                dDir.Y += -1;
            }
            if (key == 'L')
            {
                dDir.Y += 1;
            }
            if (key == 'I')
            {
                dDir.X += -1;
            }
            if (key == 'K')
            {
                dDir.X += 1;
            }
            if (key == 'M')
            {
                dDir.Z += -1;
            }
            if (key == 'N')
            {
                dDir.Z += 1;
            }

            if (dPos == Vector3.Zero && dDir == Vector3.Zero)
            {
                return(false);
            }

            dPos = dPos.LengthSquared() != 0 ? Vector3.Normalize(dPos) * CTrans : dPos;
            dDir = dDir.LengthSquared() != 0 ? Vector3.Normalize(dDir) * CRot : dDir;

            Quaternion q = Quaternion.CreateFromYawPitchRoll(dDir.Y, dDir.X, dDir.Z);

            q *= target.Dir;
            target.Set(target.Pos + dPos, q);

            return(true);
        }