Example #1
0
    Vector3 GetDirect(Transform selTrans, AXIS axis, bool bLocal)
    {
        if (bLocal)
        {
            switch (axis)
            {
            case AXIS.X: return(selTrans.right);

            case AXIS.Y: return(selTrans.up);

            case AXIS.Z: return(selTrans.forward);
            }
        }
        else
        {
            switch (axis)
            {
            case AXIS.X: return(Vector3.right);

            case AXIS.Y: return(Vector3.up);

            case AXIS.Z: return(Vector3.forward);
            }
        }
        return(Vector3.forward);
    }
Example #2
0
    public void Rotate(AXIS axis, float angle, float direction, RotationCommand.CommandType rotationType, float rotationTime = 0.3f)
    {
        if (!rotationLocked)
        {
            RotationCommand command = new RotationCommand();

            command.xIndex = int.Parse(RubikGenerator.Instance.selecedCube.name[0].ToString()) - 1;
            command.yIndex = int.Parse(RubikGenerator.Instance.selecedCube.name[1].ToString()) - 1;
            command.zIndex = int.Parse(RubikGenerator.Instance.selecedCube.name[2].ToString()) - 1;

            command.direction   = direction;
            command.angle       = angle;
            command.axis        = axis;
            command.commandType = rotationType;

            if (rotationType == RotationCommand.CommandType.Manual)
            {
                rotationCommands.Push(command);
                allRotationCommands.Push(command);
            }

            rotationLocked = true;

            var slice = RubikGenerator.Instance.GetSlice(axis);

            StartCoroutine(RotateSlice(slice, axis, angle, rotationTime, direction, rotationType));
        }
    }
Example #3
0
        public Vector Rotate(AXIS axis, double angle)
        {
            switch (axis)
            {
            case AXIS.axisZ:
                double tempX = Math.Cos(angle) * this.x - Math.Sin(angle) * this.y + 0 * this.z;
                double tempY = Math.Sin(angle) * this.x + Math.Cos(angle) * this.y + 0 * this.z;
                double tempZ = 0 * this.x + 0 * this.y + 1 * this.y;
                return(new Vector(tempX, tempY, tempZ));


                break;

            case AXIS.axisY:
                tempX = Math.Cos(angle) * this.x + 0 * this.y + Math.Sin(angle) * this.z;
                tempY = 0 * this.x + 1 * this.y + 0 * this.z;
                tempZ = -Math.Sin(angle) * this.x + 0 * this.y + Math.Cos(angle) * this.z;
                return(new Vector(tempX, tempY, tempZ));

                break;

            case AXIS.axisX:
                tempX = 1 * this.x + 0 * this.y + 0 * this.z;
                tempY = 0 * this.x + Math.Cos(angle) * this.y - Math.Sin(angle) * this.z;
                tempZ = 0 * this.x + Math.Sin(angle) * this.y + Math.Cos(angle) * this.z;
                return(new Vector(tempX, tempY, tempZ));

                break;

            default:
                return(new Vector(0, 0, 0));

                break;
            }
        }
Example #4
0
    Vector3 GetEuler(Transform selTrans, AXIS axis, bool bLocal)
    {
        if (bLocal)
        {
            Quaternion quat = Quaternion.identity;
            switch (axis)
            {
            case AXIS.X: quat.SetLookRotation(selTrans.right);              break;

            case AXIS.Y: quat.SetLookRotation(selTrans.up);                 break;

            case AXIS.Z: quat.SetLookRotation(selTrans.forward);    break;
            }
            return(quat.eulerAngles);
        }
        else
        {
            switch (axis)
            {
            case AXIS.X: return(new Vector3(0, 90, 0));

            case AXIS.Y: return(new Vector3(-90, 0, 0));

            case AXIS.Z: return(new Vector3(0, 0, 0));
            }
        }
        return(Vector3.forward);
    }
Example #5
0
        private void FillTableWithAxisInf(AXIS ax, int row = -2)
        {
            if (ax == null || ax.mt_type == AXIS.MT_TYPE.NULL)
            {
                return;
            }
            //if empty or add mode then add
            //if (dgv.Rows.Count == 0|| row == -2) row = dgv.Rows.Add();
            if (dgv.Rows.Count == 0 || row < 0 || row >= dgv.Rows.Count)
            {
                row = dgv.Rows.Add();
            }
            //the last row
            else if (row < 0)
            {
                row = dgv.Rows.Count - 1;
            }

            dgv.Rows[row].Cells[0].Value  = ax.disc;
            dgv.Rows[row].Cells[1].Value  = ax.str_status;
            dgv.Rows[row].Cells[2].Value  = ax.fcmd_pos.ToString("F3");
            dgv.Rows[row].Cells[3].Value  = ax.fenc_pos.ToString("F3");
            dgv.Rows[row].Cells[4].Value  = ax.isORG;
            dgv.Rows[row].Cells[5].Value  = ax.isELN;
            dgv.Rows[row].Cells[6].Value  = ax.isELP;
            dgv.Rows[row].Cells[7].Value  = ax.isSLN;
            dgv.Rows[row].Cells[8].Value  = ax.isSLP;
            dgv.Rows[row].Cells[9].Value  = ax.isINP;
            dgv.Rows[row].Cells[10].Value = ax.isALM;
            dgv.Rows[row].Cells[11].Value = ax.isSVRON;
        }
Example #6
0
    public static Matrix4x4 RotateM(float angle, AXIS axis)
    {
        Matrix4x4 rm  = Matrix4x4.identity;
        float     rad = angle * Mathf.Deg2Rad;

        if (axis == AXIS.AX_X)
        {
            rm[1, 1] = Mathf.Cos(rad);
            rm[1, 2] = -Mathf.Sin(rad);
            rm[2, 1] = Mathf.Sin(rad);
            rm[2, 2] = Mathf.Cos(rad);
        }
        else if (axis == AXIS.AX_Y)
        {
            rm[0, 0] = Mathf.Cos(rad);
            rm[0, 2] = Mathf.Sin(rad);
            rm[2, 0] = -Mathf.Sin(rad);
            rm[2, 2] = Mathf.Cos(rad);
        }
        else if (axis == AXIS.AX_Z)
        {
            rm[0, 0] = Mathf.Cos(rad);
            rm[0, 1] = -Mathf.Sin(rad);
            rm[1, 0] = Mathf.Sin(rad);
            rm[1, 1] = Mathf.Cos(rad);
        }
        return(rm);
    }
Example #7
0
    void DrawGuiGizmoAxis(AXIS drawAxis, float fLineLen, bool bDrawLocalAxis)
    {
        Vector3 vecDirect = Vector3.zero;
        Vector3 vecPos    = Vector3.zero;
        Color   color     = Color.white;

        if (Camera.main == null)
        {
            return;
        }

        // set color
        switch (drawAxis)
        {
        case AXIS.X: color = Color.red;                 break;

        case AXIS.Y: color = Color.green;               break;

        case AXIS.Z: color = Color.blue;                break;
        }

        // draw line
        float     fDist     = FXMakerMain.inst.GetFXMakerMouse().m_fDistance;
        Rect      baseRect  = FXMakerLayout.GetEffectHierarchyRect();
        Vector3   guiCenPos = new Vector3(Screen.width / 2, Screen.height / 2, fDist);
        Vector3   guiPos    = new Vector3(baseRect.x - 50, baseRect.y + 30) - guiCenPos;
        Transform tempTrans = GetTempTransform();

        tempTrans.position = Camera.main.ScreenToWorldPoint(guiCenPos);
        vecDirect          = tempTrans.position + GetDirect(tempTrans, drawAxis, true) * fDist / 20;
        vecPos             = Camera.main.WorldToScreenPoint(vecDirect);
        vecPos.y           = Screen.height - vecPos.y;
        NgGUIDraw.DrawLine(guiPos + guiCenPos, guiPos + vecPos, color, 3, true);
    }
Example #8
0
    public Vector3 GetAxis(AXIS axis)
    {
        switch (axis)
        {
        case AXIS.XPositive:
            return(Vector3.right);

        case AXIS.YPositive:
            return(Vector3.up);

        case AXIS.ZPositive:
            return(Vector3.forward);

        case AXIS.XNegative:
            return(-Vector3.right);

        case AXIS.YNegative:
            return(-Vector3.up);

        case AXIS.ZNegative:
            return(-Vector3.forward);

        default:
            return(Vector3.zero);
        }
    }
Example #9
0
        /* 回転行列を生成
         * @param[in] angle 回転角度[rad]
         * @param[in] axis どの軸周りに回すか
         * @return 回転行列
         */
        public static Matrix <double> GenerateRotMat(double angle, AXIS axis)
        {
            Matrix <double> rotMat = Matrix <double> .Build.Dense(3, 3, 0.0);  //3x3の零行列

            switch (axis)
            {
            case AXIS.X:
                rotMat[0, 0] = 1;
                rotMat[1, 1] = Math.Cos(angle);
                rotMat[1, 2] = -Math.Sin(angle);
                rotMat[2, 1] = Math.Sin(angle);
                rotMat[2, 2] = Math.Cos(angle);
                break;

            case AXIS.Y:
                rotMat[0, 0] = Math.Cos(angle);
                rotMat[0, 2] = Math.Sin(angle);
                rotMat[1, 1] = 1;
                rotMat[2, 0] = -Math.Sin(angle);
                rotMat[2, 2] = Math.Cos(angle);
                break;

            case AXIS.Z:
                rotMat[0, 0] = Math.Cos(angle);
                rotMat[0, 1] = -Math.Sin(angle);
                rotMat[0, 2] = 0;
                rotMat[1, 0] = Math.Sin(angle);
                rotMat[1, 1] = Math.Cos(angle);
                rotMat[2, 2] = 1;
                break;
            }
            return(rotMat);
        }
