Ejemplo n.º 1
0
        static public axis fromJson(string json)
        {
            if (jsonParser == null)
            {
                jsonParser = new Regex("\"input\": \"(.*)\",.*" +
                                       "\"key\": \"(.*)\",.*" +
                                       "\"type\": \"(.*)\",.*" +
                                       "\"isKey\": \"(.*)\",.*" +
                                       "\"name\": \"(.*)\",.*" +
                                       "\"rest\": \"(.*)\"");
            }
            MatchCollection matches = jsonParser.Matches(json);
            GroupCollection groups  = matches[0].Groups;

            string   input  = groups[1].Value;
            int      ikey   = Int32.Parse(groups[2].Value);
            KeyCode  key    = (KeyCode)ikey;
            int      itype  = Int32.Parse(groups[3].Value);
            axisType type   = (axisType)itype;
            int      iIsKey = Int32.Parse(groups[4].Value);
            bool     isKey  = (iIsKey != 0);
            string   name   = groups[5].Value;
            float    rest   = float.Parse(groups[6].Value, CultureInfo.InvariantCulture);

            axis a = new axis();

            a.input = input;
            a.key   = key;
            a.type  = type;
            a.isKey = isKey;
            a.name  = name;
            a.rest  = rest;
            return(a);
        }
Ejemplo n.º 2
0
        private double pixToData(int pix, axis ax)
        {
            double val = 0;

            switch (ax)
            {
            case axis.X:
                val = minX + scaleX / pixUsedwidth * (pix - Math.Abs(Width * MarginGraph));
                break;

            case axis.Y:
                // __Marco: I had to fix this,
                // as it gave back wrong data for some values (2009-03-12)
                double innerVal =
                    (pix + Math.Abs(Height * MarginGraph) - Height * heightPercent2)
                    * scaleY / pixUsedheight;
                // next line is a fix for Windows 7
                int innerValSign = Math.Sign(pix + Math.Abs(Height * MarginGraph) - Height * heightPercent2);
                val = -(innerVal + minY * innerValSign);
                break;
            }


            return(val);
        }
Ejemplo n.º 3
0
 public void setCENTER(axis p)
 {
     CENTRAL_POINT.x = p.x;
     CENTRAL_POINT.y = p.y;
     point[0].x      = p.x;
     point[0].y      = p.y;
 }
