public BitmapContext(Factory f, Data d, Format.BitmapEx bitmapEx, int bId) { m_factory = f; m_data = d; m_bitmapExId = bId; Format.TextureFragment fragment = data.textureFragments[bitmapEx.textureFragmentId]; Format.Texture texture = data.textures[fragment.textureId]; m_textureName = factory.texturePrefix + texture.filename; if (LWF.GetTextureLoadHandler() != null) { m_textureName = LWF.GetTextureLoadHandler()( m_textureName, factory.texturePrefix, texture.filename); } m_premultipliedAlpha = (texture.format == (int)Format.Constant.TEXTUREFORMAT_PREMULTIPLIEDALPHA); m_material = ResourceCache.SharedInstance().LoadTexture( data.name, m_textureName, texture.format, factory.useAdditionalColor, factory.textureLoader, factory.textureUnloader, factory.shaderName); if (factory.renderQueueOffset != 0) { m_material.renderQueue += factory.renderQueueOffset; } MeshContext c = ResourceCache.SharedInstance().LoadMesh( data.name, data, bitmapEx, bitmapExId); m_mesh = c.mesh; m_height = c.height; }
public BitmapContext(Factory f, Data d, Format.BitmapEx bitmapEx, int objId, int bId) { m_factory = f; m_data = d; m_objectId = objId; m_bitmapExId = bId; Format.TextureFragment fragment = data.textureFragments[bitmapEx.textureFragmentId]; Format.Texture texture = data.textures[fragment.textureId]; m_textureName = factory.texturePrefix + texture.filename; if (LWF.GetTextureLoadHandler() != null) { m_textureName = LWF.GetTextureLoadHandler()( m_textureName, factory.texturePrefix, texture.filename); } m_premultipliedAlpha = (texture.format == (int)Format.Constant.TEXTUREFORMAT_PREMULTIPLIEDALPHA); m_material = ResourceCache.SharedInstance().LoadTexture( data.name, m_textureName, texture.format, factory.useAdditionalColor, factory.textureLoader, factory.textureUnloader); if (factory.renderQueueOffset != 0) { m_material.renderQueue += factory.renderQueueOffset; } m_format = (Format.Constant)texture.format; float tw = (float)texture.width; float th = (float)texture.height; float x = (float)fragment.x; float y = -(float)fragment.y; float u = (float)fragment.u; float v = th - (float)fragment.v; float w = (float)fragment.w; float h = (float)fragment.h; float bu = bitmapEx.u * w; float bv = bitmapEx.v * h; float bw = bitmapEx.w; float bh = bitmapEx.h; x += bu; y += bv; u += bu; v += bv; w *= bw; h *= bh; m_height = h / texture.scale; float x0 = x / texture.scale; float y0 = y / texture.scale; float x1 = (x + w) / texture.scale; float y1 = (y + h) / texture.scale; m_vertices = new Vector3[] { new Vector3(x1, y1, 0), new Vector3(x1, y0, 0), new Vector3(x0, y1, 0), new Vector3(x0, y0, 0), }; if (fragment.rotated == 0) { float u0 = u / tw; float v0 = (v - h) / th; float u1 = (u + w) / tw; float v1 = v / th; m_uv = new Vector2[] { new Vector2(u1, v1), new Vector2(u1, v0), new Vector2(u0, v1), new Vector2(u0, v0), }; } else { float u0 = u / tw; float v0 = (v - w) / th; float u1 = (u + h) / tw; float v1 = v / th; m_uv = new Vector2[] { new Vector2(u1, v0), new Vector2(u0, v0), new Vector2(u1, v1), new Vector2(u0, v1), }; } }