Example #10
0
    /// <summary>
    /// Returns the value of the specified joystick axis
    /// </summary>
    /// <param name="btn"></param>
    /// <returns></returns>
    public static float GetJoystickAxis(JOYSTICK joy, AXIS axis)
    {
        string input = PAD_PREFIX;

        switch (joy)
        {
        case JOYSTICK.L:
            input += LEFT_JOYSTICK_PREFIX;
            break;

        case JOYSTICK.R:
            input += RIGHT_JOYSTICK_PREFIX;
            break;
        }

        switch (axis)
        {
        case AXIS.X:
            input += X;
            break;

        case AXIS.Y:
            input += Y;
            break;
        }

        return(Input.GetAxisRaw(input));
    }
Example #11
0
        private void FillTableWithAxisInf(AXIS ax, int row = -2)
        {
            if (ax == null || ax.mt_type == AXIS.MT_TYPE.NULL)
            {
                return;
            }
            //if empty or add mode then add
            //if (dgv.Rows.Count == 0|| row == -2) row = dgv.Rows.Add();
            if (dgv.Rows.Count == 0 || row < 0 || row >= dgv.Rows.Count)
            {
                row = dgv.Rows.Add();
            }
            //the last row
            else if (row < 0)
            {
                row = dgv.Rows.Count - 1;
            }

            dgv.Rows[row].Cells[0].Value = ax.disc;
            dgv.Rows[row].Cells[1].Value = ax.spd_start.ToString("F0");
            dgv.Rows[row].Cells[2].Value = ax.spd_stop.ToString("F0");
            dgv.Rows[row].Cells[3].Value = ax.home_spd.ToString("F0");
            dgv.Rows[row].Cells[4].Value = ax.spd_work.ToString("F0");
            //dgv.Rows[row].Cells[5].Value = ax.max_spd.ToString("F0");
            dgv.Rows[row].Cells[5].Value  = ax.tacc.ToString("F3");
            dgv.Rows[row].Cells[6].Value  = ax.tdec.ToString("F3");
            dgv.Rows[row].Cells[7].Value  = ax.sln.ToString("F0");
            dgv.Rows[row].Cells[8].Value  = ax.slp.ToString("F0");
            dgv.Rows[row].Cells[9].Value  = ax.pul_per_mm.ToString("F7");
            dgv.Rows[row].Cells[10].Value = ax.home_offset.ToString("F3");
            dgv.Rows[row].Cells[11].Value = ax.pos0.ToString("F3");
            dgv.Rows[row].Cells[12].Value = ax.pos1.ToString("F3");
        }
Example #12
0
 public override void Impact(Vector3 _originalLocalPosition, bool _destroy,
         float _duration, float _maxAngle, float _amplitude, float _count, AXIS _axis = AXIS.Y)
 {
     Play = true;
     enabled = true;
     base.Impact(_originalLocalPosition, _destroy, _duration, _maxAngle, _amplitude, _count, _axis);
     StopAllCoroutines();
     StartCoroutine(UpdatePos());
 }
Example #13
0
        /// <summary>
        /// Shakes shake into random directions. Stops all other Coroutines on this behaviourscript!
        /// </summary>
        /// <param name="_Time"></param>
        /// <param name="_Intensity"></param>
        public void Shake(float _Time, float _Intensity, AXIS _Axis)
        {
            if (ScreenIsShaking)
            {
                StopAllCoroutines();
            }

            StartCoroutine(ScreenShakeCoroutine(CamTransform, _Time, _Intensity, _Axis));
        }
Example #14
0
    /// <summary>
    /// If there is a selected small cube then given the axis of rotation group the appropriate cubes into one slice
    /// </summary>
    /// <param name="axis"></param>
    /// <returns></returns>
    public GameObject GetSlice(AXIS axis)
    {
        int x = int.Parse(selecedCube.name[0].ToString()) - 1;
        int y = int.Parse(selecedCube.name[1].ToString()) - 1;
        int z = int.Parse(selecedCube.name[2].ToString()) - 1;

        EmptySlice();
        slice.transform.rotation = Quaternion.identity;

        switch (axis)
        {
        case AXIS.Y:
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    var obj = cubes[i][y][j];
                    obj.transform.SetParent(slice.transform);
                }
            }
        }
        break;

        case AXIS.X:
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    var obj = cubes[x][i][j];
                    obj.transform.SetParent(slice.transform);
                }
            }
        }
        break;

        case AXIS.Z:
        {
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    var obj = cubes[i][j][z];
                    obj.transform.SetParent(slice.transform);
                }
            }
        }
        break;

        default:
            break;
        }

        return(slice);
    }
	void LoadPrefs()
	{
		m_nPlayIndex	= PlayerPrefs.GetInt("FxmTestControls.m_nPlayIndex"		, m_nPlayIndex);
		m_nTransIndex	= PlayerPrefs.GetInt("FxmTestControls.m_nTransIndex"	, m_nTransIndex);
		m_fTimeScale	= PlayerPrefs.GetFloat("FxmTestControls.m_fTimeScale"	, m_fTimeScale);
		m_fDistPerTime	= PlayerPrefs.GetFloat("FxmTestControls.m_fDistPerTime"	, m_fDistPerTime);
		m_nRotateIndex	= PlayerPrefs.GetInt("FxmTestControls.m_nRotateIndex"	, m_nRotateIndex);
		m_nTransAxis	= (AXIS)PlayerPrefs.GetInt("FxmTestControls.m_nTransAxis", (int)m_nTransAxis);
		m_bMinimize		= PlayerPrefs.GetInt("FxmTestControls.m_bMinimize", m_bMinimize ? 1 : 0) == 1;
		SetTimeScale(m_fTimeScale);
	}
Example #16
0
 public void AutoSetting(int nPlayIndex, int nTransIndex, AXIS nTransAxis, float fDistPerTime, int nRotateIndex, int nMultiShotCount, float fTransRate, float fStartAdjustRate)
 {
     m_nPlayIndex      = nPlayIndex;
     m_nTransIndex     = nTransIndex;
     m_nTransAxis      = nTransAxis;
     m_fDistPerTime    = fDistPerTime;
     m_nRotateIndex    = nRotateIndex;
     m_nMultiShotCount = nMultiShotCount;
     m_fTransRate      = fTransRate;
     m_fStartPosition  = fStartAdjustRate;
 }
Example #17
0
 void LoadPrefs()
 {
     m_nPlayIndex   = PlayerPrefs.GetInt("FxmTestControls.m_nPlayIndex", m_nPlayIndex);
     m_nTransIndex  = PlayerPrefs.GetInt("FxmTestControls.m_nTransIndex", m_nTransIndex);
     m_fTimeScale   = PlayerPrefs.GetFloat("FxmTestControls.m_fTimeScale", m_fTimeScale);
     m_fDistPerTime = PlayerPrefs.GetFloat("FxmTestControls.m_fDistPerTime", m_fDistPerTime);
     m_nRotateIndex = PlayerPrefs.GetInt("FxmTestControls.m_nRotateIndex", m_nRotateIndex);
     m_nTransAxis   = (AXIS)PlayerPrefs.GetInt("FxmTestControls.m_nTransAxis", (int)m_nTransAxis);
     m_bMinimize    = PlayerPrefs.GetInt("FxmTestControls.m_bMinimize", m_bMinimize ? 1 : 0) == 1;
     SetTimeScale(m_fTimeScale);
 }
        /// <summary>
        /// Creates the mesh with sub mesh.
        /// There can be only 3 submesh(one for top, bottom and side)
        /// </summary>
        /// <returns>The sub mesh.</returns>
        public Meshes CreateSubMesh(List <Vector3> points, float thickness, string name, int submeshCount = 3)
        {
            AXIS axis = GetAxisFromPoints(points);

            Meshes mesh = Create(points, thickness, name, axis);

            //set sub meshes so that we can add materials for each side
            //Top, Bottom, Side (There can be only 3 sides as per as the logic)
            SetSubMesh(mesh.mesh, mesh.mesh.triangles, points.Count, submeshCount, mesh.renderer);

            return(mesh);
        }
Example #19
0
 public void SetDefaultSetting()
 {
     m_nPlayIndex      = 0;
     m_nTransIndex     = 0;
     m_nTransAxis      = AXIS.Z;
     m_fDistPerTime    = 10;
     m_nRotateIndex    = 0;
     m_nMultiShotCount = 1;
     m_fTransRate      = 1;
     m_fStartPosition  = 0;
     SavePrefs();
 }
Example #20
0
    public static GUIContent[] GetHcEffectControls_Trans(AXIS nTransAxis)
    {
        GUIContent[] cons = new GUIContent[8];

        cons[0] = new GUIContent("Stop", "");
        cons[1] = new GUIContent(nTransAxis.ToString() + " Move", "");
        cons[2] = new GUIContent(nTransAxis.ToString() + " Scale", "");
        cons[3] = new GUIContent("Arc", "");
        cons[4] = new GUIContent("Fall", "");
        cons[5] = new GUIContent("Raise", "");
        cons[6] = new GUIContent("Circle", "");
        cons[7] = new GUIContent("Tornado", "");
        return(cons);
    }
Example #21
0
        /**
         * Calculates the axis-specific difference of the points from the ABSOLUTENullFace
         * @param i01,i02  which are the current points to calculate the difference
         * @param axis which is the specific axis to work with
         * @param absolute defines wether or not the absolute difference should be returned or not
         */
        public double BetweenByAxis(int i01, int i02, AXIS axis, bool absolute)
        {
            double result = 0;

            switch (axis)
            {
            case AXIS.X: result = currentFace[i02].world.x - currentFace[i01].world.x; break;

            case AXIS.Y: result = currentFace[i02].world.y - currentFace[i01].world.y; break;

            case AXIS.Z: result = currentFace[i02].world.z - currentFace[i01].world.z; break;
            }
            return(absolute ? Math.Abs(result) : result);
        }
