iminib3d file paths

BlitzMax Forums/MiniB3D Module/iminib3d file paths

jhocking(Posted 2010) [#1]
I just had to make a slight adjustment within the iminib3d source for dealing with files in different paths. I wanted to report what I did and why.

I was trying to setup a directory structure for my levels using folder references as described on this page:
http://majicjungle.com/blog/?p=123

However my textures weren't loading initially and I went into the source for iminib3d to figure out why. I eventually tracked down and commented out this line from the LoadTexture function in texture.mm
filename=Strip(filename);


I needed to remove this because I needed to be able to refer to textures in different directories. However, I can understand why this command was added (because XCode groups don't respect file locations) and so I don't know how you should handle this in iminib3d. If the person is using groups then you want iminib3d to strip off the file paths, but if the person is using folder references then the file path is important.


jhocking(Posted 2010) [#2]
Actually wait that didn't quite work the way I need. I think a little further down I need to adjust [UIImage imageWithContentsOfFile:] to look in the right file path.

So I guess I'm modifying my message from reporting what I changed that worked to asking how can I get this to work? Not having file paths would make the naming of files really cumbersome since every single file in the game would have to have a unique name.


ADDITION: See my bicep? I just figured it out, thanks largely to this documentation:

http://17.254.2.129/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference.html#//apple_ref/occ/clm/NSBundle/pathForResource:ofType:inDirectory:

I didn't want the Strip() function commented out after all. At the top of the LoadTexture function I added
string path = Left(filename, filename.find('/') + 1);
NSString* n_path = [NSString stringWithUTF8String: path.c_str()];


Then I changed the UIImage line at the bottom to



jhocking(Posted 2010) [#3]
Aargh actually I just discovered more headaches because that code I posted only fixes texture loading and I still have to deal with loading the models as well.

To hell with this, I didn't expect model loading to be so complicated. I guess I'll just bite the bullet and make sure all files have a unique name, ugh.


Robert Cummings(Posted 2010) [#4]
This is why i just lump it all in groups. Trying to fight it with folders just wasted my time.


Sledge(Posted 2010) [#5]
I guess I'll just bite the bullet and make sure all files have a unique name, ugh.

level01/mesh.b3d
level02/mesh.b3d

vs

level01_mesh.b3d
level02_mesh.b3d


Really, what's the difference? You've got to prefix each mesh.b3d with *something* -- it might as well be a file naming convention as a folder name! :D

That article made me smile. I can't believe he went to the trouble of concocting a script rather than getting into the habit of cleaning targets! Interesting reading, though -- nice intro to adding scripts to the build process.