private void TryToCreateTexture() { int trackedObjectID = personID; if (usePlayerID) { trackedObjectID = BeckonManager.BeckonInstance.PlayerSelection.TrackedObjectIdOfPlayerId(personID); } if (trackedObjectID < 0) { return; } OmekFramework.Common.BasicTypes.CommonDefines.ImageFormat maskImageFormat = null; if (BeckonData.Persons[(uint)trackedObjectID].Mask.GetImageFormat(out maskImageFormat).IsError()) { Debug.LogError("Error reading texture size."); } else { // create a texture and a color32[] to back it. if (maskType == Omek.ImageType.IMAGE_TYPE_MASK) { m_texture = new Texture2D(maskImageFormat.m_width, maskImageFormat.m_height, TextureFormat.ARGB32, false); m_pixels = new Color32[maskImageFormat.m_width * maskImageFormat.m_height]; } else { OmekFramework.Common.BasicTypes.CommonDefines.ImageFormat regularImageFormat = null; regularImageData.GetImageFormat(out regularImageFormat); m_texture = new Texture2D(regularImageFormat.m_width, regularImageFormat.m_height, TextureFormat.ARGB32, false); m_pixels = new Color32[regularImageFormat.m_width * regularImageFormat.m_height]; } m_texture.filterMode = FilterMode.Bilinear; m_texture.wrapMode = TextureWrapMode.Clamp; m_texture.SetPixels32(m_pixels); m_texture.Apply(); // set the texture in the material or GUITexture if (renderer) { if (maskType != Omek.ImageType.IMAGE_TYPE_COLOR) { renderer.material.color = maskColor; } renderer.material.mainTexture = m_texture; } else if (GetComponent(typeof(GUITexture))) { GUITexture gui = GetComponent(typeof(GUITexture)) as GUITexture; gui.texture = m_texture; } } }
// Use this for initialization void Start() { if (!BeckonManager.BeckonInstance.IsInit()) { return; } m_firstFrame = true; if (imageType == ImageType.IMAGE_TYPE_COLOR) { regularImageData = BeckonData.Image.RGB; } else if (imageType == ImageType.IMAGE_TYPE_DEPTH) { regularImageData = BeckonData.Image.Depth; } OmekFramework.Common.BasicTypes.CommonDefines.ImageFormat regularImageFormat = null; if (regularImageData.GetImageFormat(out regularImageFormat).IsError()) { Debug.LogError("Error reading texture size."); } else { // create a texture and a color32[] to back it. m_texture = new Texture2D(regularImageFormat.m_width, regularImageFormat.m_height, TextureFormat.ARGB32, false); m_pixels = new Color32[regularImageFormat.m_width * regularImageFormat.m_height]; m_texture.filterMode = FilterMode.Bilinear; m_texture.wrapMode = TextureWrapMode.Clamp; m_texture.SetPixels32(m_pixels); m_texture.Apply(); // set the texture in the material or GUITexture if (renderer) { renderer.material.mainTexture = m_texture; } else if (GetComponent(typeof(GUITexture))) { GUITexture gui = GetComponent(typeof(GUITexture)) as GUITexture; gui.texture = m_texture; } } Update(); }
private void TryToCreateTexture() { OmekFramework.Common.BasicTypes.CommonDefines.ImageFormat maskImageFormat = null; if (BeckonData.Persons[(uint)personLabel].Mask.GetImageFormat(out maskImageFormat).IsError()) { Debug.LogError("Error reading texture size."); } else { // create a texture and a color32[] to back it. if (maskType == Omek.ImageType.IMAGE_TYPE_MASK) { m_texture = new Texture2D(maskImageFormat.m_width, maskImageFormat.m_height, TextureFormat.ARGB32, false); m_pixels = new Color32[maskImageFormat.m_width * maskImageFormat.m_height]; } else { OmekFramework.Common.BasicTypes.CommonDefines.ImageFormat regularImageFormat = null; regularImageData.GetImageFormat(out regularImageFormat); m_texture = new Texture2D(regularImageFormat.m_width, regularImageFormat.m_height, TextureFormat.ARGB32, false); m_pixels = new Color32[regularImageFormat.m_width * regularImageFormat.m_height]; } m_texture.filterMode = FilterMode.Bilinear; m_texture.wrapMode = TextureWrapMode.Clamp; m_texture.SetPixels32(m_pixels); m_texture.Apply(); if (renderer) { if (maskType != Omek.ImageType.IMAGE_TYPE_COLOR) { renderer.material.color = maskColor; } renderer.material.mainTexture = m_texture; } else if (GetComponent(typeof(GUITexture))) { GUITexture gui = GetComponent(typeof(GUITexture)) as GUITexture; gui.texture = m_texture; } } }