Ejemplo n.º 4
0
 public Generator2(float distance, float radius, axis a, string output = "sounds/default/")
 {
     this.distance = distance;
     this.radius   = radius;
     this.axis     = a;
     this.output   = output;
 }
 private void Awake()
 {
     cam             = Camera.main.transform;
     player          = GameObject.FindGameObjectWithTag("Player").transform;
     gravity         = FindObjectOfType <Gravity>();
     gravity.enabled = false; //make sure player can't move before cam is centered on him
     hiddenVelocity  = Vector3.zero;
     axisToFollow    = axis.Neither;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Checks for intersection with a given mouse point. Pass the results from a call to System.Windows.Forms.MouseEventArgs()
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        /// <param name="mat">The mat.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public axis checkForIntersection(MouseEventArgs e, Matrix mat)
        {
            List <int> temp = new List <int>();

            temp = MeshPick(e.X, e.Y, this.gizmo, mat);
            if (temp.Count > 0)
            {
                switch (temp[0])
                {
                case 0:
                case 3:
                    this.selectedAxis = axis.X;
                    break;

                case 1:
                case 4:
                    this.selectedAxis = axis.Y;
                    break;

                case 2:
                case 5:
                    this.selectedAxis = axis.Z;
                    break;

                case 6:
                    this.selectedAxis = axis.XY;
                    break;

                case 7:
                    this.selectedAxis = axis.YZ;
                    break;

                case 8:
                    this.selectedAxis = axis.XZ;
                    break;

                default:
                    this.selectedAxis = axis.none;
                    break;
                }
            }
            else
            {
                this.selectedAxis = axis.none;
            }

            /*
             * for (int x = 0; x < this.gizmo.Count; x++)
             * {
             *  //check bitmask for object visibility
             *
             *      // Check under mouse cursor for object selection/deselection?
             *  }
             * }
             */
            return(this.selectedAxis);
        }
Ejemplo n.º 7
0
 static void AddInput(axis k, string s)
 {
     switch (s) {
         case "axisX":  axisX.f	+= k.f; break;
         case "axisY":  axisY.f  += k.f; break;
         case "mouseX": mouseX.f += k.f; break;
         case "mouseY": mouseY.f += k.f; break;
         case "roll":   roll.f   += k.f; break;
     }
 }
Ejemplo n.º 8
0
        public static double ConvertPwmtoAngle(axis axis)
        {
            int pwmvalue = -1;

            if (!comPort.MAV.param.ContainsKey("RC" + yawchannel + "_MIN"))
            {
                return(0);
            }

            switch (axis)
            {
            case GimbalPoint.axis.roll:
                pwmvalue = channelpwm(rollchannel);
                float minr    = (float)comPort.MAV.param["RC" + rollchannel + "_MIN"];
                float maxr    = (float)comPort.MAV.param["RC" + rollchannel + "_MAX"];
                float minroll = (float)comPort.MAV.param["MNT_ANGMIN_ROL"];
                float maxroll = (float)comPort.MAV.param["MNT_ANGMAX_ROL"];
                float revr    = comPort.MAV.param.ContainsKey("RC" + rollchannel + "_REV")
                        ? (float)comPort.MAV.param["RC" + rollchannel + "_REV"]
                        : (float)comPort.MAV.param["RC" + rollchannel + "_REVERSED"];

                return(angle_input(revr != 1, pwmvalue, minr, maxr, minroll, maxroll) / 100.0);

            case GimbalPoint.axis.pitch:
                pwmvalue = channelpwm(pitchchannel);
                float minp     = (float)comPort.MAV.param["RC" + pitchchannel + "_MIN"];
                float maxp     = (float)comPort.MAV.param["RC" + pitchchannel + "_MAX"];
                float minpitch = (float)comPort.MAV.param["MNT_ANGMIN_TIL"];
                float maxpitch = (float)comPort.MAV.param["MNT_ANGMAX_TIL"];
                float revp     = comPort.MAV.param.ContainsKey("RC" + pitchchannel + "_REV")
                        ? (float)comPort.MAV.param["RC" + pitchchannel + "_REV"]
                        : (float)comPort.MAV.param["RC" + pitchchannel + "_REVERSED"];


                return(angle_input(revp != 1, pwmvalue, minp, maxp, minpitch, maxpitch) / 100.0);

            case GimbalPoint.axis.yaw:
                pwmvalue = channelpwm(yawchannel);
                float miny   = (float)comPort.MAV.param["RC" + yawchannel + "_MIN"];
                float maxy   = (float)comPort.MAV.param["RC" + yawchannel + "_MAX"];
                float minyaw = (float)comPort.MAV.param["MNT_ANGMIN_PAN"];
                float maxyaw = (float)comPort.MAV.param["MNT_ANGMAX_PAN"];
                float revy   = comPort.MAV.param.ContainsKey("RC" + yawchannel + "_REV")
                        ? (float)comPort.MAV.param["RC" + yawchannel + "_REV"]
                        : (float)comPort.MAV.param["RC" + yawchannel + "_REVERSED"];

                return(angle_input(revy != 1, pwmvalue, miny, maxy, minyaw, maxyaw) / 100.0);
            }

            return(0);
        }
Ejemplo n.º 9
0
    /// <summary>
    /// Returns a Vector2 with an axis of the specified value
    /// </summary>
    /// <param name="_vector2">Vector to be changed</param>
    /// <param name="_value">Value of axis</param>
    /// <param name="_axis">selected axis</param>
    /// <returns></returns>
    public static Vector2 SetVector2Axis(Vector2 _vector2, float _value, axis _axis)
    {
        Vector2 returnData;

        if (_axis == axis.x)
        {
            returnData = new Vector2(_value, _vector2.y);
        }
        else
        {
            returnData = new Vector2(_vector2.x, _value);
        }
        return(returnData);
    }
Ejemplo n.º 10
0
        private double screenPixToData(int pix, axis ax)
        {
            double val = 0;

            if (ax == axis.X)
            {
                val = pixToData(pix - this.Bounds.Location.X - borderRight, ax);
            }
            else
            {
                val = pixToData(pix - this.Bounds.Location.Y - borderTop, ax);
            }

            return(val);
        }
Ejemplo n.º 11
0
        static void AddInput(axis k, string s)
        {
            switch (s)
            {
            case "axisX":  axisX.f += k.f; break;

            case "axisY":  axisY.f += k.f; break;

            case "mouseX": mouseX.f += k.f; break;

            case "mouseY": mouseY.f += k.f; break;

            case "roll":   roll.f += k.f; break;
            }
        }
 public void setAxisToFollow(string _axis)
 {
     if (_axis.Equals("x"))
     {
         axisToFollow = axis.x;
     }
     if (_axis.Equals("y"))
     {
         axisToFollow = axis.y;
     }
     if (_axis.Equals("both"))
     {
         axisToFollow = axis.Neither;
     }
 }
Ejemplo n.º 13
0
        public static void create(float distance, float radius, axis a, string output = "sounds/default/", string hrtf = "", string sound = "")
        {
            List <Vector3> list = new List <Vector3>();

            switch (a)
            {
            case axis.LR:
                list = axisLR(distance, radius);
                break;

            case axis.DU:
                list = axisDU(distance, radius);
                break;

            case axis.FB:
                list = axisFB(distance, radius);
                break;
            }

            bool exists = System.IO.Directory.Exists(output);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(output);
            }

            Globals g = Globals.load();

            if (hrtf == "")
            {
                hrtf = g.hrtf;
            }
            if (sound == "")
            {
                sound = g.input;
            }
            steamAudio.settings(sound, g.output, hrtf);
            steamAudio.init();

            int i = 0;

            foreach (Vector3 v in list)
            {
                string name = output + i + ".wav";
                steamAudio.ogCreateX(v.X, v.Y, v.Z, name);
                i++;
            }
        }
