Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        bool button1State = PluginImport.GetButton1State();

        if (button1State && !previousButton1State)
        {
            penColorNum = (penColorNum + 1) % penColors.Length;
        }
        previousButton1State = button1State;

        //if (PluginImport.GetButton2State()) cleanBoard();
        bool eraseState = PluginImport.GetButton2State();

        if (eraseState)
        {
            changePenColor(new Color(0.25f, 0.25f, 0.25f));
        }
        else
        {
            changePenColor(penColorNum);
        }

        bool shouldDraw = PluginImport.GetContact() && (myCounter > 0);

        if (shouldDraw)
        {
            double[] pos       = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyPosition());
            double[] dir       = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyDirection());
            Vector3  position  = new Vector3((float)pos[0], (float)pos[1], (float)pos[2]);
            Vector3  direction = new Vector3((float)dir[0], (float)dir[1], (float)dir[2]);

            double[] realPos      = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetDevicePosition());
            Vector3  realPosition = new Vector3((float)realPos[0], (float)realPos[1], (float)realPos[2]);
            float    force        = (realPosition - position).magnitude;
            if (force > 1.0f)
            {
                force = 1.0f;
            }

            RaycastHit hitInfo = new RaycastHit();
            bool       hasHit  = Physics.Raycast(position, direction, out hitInfo);

            if (previousShouldDraw)
            {
                drawBlobLine(previousCoord, hitInfo.textureCoord, blobRadius, penColors[penColorNum], force, blobSteps, eraseState);
            }
            else
            {
                drawBlob(hitInfo.textureCoord, blobRadius, penColors[penColorNum], force, eraseState);
            }
            previousCoord = hitInfo.textureCoord;

            boardTexture.SetPixels(boardPixels);
            boardTexture.Apply();
        }
        previousShouldDraw = shouldDraw;
        myCounter++;
    }
Exemplo n.º 2
0
    /******************************************************************************************************************************************************************/

    //Get Proxy Position and Orientation generic function
    public void GetProxyValues()

    {
        /*Proxy Position*/

        //Convert IntPtr to Double3Array
        myProxyPosition = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyPosition());
        Debug.Log(myProxyPosition);

        //Attach the Cursor Node
        Vector3 positionCursor = new Vector3();

        positionCursor = ConverterClass.ConvertDouble3ToVector3(myProxyPosition);

        //Assign Haptic Values to Cursor
        myHapticClassScript.hapticCursor.transform.position = positionCursor;


        //Proxy Right - Not use in that case
        //Convert IntPtr to Double3Array
        myProxyRight = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyRight());
        //Attach the Cursor Node
        Vector3 rightCursor = new Vector3();

        rightCursor = ConverterClass.ConvertDouble3ToVector3(myProxyRight);

        //Proxy Direction
        //Convert IntPtr to Double3Array
        myProxyDirection = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyDirection());
        //Attach the Cursor Node
        Vector3 directionCursor = new Vector3();

        directionCursor = ConverterClass.ConvertDouble3ToVector3(myProxyDirection);

        //Proxy Torque
        myProxyTorque = ConverterClass.ConvertIntPtrToDouble3(PluginImport.GetProxyTorque());
        //Attach the Cursor Node
        Vector3 torqueCursor = new Vector3();

        torqueCursor = ConverterClass.ConvertDouble3ToVector3(myProxyTorque);

        //Set Orientation
        myHapticClassScript.hapticCursor.transform.rotation = Quaternion.LookRotation(directionCursor, torqueCursor);

        //Proxy Orientation
        //Convert IntPtr to Double4Array

        /*myProxyOrientation = ConverterClass.ConvertIntPtrToDouble4(PluginImport.GetProxyOrientation());
         *
         *      //Attach the Cursor Node
         *      Vector4 OrientationCursor = new Vector4();
         *      OrientationCursor = ConverterClass.ConvertDouble4ToVector4(myProxyOrientation);
         *
         *      //Assign Haptic Values to Cursor
         *      myHapticClassScript.hapticCursor.transform.rotation =  new Quaternion(OrientationCursor.x,OrientationCursor.y,OrientationCursor.z,OrientationCursor.w);
         * Debug.Log(OrientationCursor.x + "  " + OrientationCursor.y + "  " + OrientationCursor.z + "  " + OrientationCursor.w);*/
    }