Example #22
0
    public static GUIContent[] GetHcEffectControls_Trans(AXIS nTransAxis)
    {
        GUIContent[]	cons = new GUIContent[8];

        cons[0]	= new GUIContent("Stop"		,  "");
        cons[1]	= new GUIContent(nTransAxis.ToString() + " Move"	, "");
        cons[2]	= new GUIContent(nTransAxis.ToString() + " Scale", "");
        cons[3]	= new GUIContent("Arc"		, "");
        cons[4]	= new GUIContent("Fall"		, "");
        cons[5]	= new GUIContent("Raise"	, "");
        cons[6]	= new GUIContent("Circle"	, "");
        cons[7]	= new GUIContent("Tornado"	, "");
        return cons;
    }
Example #23
0
    public void playerMovement(float speed, AXIS axis)
    {
        // Move the character by finding the target velocity

        if (axis == AXIS.HORIZONTAL)
        {
            targetVelocity = new Vector2(speed * 2f, playerRigidbody.velocity.y);
        }
        else if (axis == AXIS.VERTICAL)
        {
            targetVelocity = new Vector2(playerRigidbody.velocity.x, speed * 2f);
        }
        playerRigidbody.velocity = targetVelocity;
    }
Example #24
0
        /**
         * Returns the change in distance between the nose-fixpoint along a specified axis
         * @param int i01 - landmark-number
         * @param AXIS axis - axis to consider
         */
        public double DifferenceNullCurrent(int i01, AXIS axis)
        {
            double result = 0;

            switch (axis)
            {
            case AXIS.X: result = (nullFace[NOSE_FIX].world.x - nullFace[i01].world.x) - (currentFace[NOSE_FIX].world.x - currentFace[i01].world.x); break;

            case AXIS.Y: result = (nullFace[NOSE_FIX].world.y - nullFace[i01].world.y) - (currentFace[NOSE_FIX].world.y - currentFace[i01].world.y); break;

            case AXIS.Z: result = (nullFace[NOSE_FIX].world.z - nullFace[i01].world.z) - (currentFace[NOSE_FIX].world.z - currentFace[i01].world.z); break;
            }
            return(result);
        }
Example #25
0
 public void AddAxis(AXIS ax)
 {
     if (true)//if (ax.isInit)
     {
         if (list_ax.Contains(ax) == false)
         {
             list_ax.Add(ax);
             FillTableWithAxisInf(ax);
         }
     }
     else
     {
         VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, String.Format("轴状态列表,{0} 未初始化!", ax.disc));
         return;
     }
 }
Example #26
0
        // todo: refactoring
        public virtual void Impact(Vector3 _originalLocalPosition, bool _destroy,
                                   float _duration, float _maxAngle, float _amplitude, float _count, AXIS _axis = AXIS.Y)
        {
            /*if (duration != 0.0f)
             * {
             *  originalPosition = gameObject.transform.position;
             * }*/
            destroy          = _destroy;
            originalPosition = _originalLocalPosition;
            duration         = 0.0f;
            amplitude        = _amplitude;
            elapsedTime      = 0.0f;
            axis             = _axis;

            maxAngle = _maxAngle * _count;
            duration = _duration;
        }
Example #27
0
        // todo: refactoring
        public virtual void Impact(Vector3 _originalLocalPosition, bool _destroy,
            float _duration, float _maxAngle, float _amplitude, float _count, AXIS _axis = AXIS.Y)
        {
            /*if (duration != 0.0f)
            {
                originalPosition = gameObject.transform.position;
            }*/
            destroy = _destroy;
            originalPosition = _originalLocalPosition;
            duration = 0.0f;
            amplitude = _amplitude;
            elapsedTime = 0.0f;
            axis = _axis;

            maxAngle = _maxAngle * _count;
            duration = _duration;
        }
Example #28
0
    public void SimpleSmartUVMapping()
    {
        Mesh mesh = this.GetComponent <MeshFilter>().sharedMesh;

        Vector2[] uv    = new Vector2[mesh.vertices.Length];
        float     scale = 0.2f;

        //Debug.Log("uv: " + mesh.vertices.Length);
        //Debug.Log("normal: " + mesh.normals.Length);
        Vector3[] axis_vecs = new Vector3[] { Vector3.left, Vector3.right, Vector3.up, Vector3.down, Vector3.forward, Vector3.back };
        AXIS[]    axises    = new AXIS[] { AXIS.X, AXIS.X, AXIS.Y, AXIS.Y, AXIS.Z, AXIS.Z };

        for (var mi = 0; mi < mesh.vertices.Length; mi++)
        {
            Vector3 v         = mesh.vertices[mi];
            Vector3 normal    = mesh.normals[mi];
            float   min_angle = 360f;
            AXIS    hit_axis  = AXIS.X; //Axis which the nomal vector looks at.

            for (int ai = 0; ai < axises.Length; ai++)
            {
                float angle = Vector3.Angle(normal, axis_vecs[ai]);
                if (angle < min_angle)
                {
                    min_angle = angle;
                    hit_axis  = axises[ai];
                }
            }

            //UV mapping based on direction of normal map
            if (hit_axis == AXIS.X)
            {
                uv[mi] = new Vector2(v.y, v.z) * scale;
            }
            else if (hit_axis == AXIS.Y)
            {
                uv[mi] = new Vector2(v.x, v.z) * scale;
            }
            else if (hit_axis == AXIS.Z)
            {
                uv[mi] = new Vector2(v.x, v.y) * scale;
            }
        }
        this.GetComponent <MeshFilter>().sharedMesh.uv = uv;
    }
        /// <summary>
        /// Create the mesh from specified points, thickness, name and axis
        /// </summary>
        public Meshes Create(List <Vector3> points, float thickness, string name, AXIS axis = AXIS.Y)
        {
            GameObject meshObject = new GameObject(name);

            meshObject.name = name;
            meshObject.transform.position = GetMidPt(points);

            //get the vertices for building mesh
            Vector3[] verts = GetVertices(meshObject.transform, points, thickness, axis);

            Vector2[] pointsToTriangulate = ConvertPointsTo2DArray(meshObject.transform, verts, axis);

            //get necessary triangles to build mesh
            int[] triangles = GetTriangles(pointsToTriangulate, points.Count);

            //If the thickness is less than 0 then the triangles needs to be reversed
            //so that normals will be proper
            if (thickness < 0)
            {
                triangles = ReverseTriangles(triangles, points.Count);
            }

            //generate mesh using the vertices and triangles
            Mesh mesh = CreateMesh(verts, triangles);

            //UV projection for generated mesh
            BoxProjection b = new BoxProjection();

            b.BoxUvProjection(mesh, axis);

            //add mesh filter
            MeshFilter meshFilter = meshObject.AddComponent(typeof(MeshFilter)) as MeshFilter;

            meshFilter.mesh = mesh;

            //add meshrenderer
            Renderer renderer = meshObject.AddComponent(typeof(MeshRenderer)) as Renderer;

            renderer.material = new Material(Shader.Find("Standard"));

            //create object for floor/ceiling
            Meshes meshObj = new Meshes(name, mesh, renderer, thickness);

            return(meshObj);
        }
Example #30
0
        public GPIO(ushort io_num, AXIS ax, IO_DIR dir, IO_TYPE type, string disc, IO_STA default_sta = IO_STA.NULL, bool binvert = false)
        {
            this.bInvert = binvert;
            axis         = ax;
            card         = ax.card;
            if (card != null)
            {
                m_id = (int)(card.id << 8) + (int)(io_num & 0xFF);
            }
            else
            {
                m_id = -1;
            }

            num              = io_num;
            this.dir         = dir;
            this.type        = type;
            str_disc         = disc;
            this.default_sta = default_sta;

            //check num
            if (num < 0 || ((int)type == (int)IO_TYPE.VIRTUAL_ELN && (int)type == (int)IO_TYPE.VIRTUAL_ORG) && num >= card.ax_num)
            {
                VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, String.Format("{0} io_num {1} 超范围[{2},{3})", disc, num, 0, card.ax_num));
            }
            else
            {
                if (dir == IO_DIR.IN && (type == IO_TYPE.MT_CARD && num >= card.input_num) || (type == IO_TYPE.IO_CARD && num > card.input_num))
                {
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, String.Format("{0} io_num {1} 超范围[{2},{3}]", disc, num, 0, card.input_num));
                }
                if (dir == IO_DIR.OUT && (type == IO_TYPE.MT_CARD && num >= card.output_num) || (type == IO_TYPE.IO_CARD && num > card.output_num))
                {
                    VAR.msg.AddMsg(Msg.EM_MSGTYPE.ERR, String.Format("{0} io_num {1} 超范围[{2},{3}]", disc, num, 0, card.output_num));
                }
            }

            ChkSafe = null;

            if (card != null)
            {
                card.GPIOList.Add(this);
            }
        }
