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; }
// 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"); } }