Ejemplo n.º 14
0
 public Controls()           // why the how does it
 {
     menu   = new key((n) => menu.input = n);
     term   = new key((n) => term.input = n);
     invt   = new key((n) => invt.input = n);
     fire   = new key((n) => fire.input = n);
     lamp   = new key((n) => lamp.input = n);
     jump   = new key((n) => jump.input = n);
     dash   = new key((n) => dash.input = n);
     duck   = new key((n) => duck.input = n);
     mouseX = new axis((n) => mouseX.input = n);
     mouseY = new axis((n) => mouseY.input = n);
     axisX  = new axis((n) => axisX.input = n);
     axisY  = new axis((n) => axisY.input = n);
     roll   = new axis((n) => roll.input = n);
 }         // there is no reason for this to compile
Ejemplo n.º 15
0
 public Controls() { // why the how does it
     menu    = new key((n)=>menu.input=n);
     term    = new key((n)=>term.input=n);
     invt    = new key((n)=>invt.input=n);
     fire    = new key((n)=>fire.input=n);
     lamp    = new key((n)=>lamp.input=n);
     jump    = new key((n)=>jump.input=n);
     dash    = new key((n)=>dash.input=n);
     duck    = new key((n)=>duck.input=n);
     accept  = new key((n)=>accept.input=n);
     mouseX  = new axis((n)=>mouseX.input=n);
     mouseY  = new axis((n)=>mouseY.input=n);
     axisX   = new axis((n)=>axisX.input=n);
     axisY   = new axis((n)=>axisY.input=n);
     //roll  = new axis((n)=>roll.input=n);
 } // there is no reason for this how does it even