Example #31
0
/******************************************************
 * Function: GetAxis
 * Parameters: 
 *		whichPlayer - Players ONE through FOUR
 *		whichJoystick - Left, Right, or DPAD
 *		whichAxis - X or Y
 * Return:
 *		Returns the float value of the axis desired for
 *		the specific player and joystick 
******************************************************/
	public static float GetAxis(PLAYER_NUMBER whichPlayer, JOYSTICK whichJoystick, AXIS whichAxis)
	{
		float axisValue = 0.0f;

		string inputToCheck = "";

#if UNITY_ANDROID
		if (whichJoystick != JOYSTICK.LEFT)
			inputToCheck += "A_";
#endif

		inputToCheck += "P" + ((int)whichPlayer).ToString() + "_";

		switch (whichJoystick)
		{
			case JOYSTICK.LEFT:
				inputToCheck += "LeftStick_";
				break;
			case JOYSTICK.RIGHT:
				inputToCheck += "RightStick_";
				break;
			case JOYSTICK.DPAD:
				inputToCheck += "DPad_";
				break;
			default:
				break;
		}

		switch (whichAxis)
		{
			case AXIS.X:
				inputToCheck += "X";
				break;
			case AXIS.Y:
				inputToCheck += "Y";
				break;
			default:
				return 0.0f;
		}

		axisValue = Input.GetAxis(inputToCheck);

		return axisValue;
	}
        /// Identifies the axis for the given points.
        AXIS GetAxisFromPoints(List <Vector3> points)
        {
            AXIS axis = AXIS.X;

            if (points.All(x => Mathf.Approximately(Mathf.Abs(Mathf.Floor(x.x)), Mathf.Abs(Mathf.Floor(points.FirstOrDefault().x)))))
            {
                axis = AXIS.X;
            }
            else if (points.All(y => Mathf.Approximately(Mathf.Abs(Mathf.Floor(y.y)), Mathf.Abs(Mathf.Floor(points.FirstOrDefault().y)))))
            {
                axis = AXIS.Y;
            }
            else if (points.All(z => Mathf.Approximately(Mathf.Abs(Mathf.Floor(z.z)), Mathf.Abs(Mathf.Floor(points.FirstOrDefault().z)))))
            {
                axis = AXIS.Z;
            }
            else
            {
                throw new UnityException("Give points with any one axis as constant.AXIS out of alignment");
            }
            return(axis);
        }
        /// <summary>
        /// Converts the points.
        /// </summary>
        /// <returns>The points.</returns>
        Vector2[] ConvertPointsTo2DArray(Transform trans, Vector3[] points, AXIS axis)
        {
            Vector2[] convertedPoints = new Vector2[points.Length];

            for (int i = 0; i < points.Length; i++)
            {
                if (axis == AXIS.X)
                {
                    convertedPoints[i] = trans.TransformPoint(new Vector2(points[i].z, points[i].y));
                }
                else if (axis == AXIS.Y)
                {
                    convertedPoints[i] = trans.TransformPoint(new Vector2(points[i].x, points[i].z));
                }
                else if (axis == AXIS.Z)
                {
                    convertedPoints[i] = trans.TransformPoint(new Vector2(points[i].x, points[i].y));
                }
            }

            return(convertedPoints);
        }
Example #34
0
    void DrawGizmoAxis(Transform selTrans, AXIS drawAxis, float fLineLen, bool bDrawLocalAxis)
    {
        Vector3 vecDirect = Vector3.zero;
        Vector3 vecPos    = Vector3.zero;

        if (Camera.main == null)
        {
            return;
        }

        // set color
        switch (drawAxis)
        {
        case AXIS.X: Handles.color = Color.red;                 break;

        case AXIS.Y: Handles.color = Color.green;               break;

        case AXIS.Z: Handles.color = Color.blue;                break;
        }

        // set alpha
        if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.HAND)
        {
            Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, m_fHandAlpha);
        }

        // axis color
        Gizmos.color = Handles.color;

        // draw line
        vecPos    = GetPosition(selTrans);
        vecDirect = GetDirect(selTrans, drawAxis, bDrawLocalAxis);
        Gizmos.DrawRay(vecPos, vecDirect * fLineLen);
        float fCapSize = fLineLen * 0.06f * m_fCapSizeRatio;

        Gizmos.DrawSphere(vecPos + vecDirect * fLineLen, fCapSize);
//		Handles.SphereCap(0, vecPos + vecDirect * fLineLen, Quaternion.identity, fCapSize*2);
    }
Example #35
0
        /// <summary>
        /// Box uv projection.
        /// texture scale is set to 1 metres
        /// Default rotation is set to 0
        /// Default projection axis is set to Y
        /// </summary>
        public void BoxUvProjection(Mesh mesh, AXIS projectAxis = AXIS.Y, float textureScale = 1f, float uvRot = 0f)
        {
            Vector3[] vertices   = mesh.vertices;
            Vector2[] uvs        = new Vector2[vertices.Length];
            Vector2[] rotated_uv = new Vector2[vertices.Length];

            if (projectAxis == AXIS.X)
            {
                for (int i = 0; i < vertices.Length; i++)
                {
                    uvs[i] = new Vector2(vertices[i].z / (textureScale), vertices[i].y / (textureScale));
                }
            }
            else if (projectAxis == AXIS.Y)
            {
                for (int i = 0; i < vertices.Length; i++)
                {
                    uvs[i] = new Vector2(vertices[i].x / (textureScale), vertices[i].z / (textureScale));
                }
            }
            else if (projectAxis == AXIS.Z)
            {
                for (int i = 0; i < vertices.Length; i++)
                {
                    uvs[i] = new Vector2(vertices[i].x / (textureScale), vertices[i].y / (textureScale));
                }
            }

            //Rotate UV
            for (int index = 0; index < uvs.Length; index++)
            {
                rotated_uv[index] = Quaternion.AngleAxis(uvRot, Vector3.forward) * uvs[index];
            }

            //Apply UV to mesh
            mesh.uv = rotated_uv;
        }
Example #36
0
/******************************************************
 * Function: GetMouse
 * Parameters: 
 *		whichAxis - X, Y, Scrollwheel
 * Return:
 *		Returns the float value of the axis desired. 
******************************************************/
	public static float GetMouse(AXIS whichAxis)
	{
		float axisValue = 0.0f;

		string inputToCheck = "Mouse_";

		switch (whichAxis)
		{
			case AXIS.X:
				inputToCheck += "X";
				break;
			case AXIS.Y:
				inputToCheck += "Y";
				break;
			case AXIS.SCROLLWHEEL:
				inputToCheck += "Scrollwheel";
				break;
			default:
				break;
		}

		axisValue = Input.GetAxis(inputToCheck);

		return axisValue;
	}
Example #37
0
	Vector3 GetEuler(Transform selTrans, AXIS axis, bool bLocal)
	{
		if (bLocal)
		{
			Quaternion quat = Quaternion.identity;
			switch (axis)
			{
				case AXIS.X: quat.SetLookRotation(selTrans.right);		break;
				case AXIS.Y: quat.SetLookRotation(selTrans.up);			break;
				case AXIS.Z: quat.SetLookRotation(selTrans.forward);	break;
			}
			return quat.eulerAngles;
		} else {
			switch (axis)
			{
				case AXIS.X: return new Vector3(0, 90, 0);
				case AXIS.Y: return new Vector3(-90, 0, 0);
				case AXIS.Z: return new Vector3(0, 0, 0);
			}
		}
		return Vector3.forward;
	}
Example #38
0
        /// <summary>
        /// Gets a plane by axis, indexed by pl. See documentation for graphical
        /// explanation. Complications arise due to cube orientation towards end user.
        /// 
        /// For instance: 
        /// GetPlane(AXIS_Y, 1) --> return the A-Z plane at B=1.
        /// GetPlane(AXIS_X, 0) --> return the B-Z plane at A=0.
        /// GetPlane(AXIS_Z, 3) --> return the A-B plane at Z=3.
        /// 
        /// </summary>
        /// <returns>The plane indexed by pl on the axis axis.</returns>
        /// <param name="axis">The axis of the plane.</param>
        /// <param name="pl">The index of the plane.</param>
        public bool[][] GetPlane(AXIS axis, int pl)
        {
            bool[][] tmpplane = NewEmptyPlane(DIMENSION);

            switch (axis) {

            case AXIS.AXIS_X:
                for (int y = 0; y < DIMENSION; ++y) {
                    for (int z = 0; z < DIMENSION; ++z) {
                        tmpplane[y][z] = GetVoxel(pl, y, z);
                    }
                }
                break;

            case AXIS.AXIS_Y:
                for (int x = 0; x < DIMENSION; ++x) {
                    for (int z = 0; z < DIMENSION; ++z) {
                        tmpplane[x][z] = GetVoxel(x, pl, z);
                    }
                }
                break;

            case AXIS.AXIS_Z:
                for (int x = 0; x < DIMENSION; ++x) {
                    for (int y = 0; y < DIMENSION; ++y) {
                        tmpplane[x][y] = GetVoxel(y, x, pl);
                    }
                }
                break;

            default:
                break;
            }

            return tmpplane;
        }
Example #39
0
 public void RotateLookAt(float rad, AXIS axis)
 {
     Vector3 nuevoEje = Vector3.Zero;
     switch (axis) {
         case AXIS.X:
             pitch += rad;
             break;
         case AXIS.Y:
             yaw += rad;
             break;
         case AXIS.Z:
             roll += rad;
             break;
     }
     Vector3 cameraReference = new Vector3(0, 0, -1);
     Matrix rotation = Matrix.CreateRotationX(pitch) * Matrix.CreateRotationY(yaw) * Matrix.CreateRotationZ(roll);
     Vector3 referenciaTransformada = Vector3.Transform(cameraReference,rotation);
     this.lookAt = position + referenciaTransformada;
     SetView();
 }
