ASE file loader - custom scheme

May 4, 2011 at 4:02 PM
Edited May 4, 2011 at 4:04 PM

Hello, i'm using custom scheme to load mesh from ase file as you've described here http://www.ingebrigtsen.info/post/2010/09/18/Loading-files-from-other-places-than-the-XAP-package-with-Balder.aspx

But i've faced with problem that i can't load texture even if url of bitmap is valid. Take a look at next piece of code:

 

case AseConstants.BITMAP:
	{
		var file = content.Replace("\"", string.Empty);

		var relativeFile = Path.GetFileName(file);
		var rootPath = globals.RootPath;
		var actualFile = string.IsNullOrEmpty(rootPath)
							? relativeFile
							: string.Format("{0}//{1}", rootPath, relativeFile);

		var loader = globals.AssetLoaderService.GetLoader<Image>(actualFile);
		var frames = loader.Load(actualFile);
		var imageMap = new ImageMap(frames[0] as Image);
		material.DiffuseMap = imageMap;
	}
	break;

 

Extracting of file name (actualFile) doesn't work in case of custom file loader, so i "patched" this part as follows:

 

case AseConstants.BITMAP:
	{
		var file = content.Replace("\"", string.Empty);

		var relativeFile = Path.GetFileName(file);
		var rootPath = globals.RootPath;
		var actualFile = string.IsNullOrEmpty(rootPath)
							? relativeFile
							: string.Format("{0}//{1}", rootPath, relativeFile);

		if (file.Contains("://"))
			actualFile = file;

		var loader = globals.AssetLoaderService.GetLoader<Image>(actualFile);
		var frames = loader.Load(actualFile);
		var imageMap = new ImageMap(frames[0] as Image);
		material.DiffuseMap = imageMap;
	}
	break;

That worked for me. However i don't think this is done correctly or is in right place, so i would be very appreciate of any advise you may offer how to properly load textures when custom loader is used.
Coordinator
May 4, 2011 at 6:42 PM

I've been thinking a lot about this lately and how it should handle textures and assets in general. I will be looking into the asset management system and specifically look at expanding how it handles things. Also I've been thinking about adding a scheme for material libraries, not sure yet how it should work though. 

If its Ok for now, just go with what you've done and I'll drop in a work item for this and keep it in mind when looking at it and the possible refactoring I'll be doing.

Coordinator
May 4, 2011 at 6:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.