Ejemplo n.º 16
0
    static public void axisFromJson(int column, string json)
    {
        if (jsonParser == null)
        {
            jsonParser = new Regex("{([^}]*)},+");
        }
        MatchCollection matches = jsonParser.Matches(json);

        if (matches.Count != (int)Actions.NumActions)
        {
            throw new System.Exception("Invalid number of actions in the configuration file");
        }

        axis[] _axis = new axis[matches.Count];
        for (int i = 0; i < matches.Count; i++)
        {
            int    len     = matches[i].Value.Length - 3;
            string subJson = matches[i].Value.Substring(1, len);

            if (subJson.Length > 0)
            {
                _axis[i] = axis.fromJson(subJson);
            }
            else
            {
                _axis[i] = null;
            }
        }

        switch (column)
        {
        case 0:
            axis0 = _axis;
            break;

        case 1:
            axis1 = _axis;
            break;

        case 2:
            axis2 = _axis;
            break;

        default:
            throw new System.Exception("Invalid input map");
        }
    }
Ejemplo n.º 17
0
 public Controls()
 {
     // why the how does it
     menu 	= new key((n)=>menu.input=n);
     term 	= new key((n)=>term.input=n);
     invt 	= new key((n)=>invt.input=n);
     fire  	= new key((n)=>fire.input=n);
     lamp 	= new key((n)=>lamp.input=n);
     jump 	= new key((n)=>jump.input=n);
     dash 	= new key((n)=>dash.input=n);
     duck 	= new key((n)=>duck.input=n);
     mouseX 	= new axis((n)=>mouseX.input=n);
     mouseY 	= new axis((n)=>mouseY.input=n);
     axisX 	= new axis((n)=>axisX.input=n);
     axisY 	= new axis((n)=>axisY.input=n);
     roll 	= new axis((n)=>roll.input=n);
 }
        public static double ConvertPwmtoAngle(axis axis)
        {
            int pwmvalue =-1;

            if (!MainV2.comPort.MAV.param.ContainsKey("RC" + yawchannel + "_MIN"))
                return 0;

            switch (axis)
            {
                case GimbalPoint.axis.roll:
                    pwmvalue = channelpwm(rollchannel);
                    float minr = (float)MainV2.comPort.MAV.param["RC" + rollchannel + "_MIN"];
                    float maxr = (float)MainV2.comPort.MAV.param["RC" + rollchannel + "_MAX"];
                    float minroll = (float)MainV2.comPort.MAV.param["MNT_ANGMIN_ROL"];
                    float maxroll = (float)MainV2.comPort.MAV.param["MNT_ANGMAX_ROL"];
                    float revr = (float)MainV2.comPort.MAV.param["RC" + rollchannel + "_REV"];

                    return angle_input(revr != 1,pwmvalue,minr,maxr,minroll,maxroll)/100.0;
                    
                case GimbalPoint.axis.pitch:
                    pwmvalue = channelpwm(pitchchannel);
                    float minp = (float)MainV2.comPort.MAV.param["RC" + pitchchannel + "_MIN"];
                    float maxp = (float)MainV2.comPort.MAV.param["RC" + pitchchannel + "_MAX"];
                    float minpitch = (float)MainV2.comPort.MAV.param["MNT_ANGMIN_TIL"];
                    float maxpitch = (float)MainV2.comPort.MAV.param["MNT_ANGMAX_TIL"];
                    float revp = (float)MainV2.comPort.MAV.param["RC" + pitchchannel + "_REV"];


                    return angle_input(revp != 1, pwmvalue, minp, maxp, minpitch, maxpitch) / 100.0;
                    
                case GimbalPoint.axis.yaw:
                    pwmvalue = channelpwm(yawchannel);
                    float miny = (float)MainV2.comPort.MAV.param["RC" + yawchannel + "_MIN"];
                    float maxy = (float)MainV2.comPort.MAV.param["RC" + yawchannel + "_MAX"];
                    float minyaw = (float)MainV2.comPort.MAV.param["MNT_ANGMIN_PAN"];
                    float maxyaw = (float)MainV2.comPort.MAV.param["MNT_ANGMAX_PAN"];
                    float revy = (float)MainV2.comPort.MAV.param["RC" + yawchannel + "_REV"];


                    return angle_input(revy != 1, pwmvalue, miny, maxy, minyaw, maxyaw) / 100.0;
                    
            }

            return 0;
        }