Example #40
0
        /// <summary>
        /// Provides symmetry of the cube along a given axis. 
        /// You can reflect the axis either from origin or from the terminating
        /// end. 
        /// </summary>
        /// <param name="axis">Axis to provide symmetry along.</param>
        /// <param name="refl">Reflection direction.</param>
        public void SymmetryAlongAxis(AXIS axis, REFLECTION refl)
        {
            bool[][] plane_source;

            switch (refl) {
            // Reflect the cube along the plane along the specified axis, starting
            // from origin. The closest planes to 0,0,0 are what source the symmetry.
            case REFLECTION.ORIGIN:
                for (int i = 0; i < (DIMENSION / 2); ++i) {
                    plane_source = GetPlane (axis, i);
                    PatternSetPlane (axis, DIMENSION - 1 - i, plane_source);
                }
                break;
            case REFLECTION.TERMINUS:
                for (int i = 0; i < (DIMENSION / 2); ++i) {
                    plane_source = GetPlane (axis, DIMENSION - 1 - i);
                    PatternSetPlane (axis, i, plane_source);
                }
                break;
            default:
                break;
            }
        }
Example #41
0
        /// <summary>
        /// Turns off all voxels on a given plane of the specified axis.
        /// </summary>
        /// <param name="axis">Axis to manipulate.</param>
        /// <param name="pl">Plane index on axis.</param>
        public void ClearPlane(AXIS axis, int pl)
        {
            if (pl >= 0 && pl < DIMENSION) {

                switch (axis) {
                case AXIS.AXIS_X:
                    for (int y = 0; y < DIMENSION; ++y) {
                        for (int z = 0; z < DIMENSION; ++z) {
                            ClearVoxel(pl, y, z);
                        }
                    }
                    break;

                case AXIS.AXIS_Y:
                    for (int x = 0; x < DIMENSION; ++x) {
                        for (int z = 0; z < DIMENSION; ++z) {
                            ClearVoxel(x, pl, z);
                        }
                    }
                    break;

                case AXIS.AXIS_Z:
                    for (int x = 0; x < DIMENSION; ++x) {
                        for (int y = 0; y < DIMENSION; ++y) {
                            ClearVoxel(x, y, pl);
                        }
                    }
                    break;

                default:
                    break;
                }
            }
        }
Example #42
0
        /// <summary>
        /// Prints a message character by character on a given axis, and sends it flying
        /// either front-to-back or back-to-front. 
        /// 
        /// NOTE: front-to-back is relative to axis, specifically from ORIGIN-to-TERMINUS,
        /// or as close as possible. 
        /// </summary>
        /// <param name="message">Message to transmit.</param>
        /// <param name="axis">Axis to send message along.</param>
        /// <param name="direction">Direction of travel.</param>
        public void MessageFlyOnAxis(string message, AXIS axis, DIRECTION direction)
        {
            // Make sure that the string is a valid message. If it is null or empty, then we
            // have no message to transmit.
            if (String.IsNullOrEmpty (message)) {
                message = "INVALID TEXT";
            }

            foreach (char c in message) {
                PutChar (axis, 0, c);
                for (int i = 0; i < DIMENSION; ++i) {
                    ShiftAndRoll (axis, direction);
                    DelayMS (200);
                }
                ClearEntireCube ();
            }
        }
Example #43
0
	// Update is called once per frame
	void Update()
	{

		m_bUnityGizmos = false;

		// check shotkey
		if (GUI.GetNameOfFocusedControl() != "TextField")
		{
			if (Input.GetKeyDown(KeyCode.Q)) SetGizmoType(0);
			if (Input.GetKeyDown(KeyCode.W)) SetGizmoType(1);
			if (Input.GetKeyDown(KeyCode.E)) SetGizmoType(2);
			if (Input.GetKeyDown(KeyCode.R)) SetGizmoType(3);
			if (Input.GetKeyDown(KeyCode.T)) SetGizmoType(4);
			if (Input.GetKeyDown(KeyCode.Y)) m_bWorldSpace = !m_bWorldSpace;
		}

		GameObject selObj = FXMakerMain.inst.GetFXMakerHierarchy().GetSelectedGameObject();
		if (selObj == null)
			return;
		m_SelectedTransform	= selObj.transform;

		// check click
		if (m_nActiveAxis != AXIS.NONE)
		{
			if (Input.GetMouseButtonDown(0))
			{
				m_OldMousePos			= Input.mousePosition;
				m_OldOriScale			= m_SelectedTransform.localScale;
				m_OldInsScale			= (GetInstanceObject() == null ? Vector3.one : GetInstanceObject().transform.localScale);
				m_OldGizmoLineLength	= NgLayout.GetWorldPerScreenPixel(FXMakerEffect.inst.m_CurrentEffectRoot.transform.position) * (Screen.width * m_fGizmoLinePerScreen * m_fWorldLineRatio);
				m_SaveRotate			= Vector3.zero;
				m_bClick				= true;

				if (m_nGizmoTypeIndex == (int)GIZMO_TYPE.POSITION || m_nGizmoTypeIndex == (int)GIZMO_TYPE.ROTATION || m_nGizmoTypeIndex == (int)GIZMO_TYPE.SCALE)
					FXMakerEffect.inst.SetChangePrefab();
			}
			if (m_bClick && Input.GetMouseButton(0))
			{
				Vector3 currMousePos	= Input.mousePosition;
				Vector3 prevWorldPos	= NgLayout.GetScreenToWorld(m_SelectedTransform.transform.position, m_OldMousePos);
				Vector3 currWorldPos	= NgLayout.GetScreenToWorld(m_SelectedTransform.transform.position, currMousePos);
				
				if (IsLocalSpace())
				{
					Transform	tempTrans	= GetTempTransform();
					tempTrans.rotation		= m_SelectedTransform.rotation;
					currWorldPos = tempTrans.InverseTransformPoint(currWorldPos);
					prevWorldPos = tempTrans.InverseTransformPoint(prevWorldPos);
				}

				switch (((GIZMO_TYPE)m_nGizmoTypeIndex))
				{
					case GIZMO_TYPE.POSITION:
						{
							switch (m_nActiveAxis)
							{
								case AXIS.X: AddTranslate(currWorldPos.x - prevWorldPos.x, 0, 0, m_bActiveLocal); break;
								case AXIS.Y: AddTranslate(0, currWorldPos.y - prevWorldPos.y, 0, m_bActiveLocal); break;
								case AXIS.Z:
									{
										if (m_bFixedSide)
										{
											AddTranslate(currWorldPos.x - prevWorldPos.x, 0, 0, m_bActiveLocal);
											AddTranslate(0, currWorldPos.y - prevWorldPos.y, 0, m_bActiveLocal);
										} else {
											AddTranslate(0, 0, currWorldPos.z - prevWorldPos.z, m_bActiveLocal);
										}
										break;
									}
							}
							break;
						}
					case GIZMO_TYPE.ROTATION:
						{
							switch (m_bFixedSide ? AXIS.Z : m_nActiveAxis)
							{
								case AXIS.X: AddRotation(currWorldPos.z - prevWorldPos.z, 0, 0, m_bActiveLocal); break;
								case AXIS.Y: AddRotation(0, currWorldPos.x - prevWorldPos.x, 0, m_bActiveLocal); break;
								case AXIS.Z: AddRotation(0, 0, prevWorldPos.x - currWorldPos.x, m_bActiveLocal); break;
							}
							break;
						}
					case GIZMO_TYPE.SCALE:
						{
							float	fScaleDist;
							switch (m_nActiveAxis)
							{
								case AXIS.X: fScaleDist = currWorldPos.x - prevWorldPos.x;	AddScale(fScaleDist/m_OldGizmoLineLength, 0, 0);	break;
								case AXIS.Y: fScaleDist = currWorldPos.y - prevWorldPos.y;	AddScale(0, fScaleDist/m_OldGizmoLineLength, 0);	break;
								case AXIS.Z: fScaleDist = currWorldPos.z - prevWorldPos.z;	AddScale(0, 0, fScaleDist/m_OldGizmoLineLength);	break;
								case AXIS.A:
									{
										fScaleDist = (currMousePos.x - m_OldMousePos.x) * NgLayout.GetWorldPerScreenPixel(selObj.transform.position);
										if (m_bFixedSide)
											 AddScale(fScaleDist/m_OldGizmoLineLength, fScaleDist/m_OldGizmoLineLength, 0);
										else AddScale(fScaleDist/m_OldGizmoLineLength, fScaleDist/m_OldGizmoLineLength, fScaleDist/m_OldGizmoLineLength);
										break;
									}
							}
							break;
						}
				}
				m_OldMousePos = currMousePos;
			}
			if (Input.GetMouseButtonUp(0))
			{
				m_nActiveAxis	= AXIS.NONE;
				m_bClick		= false;
				if (IsGridMove() /*&& FXMakerOption.inst.m_bGizmoGridMoveUnit*/)
					UpdateGridMove();
			}
			FXMakerMain.inst.GetFXMakerMouse().SetHandControl(m_bClick == false);
		}
	}
Example #44
0
        /// <summary>
        /// Mirrors the cube along a given axis.
        /// 
        /// If a cube is mirrored along it's Z-axis, the voxels at the top will
        /// now become the voxels at the bottom. They DO NOT change x-y positions
        /// though within the x-y plane from that Z-slice. 
        /// </summary>
        /// <param name="axis">Axis to mirror across.</param>
        public void MirrorCubeAlongAxis(AXIS axis)
        {
            // Get the outer-two most planes along the given axis. Swap them.
            // Then move on to the next inner-two. Swap them as well.
            // Repeat until no planes are left!
            bool[][] plane1;
            bool[][] plane2;

            for (int i = 0; i < (DIMENSION / 2); ++i) {
                plane1 = GetPlane (axis, i);				 // Get the plane closest to origin.
                plane2 = GetPlane (axis, DIMENSION - 1 - i); // Get the plane closest to terminus.

                PatternSetPlane (axis, i, plane2);	// Put plane2 at the beginning.
                PatternSetPlane (axis, DIMENSION - 1 - i, plane1);	// Put plane1 at the end.
            }
        }
