Esempio n. 1
0
        /// <summary>
        /// Loads all resources of this texture painter object.
        /// </summary>
        /// <param name="resources">The target resource dictionary.</param>
        internal void LoadResources(ResourceDictionary resources)
        {
            // Load material
            m_materialResource = resources.GetResourceAndEnsureLoaded <SpriteMaterialResource>(
                KEY_MATERIAL,
                () => new SpriteMaterialResource(m_texture));

            // Load geometry resource
            m_geometryResource = resources.GetResourceAndEnsureLoaded <GeometryResource>(
                KEY_GEOMETRY,
                () =>
            {
                VertexStructure structure = new VertexStructure();
                structure.FirstSurface.BuildRect4V(
                    new Vector3(-1f, -1f, 0f),
                    new Vector3(1f, -1f, 0f),
                    new Vector3(1f, 1f, 0f),
                    new Vector3(-1f, 1f, 0f),
                    Color4.Transparent);
                structure.FirstSurface.Material = KEY_MATERIAL;
                return(new GeometryResource(structure));
            });

            // Load the texture resource
            m_textureResource = resources.GetResourceAndEnsureLoaded <TextureResource>(m_texture);

            // Get default resources
            m_defaultResources = resources.GetResourceAndEnsureLoaded <DefaultResources>(
                DefaultResources.RESOURCE_KEY,
                () => new DefaultResources());

            m_renderParameters = resources.GetResourceAndEnsureLoaded <ObjectRenderParameters>(
                KEY_RENDER_PARAMETERS,
                () => new ObjectRenderParameters());
        }
Esempio n. 2
0
 /// <summary>
 /// Unloads all resources.
 /// </summary>
 internal void UnloadResources()
 {
     m_geometryResource = null;
     m_textureResource  = null;
     m_defaultResources = null;
     m_renderParameters = null;
     m_materialResource = null;
 }