Ejemplo n.º 19
0
        private void button2_Click(object sender, EventArgs e)
        {
            label8.Text = "Generating...";
            float  distance;
            float  radius;
            axis   a = axis.DU;
            string path;
            string hrtf;
            string sound;

            try {
                distance = float.Parse(textBox1.Text);
                radius   = float.Parse(textBox2.Text);
                if (radioButton1.Checked)
                {
                    a = axis.LR;
                }
                if (radioButton2.Checked)
                {
                    a = axis.DU;
                }
                if (radioButton3.Checked)
                {
                    a = axis.FB;
                }

                path  = Path.Combine(textBox3.Text, textBox4.Text) + "\\";
                hrtf  = textBox5.Text;
                sound = textBox6.Text;

                bool exists = System.IO.Directory.Exists(path);
                if (!exists)
                {
                    System.IO.Directory.CreateDirectory(path);
                }
                Generator2.create(distance, radius, a, path, hrtf, sound);
                label8.Text = "Done!";
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
                //System.IO.Directory.Delete(path);
            }
        }
Ejemplo n.º 20
0
        private void drawTick(double value, axis ax, int fontPx)
        {
            float fTextPosX = 0.0F;
            float fTextPosY = 0.0F;

            Point ptMinXY = dataToPix(minX, minY);
            Point ptMaxXY = dataToPix(maxX, maxY);


            Point tickPos  = new Point(ptMinXY.X, ptMinXY.Y);
            Point ptToTick = new Point(ptMinXY.X - 5, ptMinXY.Y + 5);

            string formatNum = "";

            switch (ax)
            {
            case axis.X:
                tickPos    = dataToPix(value, minY);
                fTextPosX  = (float)tickPos.X - 15;
                fTextPosY  = (float)tickPos.Y + 7.0F;
                ptToTick.X = tickPos.X;
                formatNum  = formatNumX;
                break;

            case axis.Y:
                tickPos    = dataToPix(minX, value);
                fTextPosX  = (float)tickPos.X - 45;
                fTextPosY  = (float)tickPos.Y - 8;
                ptToTick.Y = tickPos.Y;
                formatNum  = formatNumY;
                break;
            }



            drawLine(tickPos.X, tickPos.Y, ptToTick.X, ptToTick.Y);
            writeText(fTextPosX,
                      fTextPosY,
                      fontPx,
                      value.ToString(formatNum,
                                     CultureInfo.InvariantCulture));
        }
Ejemplo n.º 21
0
    public static float GetAxis(int player, axis _axis)
    {
        if (player <= 0 || player > 4)
        {
            return(0f);
        }

        GamePadState state = GamePad.GetState((PlayerIndex)(player - 1));

        switch (_axis)
        {
        case axis.HORIZONTAL:
            return(state.ThumbSticks.Left.X);

        case axis.VERTICAL:
            return(state.ThumbSticks.Left.Y);
        }

        return(0f);
    }