Example #45
0
	bool DrawOriginalGizmo(Transform selTrans, bool bLocal)
	{
		float		fLineLen	= NgLayout.GetWorldPerScreenPixel(FXMakerEffect.inst.m_CurrentEffectRoot.transform.position) * (Screen.width * m_fGizmoLinePerScreen * m_fWorldLineRatio);
		float		fCapSize	= fLineLen * 0.07f * m_fCapSizeRatio;
		Vector3		cubeSize	= Vector3.one * fCapSize;
		bool		bSelected	= false;

		// check active
		if ((((GIZMO_TYPE)m_nGizmoTypeIndex) != GIZMO_TYPE.HAND && ((GIZMO_TYPE)m_nGizmoTypeIndex) != GIZMO_TYPE.NONE) && m_bClick == false)
		{
			AXIS nActiveAxis = AXIS.NONE;
			float	fStartClickLen	= fLineLen/4.0f;

			if (HandleUtility.DistanceToLine(GetPosition(selTrans) + GetDirect(selTrans, AXIS.X, bLocal) * fStartClickLen, GetPosition(selTrans) + GetDirect(selTrans, AXIS.X, bLocal) * fLineLen) < m_fActiveDist)
				nActiveAxis = AXIS.X;
			if (HandleUtility.DistanceToLine(GetPosition(selTrans) + GetDirect(selTrans, AXIS.Y, bLocal) * fStartClickLen, GetPosition(selTrans) + GetDirect(selTrans, AXIS.Y, bLocal) * fLineLen) < m_fActiveDist)
				nActiveAxis = AXIS.Y;
			if (HandleUtility.DistanceToLine(GetPosition(selTrans) + GetDirect(selTrans, AXIS.Z, bLocal) * fStartClickLen, GetPosition(selTrans) + GetDirect(selTrans, AXIS.Z, bLocal) * fLineLen) < m_fActiveDist)
				nActiveAxis = AXIS.Z;
			if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.SCALE)
				if (HandleUtility.DistanceToLine(GetPosition(selTrans), GetPosition(selTrans)) < m_fActiveDist)
					nActiveAxis = AXIS.A;

			if (nActiveAxis != AXIS.NONE)
			{
				m_nActiveAxis	= nActiveAxis;
				m_bActiveLocal	= bLocal;
				bSelected		= true;
			} else {
				m_nActiveAxis	= AXIS.NONE;
			}
		}

		// draw Selected gizmo
		DrawGizmoAxis(AXIS.X, bLocal, fLineLen, fCapSize);
		DrawGizmoAxis(AXIS.Y, bLocal, fLineLen, fCapSize);
		DrawGizmoAxis(AXIS.Z, bLocal, fLineLen, fCapSize);

		// World Center Sphere
		Gizmos.color = Color.yellow;
		if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.HAND)
			Gizmos.color = new Color(Gizmos.color.r, Gizmos.color.g, Gizmos.color.b, m_fHandAlpha);
		Gizmos.DrawSphere(Vector3.zero, cubeSize.x/2.0f);

		// selected center
		if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.SCALE)
		{
			if (m_nActiveAxis == AXIS.A && m_bActiveLocal == bLocal)
				 Gizmos.color = Color.white;
			else Gizmos.color = Color.cyan;
			Gizmos.DrawCube(GetPosition(selTrans), cubeSize);
		}

		// Gizmo tooltip, Camera Pos
		if (IsLocalSpace())
			 m_GizmoTooltip = Camera.main.transform.position +  " , GizmosLength = " + fLineLen.ToString("0.000") + " , long=Local";
		else m_GizmoTooltip = Camera.main.transform.position +  " , GizmosLength = " + fLineLen.ToString("0.000") + " , long=World, shot=Local";
		FXMakerMain.inst.SetEmptyTooltip(m_GizmoTooltip);

		return bSelected;
	}
Example #46
0
 public XBOXControllerAnalog(SICK thumbStick, AXIS axis)
 {
     this.axis = axis;
        this.stick = thumbStick;
 }
	public void AutoSetting(int nPlayIndex, int nTransIndex, AXIS nTransAxis, float fDistPerTime, int nRotateIndex, int nMultiShotCount, float fTransRate, float fStartAdjustRate)
	{
		m_nPlayIndex		= nPlayIndex;
		m_nTransIndex		= nTransIndex;
		m_nTransAxis		= nTransAxis;
		m_fDistPerTime		= fDistPerTime;
		m_nRotateIndex		= nRotateIndex;
		m_nMultiShotCount	= nMultiShotCount;
		m_fTransRate		= fTransRate;
		m_fStartPosition	= fStartAdjustRate;
	}
Example #48
0
        /// <summary>
        /// Partially rotates a given plane, not based on strictly 90°, 180°, or
        /// -90° turns. 
        /// </summary>
        /// <param name="axis">Axis to rotate along.</param>
        /// <param name="pl">Plane of axis to rotate.</param>
        /// <param name="theta">Degree of rotation.</param>
        public void PartialRotation(AXIS axis, int pl, double theta)
        {
            // Get the plane that you need to rotate.
            bool[][] tmpplane = GetPlane(axis, pl);

            // List of coordinates of voxels that are set, and which need to
            // be rotated through.
            var coords = new List<Point>();
            var rotated = new List<Point>();

            // Parital rotation is accomplished via the following matrix expansion:
            // | x' | = | cos(θ) - sin(θ) | | x |
            // | y' | = | sin(θ) + cos(θ) | | y |
            //		Therefore
            // x' = x * cos(θ) - y * sin(θ)
            // y' = x * sin(θ) + y * cos(θ)
            double sin_t = Math.Sin(theta);
            double cos_t = Math.Cos(theta);

            int x_prime = 0;
            int y_prime = 0;

            // Determine which voxels are currently set on this plane.
            //	x_prime = (int)((P.B * cos_t) - (P.Z * sin_t));
            //	y_prime = (int)((P.B * sin_t) + (P.Z * cos_t));
        }
Example #49
0
	void DrawGizmoAxis(AXIS	drawAxis, bool bLocal, float fLineLen, float fCapSize)
	{
		Transform	selTrans	= m_SelectedTransform.transform;
		Vector3		vecEuler	= Vector3.zero;
		Vector3		vecDirect	= Vector3.zero;

		// set color
		if (m_nActiveAxis != drawAxis || m_bActiveLocal != bLocal)
		{
			switch (drawAxis)
			{
				case AXIS.X: Handles.color = Color.red;			break;
				case AXIS.Y: Handles.color = Color.green;		break;
				case AXIS.Z: Handles.color = Color.blue;		break;
			}
		} else Handles.color = Color.white;
		if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.HAND)
			Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, m_fHandAlpha);

		// axis color
		Gizmos.color = Handles.color;

		vecDirect	= GetDirect(selTrans, drawAxis, bLocal);
		vecEuler	= GetEuler(selTrans, drawAxis, bLocal);

		// draw line
//		Handles.DrawLine(GetPosition(selTrans), GetPosition(selTrans) + vecDirect * fLineLen);
		if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.SCALE)
		{
			float	scale = 1;
			if (m_bClick)
			{
				switch (drawAxis)
				{
					case AXIS.X: scale = selTrans.localScale.x / m_OldOriScale.x; break;
					case AXIS.Y: scale = selTrans.localScale.y / m_OldOriScale.y; break;
					case AXIS.Z: scale = selTrans.localScale.z / m_OldOriScale.z; break;

				}
			}

			Gizmos.DrawRay(GetPosition(selTrans), vecDirect * fLineLen * scale);
		} else {
			Gizmos.DrawRay(GetPosition(selTrans), vecDirect * fLineLen);
		}

		// draw cap
		switch (((GIZMO_TYPE)m_nGizmoTypeIndex))
		{
			case GIZMO_TYPE.POSITION:	Handles.ConeCap(0, GetPosition(selTrans) + vecDirect * fLineLen, Quaternion.Euler(vecEuler), fCapSize*1.6f);		break;
			case GIZMO_TYPE.ROTATION:	Handles.CylinderCap(0, GetPosition(selTrans) + vecDirect * fLineLen, Quaternion.Euler(vecEuler), fCapSize*2f);		break;
			case GIZMO_TYPE.SCALE:		Handles.CubeCap(0, GetPosition(selTrans) + vecDirect * fLineLen, Quaternion.Euler(vecEuler), fCapSize);				break;
		}
		
// 		// draw rot line
// 		if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.ROTATION)
// 		{
// 			if (m_bClick)
// 			{
//				transform.position	= GetPosition(selTrans);
//				transform.rotation	= Quaternion.Euler(m_SaveRotate);
// 
// 				switch (drawAxis)
// 				{
// 					case AXIS.X: Gizmos.color = Color.red;		Gizmos.DrawLine(GetPosition(selTrans), selTrans.right		* fLineLen * 1.3f);	break;
// 					case AXIS.Y: Gizmos.color = Color.green;	Gizmos.DrawLine(GetPosition(selTrans), selTrans.up			* fLineLen * 1.3f);	break;
// 					case AXIS.Z: Gizmos.color = Color.blue;		Gizmos.DrawLine(GetPosition(selTrans), selTrans.forward		* fLineLen * 1.3f);	break;
// 				}
// 				if (m_nActiveAxis != drawAxis && m_bActiveLocal == bLocal)
// 				{
// 					Gizmos.color = Color.white;
// 					switch (drawAxis)
// 					{
// 						case AXIS.X: Gizmos.DrawLine(transform.position, transform.right	* fLineLen * 2);	break;
// 						case AXIS.Y: Gizmos.DrawLine(transform.position, transform.up		* fLineLen * 2);	break;
// 						case AXIS.Z: Gizmos.DrawLine(transform.position, transform.forward	* fLineLen * 2);	break;
// //						case AXIS.X: Handles.DrawSolidArc(transform.position, transform.right, -transform.up, m_SaveRotate.z, fCapSize*10); break;
// 					}
// 				}
// 			}
// 		}
	}
