예제 #1
0
 /// <summary>
 /// Helper function to load mtllib statements
 /// </summary>
 /// <param name="mtlLibPath"></param>
 protected void LoadMaterialLibrary(string mtlLibPath)
 {
     if (streamFactory.Exists(mtlLibPath))
     {
         Materials = new MTLLoader(streamFactory).Load(streamFactory.OpenStream(mtlLibPath));
         return;
     }
 }
예제 #2
0
    //private FileInfo _objFileInfo = null;

    /// <summary>
    /// The texture loading function. Overridable for stream loading purposes.
    /// </summary>
    /// <param name="path">The path supplied by the OBJ file, converted to OS path seperation</param>
    /// <param name="isNormalMap">Whether the loader is requesting we convert this into a normal map</param>
    /// <returns>Texture2D if found, or NULL if missing</returns>
    public virtual Texture2D TextureLoadFunction(string path, bool isNormalMap)
    {
        //find it

        /* foreach (var searchPath in SearchPaths)
         * {
         *  //replace varaibles and combine path
         *  string processedPath = (_objFileInfo != null) ? searchPath.Replace("%FileName%", Path.GetFileNameWithoutExtension(_objFileInfo.Name))
         *                                                : searchPath;
         *  string filePath = Path.Combine(processedPath, path);
         *
         *  //return if eists
         *  if (File.Exists(filePath))
         *  {
         *      var tex = ImageLoader.LoadTexture(filePath);
         *
         *      if(isNormalMap)
         *          tex = ImageUtils.ConvertToNormalMap(tex);
         *
         *      return tex;
         *  }
         * }*/

        if (streamFactory.Exists(path))
        {
            Stream textureStream = streamFactory.OpenStream(path);
            var    tex           = Dummiesman.ImageLoader.LoadTexture(textureStream, Path.GetExtension(path));

            if (isNormalMap)
            {
                tex = ImageUtils.ConvertToNormalMap(tex);
            }

            return(tex);
        }

        //not found
        return(null);
    }