Ejemplo n.º 22
0
        private void button3_Click(object sender, EventArgs e)
        {
            axis a = axis.DU;

            if (radioButton1.Checked)
            {
                a = axis.LR;
            }
            if (radioButton2.Checked)
            {
                a = axis.DU;
            }
            if (radioButton3.Checked)
            {
                a = axis.FB;
            }
            string sound = Path.GetFileNameWithoutExtension(textBox6.Text);
            string sofa  = Path.GetFileNameWithoutExtension(textBox5.Text);

            textBox4.Text = string.Format("{0}_{1}_{2}_{3}_{4}", textBox1.Text, textBox2.Text, a.ToString(), sound, sofa);
        }
Ejemplo n.º 23
0
    public void Subdivide(LeModule.axis axis)
    {
        subdivisionAxis = axis;
        if (children == null)
        {
            children = new List <LeModule>();
        }
        // Create modules if this is the first time we've been divided
        while (children.Count < 2)
        {
            var go = new GameObject();
            go.transform.SetParent(this.transform);
            go.transform.localPosition = Vector3.zero;
            go.transform.localRotation = Quaternion.identity;
            var node = go.AddComponent <LeModule>();
            children.Add(node);
            node.parent = this;
            var prefab = Resources.Load <GameObject>("Prefabs/Cube");
            node.go = GameObject.Instantiate(prefab);
            node.go.transform.SetParent(node.transform);
            node.go.transform.localPosition = Vector3.zero;
            node.go.transform.localRotation = Quaternion.identity;
            Debug.Log(uid + " Added child");
        }
        if (children != null)
        {
            if (children.Count < 2)
            {
                Debug.LogError(uid + " childNodes.Count < 2");
                return;
            }
        }
        else
        {
            Debug.LogError(uid + " childNodes list == null");
            return;
        }
        // Get a list containing two modulor values
        List <float> ms = new List <float>();

        foreach (LeModule child in children)
        {
            switch (subdivisionAxis)
            {
            case axis.x:
                ms = Modulor.GetList(size.x, 2);
                break;

            case axis.y:
                ms = Modulor.GetList(size.y, 2);
                break;

            case axis.z:
                ms = Modulor.GetList(size.z, 2);
                break;
            }
        }
        // Check sizes to see if they are out of bounds
        foreach (var value in ms)
        {
        }
        // Revese the list randomly
        if (ExtRandom <bool> .Chance(1, 2))
        {
            ms.Reverse();
        }

        for (int i = 0; i < children.Count; i++)
        {
            switch (subdivisionAxis)
            {
            case axis.x:
                children[i].size.x = ms[i];
                break;

            case axis.y:
                children[i].size.y = ms[i];
                break;

            case axis.z:
                children[i].size.z = ms[i];
                break;
            }
        }
        foreach (LeModule child in children)
        {
            var scale = child.go.transform.localScale;
            switch (subdivisionAxis)
            {
            case axis.x:
                scale.x = child.size.x;
                scale.y = size.y;
                scale.z = size.z;
                break;

            case axis.y:
                scale.x = size.x;
                scale.y = child.size.y;
                scale.z = size.z;
                break;

            case axis.z:
                scale.x = size.x;
                scale.y = size.y;
                scale.z = child.size.z;
                break;
            }
            child.go.transform.localScale = scale;
        }

        // Effect position
        // index 0 pos = index 1 scale / 2
        // index 1 should be moved the scale of index 0 / 2
        foreach (LeModule child in children)
        {
            var pos        = child.transform.localPosition;
            int childIndex = children.IndexOf(child);
            if (childIndex == 0)
            {
                switch (subdivisionAxis)
                {
                case axis.x:
                    pos.x = children[1].size.x / 2 * -1;
                    pos.y = 0;
                    pos.z = 0;
                    break;

                case axis.y:
                    pos.x = 0;
                    pos.y = children[1].size.y / 2 * -1;
                    pos.z = 0;
                    break;

                case axis.z:
                    pos.x = 0;
                    pos.y = 0;
                    pos.z = children[1].size.z / 2 * -1;
                    break;
                }
            }
            else if (childIndex == 1)
            {
                switch (subdivisionAxis)
                {
                case axis.x:
                    pos.x = children[0].size.x / 2;
                    pos.y = 0;
                    pos.z = 0;
                    break;

                case axis.y:
                    pos.x = 0;
                    pos.y = children[0].size.y / 2;
                    pos.z = 0;
                    break;

                case axis.z:
                    pos.x = 0;
                    pos.y = 0;
                    pos.z = children[0].size.z / 2;
                    break;
                }
            }
            else
            {
                Debug.LogError(uid + "Index should not be greater than 1");
            }
            child.transform.localPosition = pos;
        }
        // Set the size of the un effected axises to the values in the parent
        foreach (LeModule child in children)
        {
            switch (subdivisionAxis)
            {
            case axis.x:
                child.size.y = size.y;
                child.size.z = size.z;
                break;

            case axis.y:
                child.size.x = size.x;
                child.size.z = size.z;
                break;

            case axis.z:
                child.size.x = size.x;
                child.size.y = size.y;
                break;
            }
        }
        // Hide self
        foreach (LeModule item in children)
        {
            item.go.SetActive(true);
        }
        go.SetActive(false);
    }
    void Update()
    {
        offset = (InputManager.GetInputPosition() - previousPosition);
        if (InputManager.GetInputDown(0))    // Input.GetMouseButtonDown(0) 当0键被按下一次
        {
            if (detectionZoneMask.rect.Contains(InputManager.GetInputPosition()))
            {
                draging = true;
            }
            else
            {
                draging = false;
                Debug.Log("No draging" + InputManager.GetInputPosition().ToString() + "in " + detectionZoneMask.rect.size.ToString());
            }
            if (miniCameraMask.rect.Contains(InputManager.GetInputPosition()))
            {
                draging = false;
                Debug.Log("Cancle Input draging" + InputManager.GetInputPosition().ToString() + "in " + miniCameraMask.rect.size.ToString());
            }

            if (draging)
            {
                Debug.Log("Input draging" + InputManager.GetInputPosition().ToString() + "in " + detectionZoneMask.rect.size.ToString());
            }
        }
        else if (InputManager.GetInputHold(0) && draging)       // Input.GetMouseButton(0) 当0键被按住持续侦测(包含down和up各一次)
        {
            if (routatingAround == axis.empty && offset.magnitude > 0.001f)
            {
                routatingAround     = Mathf.Abs(offset.x) >= Mathf.Abs(offset.y) ? axis.y : axis.normalInXZ;
                axisToRoutateAround = (routatingAround != axis.empty && Mathf.Abs(offset.x) >= Mathf.Abs(offset.y))? Vector3.up : Vector3.Cross(camTransform.position - target.position, Vector3.down);
                if (Mathf.Abs(offset.x) >= Mathf.Abs(offset.y))
                {
                    Debug.Log("Detect x>=y " + offset.ToString());
                }
                else
                {
                    Debug.Log("Detect x<y " + offset.ToString());
                }
            }

            if (routatingAround == axis.y)
            {
                // Routate around the y axis
                camTransform.RotateAround(target.position, axisToRoutateAround, Time.deltaTime * offset.x * speedX);
            }
            else if (routatingAround == axis.normalInXZ)
            {
                float cosAngleBetweenCamRayAndXZPlane = 0f;
                cosAngleBetweenCamRayAndXZPlane = Vector3.Dot(Vector3.up, camTransform.position - target.position) / (camTransform.position - target.position).magnitude;
                if ((cosAngleBetweenCamRayAndXZPlane >= 0.9f && offset.y < 0 || (cosAngleBetweenCamRayAndXZPlane <= -0.9f && offset.y > 0)))
                {
                    offset.y = 0;
                }
                camTransform.RotateAround(target.position, axisToRoutateAround, Time.deltaTime * offset.y * speedY);
            }
        }
        else if (InputManager.GetInputUp(0) && draging)  //Input.GetMouseButtonUp(0) 当0键放开一次
        {
            routatingAround     = axis.empty;
            axisToRoutateAround = Vector3.zero;
            draging             = false;
        }
        previousPosition = Input.mousePosition;
    }