Example #50
0
        /// <summary>
        /// Shift the specified axis in the specified direction. Roll planes
        /// through (do not discard planes). 
        /// </summary> 
        /// <param name="axis">Axis.</param>
        /// <param name="direction">Direction.</param>
        public void ShiftAndRoll(AXIS axis, DIRECTION direction)
        {
            bool[][] tmpplane;

            if (direction == DIRECTION.FORWARD) {
                // Save the last plane so that it may be rotated through as element 0.
                tmpplane = GetPlane (axis, DIMENSION - 1);
                for (int i = DIMENSION - 1; i > 0; --i) {
                    // Set the ith plane to the plane before it.
                    PatternSetPlane (axis, i, GetPlane(axis, i-1));
                }
                // Rotate the last plane through to the first element.
                PatternSetPlane (axis, 0, tmpplane);
            } else {
                // Save the first plane so it will rotate through as last element.
                tmpplane = GetPlane (axis, 0);
                for (int i = 0; i < DIMENSION - 1; ++i) {
                    // Set the ith plane to the plane after it.
                    PatternSetPlane (axis, i, GetPlane (axis, i+1));
                }
                // Rotate the first plane through as the last element.
                PatternSetPlane (axis, DIMENSION - 1, tmpplane);
            }
        }
Example #51
0
        /// <summary>
        /// Sets a plane indexed by pl on the axis axis to a
        /// given pattern.
        /// 
        /// See documentation for graphical explanation. Complications arise due 
        /// to cube orientation towards end user.
        /// </summary>
        /// <param name="axis">The axis to set the plane on.</param>
        /// <param name="pl">The index of the plane.</param>
        /// <param name="pattern">The pattern to fill the plane with.</param>
        public void PatternSetPlane(AXIS axis, int pl, bool [][] pattern)
        {
            switch (axis) {

            case AXIS.AXIS_X:
                for (int y = 0; y < DIMENSION; ++y) {
                    for (int z = 0; z < DIMENSION; ++z) {
                        SetVoxelFrom(z, y, pl, pattern[y][z]);
                    }
                }
                break;

            //
            case AXIS.AXIS_Y:
                for (int x = 0; x < DIMENSION; ++x) {
                    for (int z = 0; z < DIMENSION; ++z) {
                        SetVoxelFrom(z, pl, x, pattern[x][z]);
                    }
                }
                break;

            case AXIS.AXIS_Z:
                for (int x = 0; x < DIMENSION; ++x) {
                    for (int y = 0; y < DIMENSION; ++y) {
                        SetVoxelFrom(pl, y, x, pattern[x][y]);
                    }
                }
                break;

            default:
                break;
            }
        }
Example #52
0
 /// <summary>
 /// Shift the specified axis in the specified direction. Discard planes
 /// as they reach the boundary. 
 /// </summary> 
 /// <param name="axis">Axis.</param>
 /// <param name="direction">Direction.</param>
 public void ShiftNoRoll(AXIS axis, DIRECTION direction)
 {
     if (direction == DIRECTION.FORWARD) {
         for (int i = DIMENSION - 1; i > 0; --i) {
             // Set the ith plane to the plane before it.
             PatternSetPlane (axis, i, GetPlane(axis, i-1));
         }
         ClearPlane (axis, 0);
     } else {
         for (int i = 0; i < DIMENSION - 1; ++i) {
             PatternSetPlane (axis, i, GetPlane (axis, i+1));
         }
         ClearPlane (axis, DIMENSION - 1);
     }
 }
	// -------------------------------------------------------------------------------------------
	void winActionToolbar(int id)
	{
		Rect		popupRect	= GetActionToolbarRect();
		Rect		baseRect;
		Rect		rect;
		string		info		= "";
		string		infotooltip	= "";
		int			nColCount	= 10;
		int			nRowCount	= 5;
		GUIContent	content;

		// mini ----------------------------------------------------------------
		m_bMinimize = GUI.Toggle(new Rect(3, 1, FXMakerLayout.m_fMinimizeClickWidth, FXMakerLayout.m_fMinimizeClickHeight), m_bMinimize, "Mini");
		if (GUI.changed)
			PlayerPrefs.SetInt("FxmTestControls.m_bMinimize", m_bMinimize ? 1 : 0);
		GUI.changed = false;
		if (FXMakerLayout.m_bMinimizeAll || m_bMinimize)
		{
			nRowCount = 1;
			// mesh info -----------------------------------------------------------------
			baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
			if (FxmTestMain.inst.IsCurrentEffectObject())
			{
				info		= string.Format("P={0} M={1} T={2}", m_nParticleCount, m_nMeshCount, m_nTriangles);
				infotooltip	= string.Format("ParticleCount = {0} MeshCount = {1}\n Mesh: Triangles = {2} Vertices = {3}", m_nParticleCount, m_nMeshCount, m_nTriangles, m_nVertices);
			}
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), info);

			// CurrentTime Horizontal Slider ----------------------------------------------
			if (FxmTestMain.inst.IsCurrentEffectObject())
			{
				float fMaxTime = (m_nRepeatIndex <= m_nPlayIndex) ? m_fPlayToolbarTimes[m_nPlayIndex] : 10.0f;
				baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
				GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 2), "ElapsedTime " + (Time.time - m_fPlayStartTime).ToString("0.000"));
				rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 4, 4);
				rect.y += 5;
				GUI.HorizontalSlider(rect, Time.time - m_fPlayStartTime, 0.0f, fMaxTime);

				// restart
				baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
				if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 2), "Restart"))
					CreateInstanceEffect();
			}

			return;
		}

		// mesh info -----------------------------------------------------------------
		baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 2);
		if (NcEffectBehaviour.GetRootInstanceEffect())
		{
			info		= string.Format("P = {0}\nM = {1}\nT = {2}", m_nParticleCount, m_nMeshCount, m_nTriangles);
			infotooltip	= string.Format("ParticleCount = {0} MeshCount = {1}\n Mesh: Triangles = {2} Vertices = {3}", m_nParticleCount, m_nMeshCount, m_nTriangles, m_nVertices);
		}
		GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 1), new GUIContent(info, NgTooltipTooltip(infotooltip)));

		// control button ------------------------------------------------------------
		if (FxmTestMain.inst.IsCurrentEffectObject())
		{
			bool bClick = false;

			// Play ---------------------------------------
			GUIContent[]	playToolbarContents	= GetHcEffectControls_Play(0, m_fTimeScale, m_fPlayToolbarTimes[1], m_fPlayToolbarTimes[m_nRepeatIndex], m_fPlayToolbarTimes[m_nRepeatIndex+1], m_fPlayToolbarTimes[m_nRepeatIndex+2], m_fPlayToolbarTimes[m_nRepeatIndex+3], m_fPlayToolbarTimes[m_nRepeatIndex+4]);
			baseRect		= FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 0, 1);
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 1, 1), new GUIContent("Play", ""));
			int nPlayIndex	= GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 8), m_nPlayIndex, playToolbarContents, playToolbarContents.Length);

			if (GUI.changed)
				bClick = true;

			// Trans ---------------------------------------
			GUIContent[]	TransToolbarContents	= GetHcEffectControls_Trans(m_nTransAxis);
			baseRect		= FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 1, 1);
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 1, 1), new GUIContent("Trans", ""));
			int nTransIndex	= GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 8), m_nTransIndex, TransToolbarContents, TransToolbarContents.Length);

			if (GUI.changed)
			{
				bClick = true;
				if ((nTransIndex == 1 || nTransIndex == 2) && Input.GetMouseButtonUp(1))	// m_nTransIndex scale
				{
					if (m_nTransAxis == AXIS.Z)
						m_nTransAxis = 0;
					else m_nTransAxis++;
					PlayerPrefs.SetInt("FxmTestControls.m_nTransAxis", (int)m_nTransAxis);
				}
			}

			if (bClick)
			{
				FxmTestMain.inst.CreateCurrentInstanceEffect(false);
				RunActionControl(nPlayIndex, nTransIndex);
				PlayerPrefs.SetInt("FxmTestControls.m_nPlayIndex", m_nPlayIndex);
				PlayerPrefs.SetInt("FxmTestControls.m_nTransIndex", m_nTransIndex);
			}
		}

		// TransSpeed Horizontal Slider -----------------------------------------------
		float	TransSpeed	= m_fDistPerTime;
		baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 2, 1);
		content  = new GUIContent("DistPerTime", "");
		content.text += " " + m_fDistPerTime.ToString("00.00");
		GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), content);
		rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 5);
		rect.y += 5;
		TransSpeed = GUI.HorizontalSlider(rect, TransSpeed, 0.1f, 40.0f);
		// TransSpeed Trans ----------------------------------------------
