Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        this.transform.localScale = new Vector3(0.12f, 0.12f, 1.0f);

        // Calculate index
        _lastIndex++;
        int index = (int)(_lastIndex) % (_uvTieX * _uvTieY);

        if (index != _lastIndex)
        {
            // split into horizontal and vertical index
            int uIndex = index % _uvTieX;
            int vIndex = index / _uvTieY;

            // build offset
            // v coordinate is the bottom of the image in opengl so we need to invert.
            Vector2 offset = new Vector2(uIndex * _size.x,
                                         1.0f - _size.y - vIndex * _size.y);

            Texture2D subtex = MedicalImaging.cropTexture2D(texture, new Rect(offset.x, offset.y,
                                                                              200, 180));

            //_myRenderer.material.SetTextureOffset ("_MainTex", offset);
            //_myRenderer.material.SetTextureScale ("_MainTex", _size);

            _lastIndex = index;

            _myRenderer.material.SetTexture("_MainTex", subtex);
            MedicalImaging.applyQuadShader(this.gameObject, "Custom/MRI_Image_OpacityMap");
            //MedicalImaging.applyQuadShader(this.gameObject, "Custom/GLSL_basic_shader");
        }
    }
Exemplo n.º 2
0
    public void loadSlice(int slice)
    {
        if (slice < 0)
        {
            slice = 0;
        }
        if (slice > MedicalImaging.slices)
        {
            slice = MedicalImaging.slices - 1;
        }
        currentSlice = slice;

        MedicalImaging.applyQuadTexture2D(this.gameObject, MedicalImaging.texture, slice);

        MedicalImaging.applyQuadShader(this.gameObject, "Custom/LensMask_Shader");

        Debug.Log("slice: " + slice.ToString());

        string txt =
            string.Format("Slice -({0})", currentSlice.ToString());
        var g = GameObject.Find("CurrSliceTextBox").GetComponent <TextMesh> ();

        g.text     = txt;
        g.fontSize = 14;
    }
Exemplo n.º 3
0
    public static void applyQuadTexture2D(GameObject q, Texture2D texture, int slice)
    {
        MeshRenderer m_renderer;
        Mesh         m_mesh;
        Material     m_material;

        m_renderer = q.GetComponent <MeshRenderer>();
        m_mesh     = q.GetComponent <MeshFilter>().mesh;
        m_material = m_renderer.material;

        int     _uvTieX = 10;
        int     _uvTieY = 10;
        Vector2 _size   = new Vector2(1.0f / _uvTieX, 1.0f / _uvTieY);

        // split into horizontal and vertical index
        int uIndex = slice % 10;
        int vIndex = slice / 10;


        // build offset
        // v coordinate is the bottom of the image in opengl so we need to invert.
        Vector2 offset = new Vector2(uIndex * _size.x,
                                     1.0f - _size.y - vIndex * _size.y);

        Texture2D subtex = MedicalImaging.cropTexture2D(texture,
                                                        new Rect(offset.x * texture.width, offset.y * texture.height,
                                                                 200, 180));


        m_material.SetTexture("_MainTex", subtex);
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        Pose = Vector3.zero;

        MedicalImaging.LoadMRISlices(texture, alphamap);
        MedicalImaging.BuildMRIModel(this.gameObject, MedicalImaging.slices,
                                     Vector3.zero, 1.0f, Threshold);

        this.transform.Translate(new Vector3(0.1f, 0.15f, -0.10f));
    }
Exemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        pose = Vector3.zero;
        DepthChangedEventHandler += MagnifierLensTexture_DepthChangedEventHandler;

        MedicalImaging.LoadMRISlices(texture, alphamap);


        loadSlice(currentSlice);
    }