void InitHaptics()
    {
        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);

        //Retrieve texture data from bitmap.
        Texture2D _texture = Resources.Load("letter-exploration-texture") as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }
Пример #2
0
    private void AddHapticSprite(string type)
    {
        //HapticServiceAdapter hapticServiceAdapter = HapticServiceAdapter.GetInstance();

        Texture2D texture = Resources.Load(type) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(texture, TanvasTouch.HapticUtil.Mode.Brightness);

        HapticTexture hapticTexture = HapticTexture.Create(hapticServiceAdapter);

        hapticTexture.SetSize(texture.width, texture.height);
        hapticTexture.SetData(textureData);

        HapticMaterial hapticMaterial = HapticMaterial.Create(hapticServiceAdapter);

        hapticMaterial.SetTexture(0, hapticTexture);

        hapticSprite = HapticSprite.Create(hapticServiceAdapter);
        hapticSprite.SetMaterial(hapticMaterial);
        //hapticSprite.SetSize(texture.width, texture.height);
        //hapticSprite.SetPosition((Screen.width - texture.width) / 2, ((int)transform.localPosition.y) + (Screen.height - texture.height) / 2);

        hapticView.AddSprite(hapticSprite);

        hapticSprites.Add(type, hapticSprite);
    }
    void InitHaptics()
    {
        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);

        //Retrieve texture data from bitmap.
        string imagePath = "Letters/big-letter-" + MenuScript.chosenLetter + "-texture";

        /*switch (MenuScript.chosenLetter)
         * {
         *  case 'c':
         *      Debug.Log("Activating C haptic.");
         *      imagePath = "Letters/big-letter-c-texture";
         *      break;
         *  case 'm':
         *      Debug.Log("Activating M haptic");
         *      imagePath = "Letters/big-letter-m-texture";
         *      break;
         *  case 'r':
         *      Debug.Log("Activating R haptic");
         *      imagePath = "Letters/big-letter-r-texture";
         *      break;
         *  case 't':
         *      Debug.Log("Activating T haptic");
         *      imagePath = "Letters/big-letter-t-texture";
         *      break;
         * }*/

        Texture2D _texture = Resources.Load(imagePath) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }
    void InitHaptics()
    {
        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);

        //Retrieve texture data from bitmap.
        string imagePath = "";

        switch (this.gameObject.name)
        {
        case "NoiseBrushMesh":
            Debug.Log("Activating noise haptic.");
            imagePath = "noise_texture";
            break;

        case "BumpyBrushMesh":
            Debug.Log("Activating bumpy haptic.");
            imagePath = "bumpy_texture";
            break;

        case "SoftBrushMesh":
            Debug.Log("Activating soft haptic.");
            imagePath = "soft_texture";
            break;
        }

        //Retrieve texture data from bitmap.
        Texture2D _texture = Resources.Load(imagePath) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }
Пример #5
0
    void InitHaptics()
    {
        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);

        //Retrieve texture data from bitmap.
        string imagePath = "";

        switch (this.gameObject.name)
        {
        case "SquareHaptic1":
            imagePath = "Textures/noise_highres/noise-blur";
            break;

        case "SquareHaptic3":
            imagePath = "Textures/noise_highres/noise-original";
            break;

        case "SquareHaptic5":
            imagePath = "Textures/noise_highres/noise-sharp";
            break;
        }
        Texture2D _texture = Resources.Load(imagePath) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }
Пример #6
0
    //initializing the application's haptic resources
    public void InitHaptics()
    {
        Debug.Log("I see haptics");

        //Retrieve texture data from bitmap.
        string imagePath = "";

        //imagePath = "Textures/noise/noise_texture3";

        switch (this.gameObject.name)

        {
        //C1 version: haptics become finer with less current

        case "HapticMeshA":
            imagePath = "Textures/test/test1-test";
            Debug.Log("texture is textureA");
            break;

        case "HapticMeshB":
            imagePath = "Textures/test/test2-test";
            Debug.Log("texture is textureB");
            break;

        case "HapticMeshC":
            imagePath = "Textures/test/test2-test";
            Debug.Log("texture is textureC");
            break;

        case "HapticMeshD":
            imagePath = "Textures/test/test3-test";
            Debug.Log("texture is textureD");
            break;

        /*
         * //C2 version: haptics become coarser with less current
         * case "HapticMeshA":
         * imagePath = "Textures/test/test3-test";
         * Debug.Log("texture is textureA");
         * break;
         * case "HapticMeshB":
         * imagePath = "Textures/test/test2-test";
         * Debug.Log("texture is textureB");
         * break;
         * case "HapticMeshC":
         * imagePath = "Textures/test/test2-test";
         * Debug.Log("texture is textureC");
         * break;
         * case "HapticMeshD":
         * imagePath = "Textures/test/test1-test";
         * Debug.Log("texture is textureD");
         * break;
         */
        // Resistor haptics
        case "HapticMesh1":
            imagePath = "Textures/stripes/stripe1";
            Debug.Log("texture is texture1");
            break;

        case "HapticMesh2":
            imagePath = "Textures/stripes/stripe1two";
            Debug.Log("texture is texture2");
            break;

        case "HapticMesh3":
            imagePath = "Textures/stripes/stripe1three";
            Debug.Log("texture is texture3");
            break;

        case "HapticMesh4":
            imagePath = "Textures/stripes/stripe4";
            Debug.Log("texture is texture4");
            break;

        case "HapticMesh5":
            imagePath = "Textures/dots/dots4";
            break;
        }

        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);



        /*
         * {
         *  case "HapticMesh1":
         *      imagePath = "Textures/checker_highres/checker_hr0";
         *  break;
         *
         *  case "HapticMesh2":
         *      imagePath = "Textures/checker_highres/checker_hr1";
         *  break;
         *
         *  case "HapticMesh3":
         *      imagePath = "Textures/checker_highres/checker_hr2";
         *  break;
         *
         *  case "HapticMesh4":
         *      imagePath = "Textures/checker_highres/checker_hr3";
         *  break;
         *
         *  case "HapticMesh5":
         *      imagePath = "Textures/checker_highres/checker_hr4";
         *  break;
         *
         * }
         */
        /*
         * {
         *  case "HapticMesh1":
         *      imagePath = "Textures/sandpaper/sandpaper0";
         *  break;
         *
         *  case "HapticMesh2":
         *      imagePath = "Textures/sandpaper/sandpaper1";
         *  break;
         *
         *  case "HapticMesh3":
         *      imagePath = "Textures/sandpaper/sandpaper2";
         *  break;
         *
         *  case "HapticMesh4":
         *      imagePath = "Textures/sandpaper/sandpaper3";
         *  break;
         *
         *  case "HapticMesh5":
         *      imagePath = "Textures/sandpaper/sandpaper4";
         *  break;
         *
         * }
         */

        Texture2D _texture = Resources.Load(imagePath) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }
Пример #7
0
    //initializing the application's haptic resources
    void InitHaptics()
    {
        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);

        //Retrieve texture data from bitmap.
        string imagePath = "";

        //imagePath = "Textures/noise/noise_texture3";

        switch (this.gameObject.name)

        {
        case "HapticMesh1":
            imagePath = "Textures/noise/noise_texture4";
            break;

        case "HapticMesh2":
            imagePath = "Textures/noise/noise_texture3";
            break;

        case "HapticMesh3":
            imagePath = "Textures/customized/createdPolkaDotTexture";
            break;

        case "HapticMesh4":
            imagePath = "Textures/noise/noise_texture1";
            break;

        case "HapticMesh5":
            imagePath = "Textures/noise/noise_texture0";
            break;
        }



        /*
         * {
         *  case "HapticMesh1":
         *      imagePath = "Textures/checker_highres/checker_hr0";
         *  break;
         *
         *  case "HapticMesh2":
         *      imagePath = "Textures/checker_highres/checker_hr1";
         *  break;
         *
         *  case "HapticMesh3":
         *      imagePath = "Textures/checker_highres/checker_hr2";
         *  break;
         *
         *  case "HapticMesh4":
         *      imagePath = "Textures/checker_highres/checker_hr3";
         *  break;
         *
         *  case "HapticMesh5":
         *      imagePath = "Textures/checker_highres/checker_hr4";
         *  break;
         *
         * }
         */
        /*
         * {
         *  case "HapticMesh1":
         *      imagePath = "Textures/sandpaper/sandpaper0";
         *  break;
         *
         *  case "HapticMesh2":
         *      imagePath = "Textures/sandpaper/sandpaper1";
         *  break;
         *
         *  case "HapticMesh3":
         *      imagePath = "Textures/sandpaper/sandpaper2";
         *  break;
         *
         *  case "HapticMesh4":
         *      imagePath = "Textures/sandpaper/sandpaper3";
         *  break;
         *
         *  case "HapticMesh5":
         *      imagePath = "Textures/sandpaper/sandpaper4";
         *  break;
         *
         * }
         */

        Texture2D _texture = Resources.Load(imagePath) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }
Пример #8
0
    void InitHaptics()
    {
        //Get the service adapter
        mHapticServiceAdapter = HapticServiceAdapter.GetInstance();

        //Create the haptic view with the service adapter instance and then activate it.
        mHapticView = HapticView.Create(mHapticServiceAdapter);
        mHapticView.Activate();

        //Set orientation of haptic view based on screen orientation.
        mHapticView.SetOrientation(Screen.orientation);

        string imagePath = "";

        switch (this.gameObject.name)
        {
        case "TrackOneInsideFeedbackMesh":
            Debug.Log("Activating inside haptic.");
            imagePath = "Tracks/feedback-exploration-insidetexture-track1";
            break;

        case "TrackOneOutsideFeedbackMesh":
            Debug.Log("Activating outside haptic.");
            imagePath = "Tracks/feedback-exploration-outsidetexture-track1";
            break;

        case "TrackTwoInsideFeedbackMesh":
            Debug.Log("Activating inside haptic.");
            Debug.Log("Log #9.");
            imagePath = "Tracks/feedback-exploration-insidetexture-track2";
            break;

        case "TrackTwoOutsideFeedbackMesh":
            Debug.Log("Activating outside haptic.");
            imagePath = "Tracks/feedback-exploration-outsidetexture-track2";
            break;

        case "TrackThreeInsideFeedbackMesh":
            Debug.Log("Activating inside haptic.");
            imagePath = "Tracks/feedback-exploration-insidetexture-track3";
            break;

        case "TrackThreeOutsideFeedbackMesh":
            Debug.Log("Activating outside haptic.");
            imagePath = "Tracks/feedback-exploration-outsidetexture-track3";
            break;
        }

        //Retrieve texture data from bitmap.
        Texture2D _texture = Resources.Load(imagePath) as Texture2D;

        byte[] textureData = TanvasTouch.HapticUtil.CreateHapticDataFromTexture(_texture, TanvasTouch.HapticUtil.Mode.Brightness);

        //Create a haptic texture with the retrieved texture data.
        mHapticTexture = HapticTexture.Create(mHapticServiceAdapter);
        mHapticTexture.SetSize(_texture.width, _texture.height);
        mHapticTexture.SetData(textureData);

        //Create a haptic material with the created haptic texture.
        mHapticMaterial = HapticMaterial.Create(mHapticServiceAdapter);
        mHapticMaterial.SetTexture(0, mHapticTexture);

        //Create a haptic sprite with the haptic material.
        mHapticSprite = HapticSprite.Create(mHapticServiceAdapter);
        mHapticSprite.SetMaterial(mHapticMaterial);

        //Add the haptic sprite to the haptic view.
        mHapticView.AddSprite(mHapticSprite);
    }