// 		if (GUI.Button(NgLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 23, 1), new GUIContent("1", "")))
// 			TransSpeed = 1;
		if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 14, 1), new GUIContent("<", "")))
			TransSpeed = (int)(TransSpeed-1);
		if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 15, 1), new GUIContent(">", "")))
			TransSpeed = (int)(TransSpeed+1);
		if (TransSpeed != m_fDistPerTime)
		{
			m_fDistPerTime = (TransSpeed == 0 ? 0.1f : TransSpeed);
			PlayerPrefs.SetFloat("FxmTestControls.m_fDistPerTime", m_fDistPerTime);
			// Trans 惑怕搁.. 官肺 利侩
			if (0 < m_nTransIndex)
				CreateInstanceEffect();
		}

		if (NgLayout.GUIButton(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 9, 1), new GUIContent("Multi", m_nMultiShotCount.ToString()), true))
		{
			if (Input.GetMouseButtonUp(0))
			{
				m_nMultiShotCount++;
				if (4 < m_nMultiShotCount)
					m_nMultiShotCount = 1;
			} else {
				m_nMultiShotCount = 1;
			}
			CreateInstanceEffect();
		}

		// front Rotation ----------------------------------------------
		GUIContent[]		rotateToolbarContents	= GetHcEffectControls_Rotate();
		baseRect			= FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 2, 1);
		int nRotateIndex	= GUI.SelectionGrid(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 1), m_nRotateIndex, rotateToolbarContents, rotateToolbarContents.Length);
		if (nRotateIndex != m_nRotateIndex)
		{
			m_nRotateIndex = nRotateIndex;
			PlayerPrefs.SetInt("FxmTestControls.m_nRotateIndex", m_nRotateIndex);
			// Trans 惑怕搁.. 官肺 利侩
			if (0 < m_nTransIndex)
				CreateInstanceEffect();
		}

		// timeScale Horizontal Slider -----------------------------------------------
		float timeScale = m_fTimeScale;
		baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 3, 1);
		content  = new GUIContent("TimeScale", "");
		content.text += " " + m_fTimeScale.ToString("0.00");
		GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), content);
		rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 5);
		rect.y += 5;
		timeScale = GUI.HorizontalSlider(rect, timeScale, 0.0f, 3.0f);
		if (timeScale == 0)
		{
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 7, 1), new GUIContent("Resume", "")))
				timeScale = m_fOldTimeScale;
		} else {
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 7, 1), new GUIContent("Pause", "")))
				timeScale = 0;
		}
		if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 8, 1), new GUIContent("Reset", "")))
			timeScale = 1;
		SetTimeScale(timeScale);

		// CurrentTime Horizontal Slider ----------------------------------------------
		if (FxmTestMain.inst.IsCurrentEffectObject())
		{
			float fMaxTime = (m_nRepeatIndex <= m_nPlayIndex) ? m_fPlayToolbarTimes[m_nPlayIndex] : 10.0f;
			baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 4, 1);
			content  = new GUIContent("ElapsedTime", "");
			content.text += " " + (Time.time - m_fPlayStartTime).ToString("0.000");
			GUI.Box(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 0, 2), content);
			rect = FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 2, 5);
			rect.y += 5;
			GUI.HorizontalSlider(rect, Time.time - m_fPlayStartTime, 0.0f, fMaxTime);
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 14, 1), new GUIContent("+.5", "")))
			{
				SetTimeScale(1.0f);
				Invoke("invokeStopTimer", 0.5f);
			}
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 15, 1), new GUIContent("+.1", "")))
			{
				SetTimeScale(0.4f);
				Invoke("invokeStopTimer", 0.1f);
			}
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 16, 1), new GUIContent("+.05", "")))
			{
				SetTimeScale(0.2f);
				Invoke("invokeStopTimer", 0.05f);
			}
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount*2, 17, 1), new GUIContent("+.01", "")))
			{
				SetTimeScale(0.04f);
				Invoke("invokeStopTimer", 0.01f);
			}

			// restart
			baseRect = FXMakerLayout.GetChildVerticalRect(popupRect, 0, nRowCount, 3, 2);
			if (GUI.Button(FXMakerLayout.GetInnerHorizontalRect(baseRect, nColCount, 9, 1), new GUIContent("Restart", "")))
				CreateInstanceEffect();
		}
	}
Example #54
0
 /// <summary>
 /// Writes a specified to a plane along axis. 
 /// </summary>
 /// <param name="axis">Axis to write along.</param>
 /// <param name="pl">Plane to modify.</param>
 /// <param name="c">Character to write (lookup bitmap).</param>
 public void PutChar(AXIS axis, int pl, char c)
 {
     PatternSetPlane (axis, pl, GetChar (c));
 }
	public void SetDefaultSetting()
	{
		m_nPlayIndex		= 0;
		m_nTransIndex		= 0;
		m_nTransAxis		= AXIS.Z;
		m_fDistPerTime		= 10;
		m_nRotateIndex		= 0;
		m_nMultiShotCount	= 1;
		m_fTransRate		= 1;
		m_fStartPosition	= 0;
		SavePrefs();
	}
Example #56
0
	void DrawGuiGizmoAxis(AXIS drawAxis, float fLineLen, bool bDrawLocalAxis)
	{
		Vector3		vecDirect	= Vector3.zero;
		Vector3		vecPos		= Vector3.zero;
		Color		color		= Color.white;

		if (Camera.main == null)
			return;

		// set color
		switch (drawAxis)
		{
			case AXIS.X: color = Color.red;			break;
			case AXIS.Y: color = Color.green;		break;
			case AXIS.Z: color = Color.blue;		break;
		}

		// draw line
		float		fDist		= FXMakerMain.inst.GetFXMakerMouse().m_fDistance;
		Rect		baseRect	= FXMakerLayout.GetEffectHierarchyRect();
		Vector3		guiCenPos	= new Vector3(Screen.width/2, Screen.height/2, fDist);
		Vector3		guiPos		= new Vector3(baseRect.x-50, baseRect.y+30) - guiCenPos;
		Transform	tempTrans	= GetTempTransform();

		tempTrans.position	= Camera.main.ScreenToWorldPoint(guiCenPos);
		vecDirect			= tempTrans.position + GetDirect(tempTrans, drawAxis, true) * fDist/20;
		vecPos				= Camera.main.WorldToScreenPoint(vecDirect);
		vecPos.y = Screen.height - vecPos.y;
 		NgGUIDraw.DrawLine(guiPos+guiCenPos, guiPos+vecPos, color, 3, true);
	}
Example #57
0
        /// <summary>
        /// A single plane of all-set voxels is sent along
        /// [axis] away from ORIGIN towards TERMINUS. 
        /// 
        /// When the plane reaches TERMINUS, it delays for [speed] milliseconds.
        /// </summary>
        /// <param name="axis">Axis.</param>
        /// <param name="speed">Speed.</param>
        public void AxisBoing(AXIS axis, int speed)
        {
            // Always set the ORIGIN plane first.
            SetPlane (axis, 0);

            // Because the ORIGIN plane is already set, we only have to Shift DIMENSION-1 times.
            for (int i = 0; i < DIMENSION-1; ++i) {
                ShiftAndRoll (axis, DIRECTION.FORWARD);
                DelayMS (speed);
            }
            DelayMS (speed*2);
            for (int i = 0; i < DIMENSION-1; ++i) {
                ShiftAndRoll (axis, DIRECTION.REVERSE);
                DelayMS (speed);
            }
        }
Example #58
0
	Vector3 GetDirect(Transform selTrans, AXIS axis, bool bLocal)
	{
		if (bLocal)
		{
			switch (axis)
			{
				case AXIS.X: return selTrans.right;
				case AXIS.Y: return selTrans.up;
				case AXIS.Z: return selTrans.forward;
			}
		} else {
			switch (axis)
			{
				case AXIS.X: return Vector3.right;
				case AXIS.Y: return Vector3.up;
				case AXIS.Z: return Vector3.forward;
			}
		}
		return Vector3.forward;
	}
Example #59
0
        /// <summary>
        /// Rotates the plane.
        /// 
        /// Rotate by +90:
        /// 	Transpose matrix.
        /// 	Reverse rows.
        ///
        /// Rotate by +180:
        /// 	Reverse each row, then each column. 
        /// 
        /// Rotate by +270:
        /// 	Transpose matrix.
        /// 	Reverse columns.
        /// 
        /// See: http://stackoverflow.com/a/8664879
        /// </summary>
        /// <param name="axis">Axis.</param>
        /// <param name="pl">Pl.</param>
        /// <param name="theta">Theta.</param>
        public void RotatePlane(AXIS axis, int pl, int theta)
        {
            // Acquire the plane on the axis you intend to rotate.
            bool[][] plane = GetPlane (axis, pl);

            switch (theta) {

            case 90:
                Transpose2D (ref plane);
                RowReversal2D (ref plane);
                break;

            case 180:
                Transpose2D (ref plane);
                RowReversal2D (ref plane);
                ColumnReversal2D (ref plane);
                break;

            case 270:
                Transpose2D (ref plane);
                ColumnReversal2D (ref plane);
                break;

            default:
                break;
            }

            // Write your changes to the cube.
            PatternSetPlane (axis, pl, plane);
        }
Example #60
0
	void DrawGizmoAxis(Transform selTrans, AXIS drawAxis, float fLineLen, bool bDrawLocalAxis)
	{
		Vector3		vecDirect	= Vector3.zero;
		Vector3		vecPos		= Vector3.zero;

		if (Camera.main == null)
			return;

		// set color
		switch (drawAxis)
		{
			case AXIS.X: Handles.color = Color.red;			break;
			case AXIS.Y: Handles.color = Color.green;		break;
			case AXIS.Z: Handles.color = Color.blue;		break;
		}

		// set alpha
		if (((GIZMO_TYPE)m_nGizmoTypeIndex) == GIZMO_TYPE.HAND)
			Handles.color = new Color(Handles.color.r, Handles.color.g, Handles.color.b, m_fHandAlpha);

		// axis color
		Gizmos.color = Handles.color;

		// draw line
		vecPos		= GetPosition(selTrans);
		vecDirect	= GetDirect(selTrans, drawAxis, bDrawLocalAxis);
		Gizmos.DrawRay(vecPos, vecDirect * fLineLen);
		float		fCapSize	= fLineLen * 0.06f * m_fCapSizeRatio;
		Gizmos.DrawSphere(vecPos + vecDirect * fLineLen, fCapSize);
//		Handles.SphereCap(0, vecPos + vecDirect * fLineLen, Quaternion.identity, fCapSize*2);
	}