Ejemplo n.º 25
0
        /// <summary>
        /// Checks for intersection with a given mouse point. Pass the results from a call to System.Windows.Forms.MouseEventArgs()
        /// </summary>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        /// <param name="mat">The mat.</param>
        /// <returns></returns>
        /// <remarks></remarks>
        public axis checkForIntersection(MouseEventArgs e, Matrix mat)
        {
            List<int> temp = new List<int>();
            temp = MeshPick(e.X, e.Y, this.gizmo, mat);
            if (temp.Count > 0)
            {
                switch (temp[0])
                {
                    case 0:
                    case 3:
                        this.selectedAxis = axis.X;
                        break;
                    case 1:
                    case 4:
                        this.selectedAxis = axis.Y;
                        break;
                    case 2:
                    case 5:
                        this.selectedAxis = axis.Z;
                        break;
                    case 6:
                        this.selectedAxis = axis.XY;
                        break;
                    case 7:
                        this.selectedAxis = axis.YZ;
                        break;
                    case 8:
                        this.selectedAxis = axis.XZ;
                        break;
                    default:
                        this.selectedAxis = axis.none;
                        break;
                }
            }
            else
            {
                this.selectedAxis = axis.none;
            }

            /*
            for (int x = 0; x < this.gizmo.Count; x++)
            {
                //check bitmask for object visibility

                    // Check under mouse cursor for object selection/deselection?
                }
            }
            */
            return this.selectedAxis;
        }
Ejemplo n.º 26
0
    static private CoroutineRet _waitInput(axis[] arr, Actions action)
    {
        int  idx  = action.idx();
        bool done = false;

        while (!done)
        {
            /* Wait until the end of the next frame */
            yield return(null);

            if (waitCaller.lastKey != KeyCode.None)
            {
                arr[idx] = new axis(waitCaller.lastKey);
                done     = true;
                break;
            }
            else
            {
                /* Test every option in every gamepad :grimacing: */
                for (int gpIdx = 1; !done && gpIdx < gamepadNum; gpIdx++)
                {
                    for (int gpAxis = 0; gpAxis < gamepadAxisNum; gpAxis++)
                    {
                        string name = $"joystick {gpIdx} axis {gpAxis}";
                        int    i    = gpIdx * gamepadAxisNum + gpAxis;
                        float  rest = Input.axisRest[i];
                        float  val  = DefInput.GetAxisRaw(name);
                        float  diff = val - rest;

                        /* Check that the axis is 80% of the way pressed
                         * in the given direction */
                        if (val > rest && diff > 0.25f &&
                            diff / (1.0f - rest) >= 0.8f)
                        {
                            arr[idx] = new axis(name, axisType.positiveAxis, rest);
                            done     = true;
                            break;
                        }
                        else if (val < rest && diff < -0.25f &&
                                 Math.Abs(diff / (1.0f + rest)) >= 0.8f)
                        {
                            arr[idx] = new axis(name, axisType.negativeAxis, rest);
                            done     = true;
                            break;
                        }
                    }
                    for (int gpBt = 0; gpBt < gamepadButtonNum; gpBt++)
                    {
                        string name = $"joystick {gpIdx} button {gpBt}";
                        if (DefInput.GetButton(name))
                        {
                            arr[idx] = new axis(name, axisType.none);
                            done     = true;
                            break;
                        }
                    }
                }
            }
        }

        waitFunc = null;
        waitCaller.GetComponentInChildren <KeyLogger>().enabled = false;
        waitCaller = null;
    }
Ejemplo n.º 27
0
 /*
  *   add a new point to array axis
  *
  */
 public void add(axis p)
 {
     current_pos++;
     point[current_pos].x = p.x;
     point[current_pos].y = p.y;
 }