Can’t get mtl for OBJ robot to work

I downloaded the obj & mtl files for the cool robot in @yojimbo2000’s old OBJ loader.

The obj loaded just fine into craft but I can’t figure out how to get the mtl loaded.

Attached is the project (includes assets) and a screenshot.

@UberGoober - not sure if the files you mention are fully valid obj and mtl files as Craft wasn’t available and there were a few home made obj loaders. Have you tried them with an external model loader?

Will try to pull the files down and check them if my iPad & Codea behave.

@Bri_G I think the OBJ and MTL files are downloaded directly from the net somewhere, not generated by the OBJ loader, so they should be legit. I could be wrong though.

@UberGoober - the robot obj and mtl are present in your documents folder ie Codea root. I’ll check in my system.

@Bri_G not sure what you mean, I included those in the assets of the zipped up project, at least I thought I did.

@UberGoober - yeah your right, it is in the Project.codea folder. But if you check it out it does what I have previously mentioned about obj and mtl files. The file names are robot_obj.txt and robot_mtl.txt. Also I couldn;t see them as resources in the Project resources viewer. @Simeon - this is the same format naming that I have seen on Dropbox. I got round it by using name_obj.obj and name_mtl.mtl for naming. This is confusing.

@UberGoober as @Bri_G stated the model does not show up in the asset picker?
If the filenames have the extension .txt it will not work. They have to be .obj and .mtl.

I have never succeeded to get obj/mtl files into the project assets-how did you manage to do that? I have complained to @Simeon in the past that it is not possible to move the obj/mtl from dropbox to project assets.

@piinthesky readText(...) is your friend. That’s how I moved them. I just typed it in on a blank line, used it to move the files, then deleted the line again.

@UberGoober - the colour data is in the mtl file but the file may not be read as the filename has been changed to robot_mtl.txt. if you can read you project file on a PC or Mac you could rename it to a .zip file, unzip it and change the names of the two files then rezip the file and import it into Codea. That may or may not work depending on where the Codea edits the file names. I’ll play around with this but it won’t be soon. Busy, busy, busy.

@Bri_G you can actually edit a file extension from Dropbox, so it was pretty easy to do. So now It appears as a model in the model browser, but it still doesn’t have the color information.

@UberGoober are you sure the .mtl file is in the project assets? If instead you have the .obj/.mtl in dropbox does it work?

@UberGoober @piinthesky - you can get obj/mtl files visible in the viewer if they are in Codea root. Copy the properly named files there then use asset.documents or look them up on the assets viewer from the project list page.

@piinthesky I get the same (non) results whether the files are in the Codea root, Dropbox, or the project assets.

@UberGoober - how are the files named? Can you see them in the asset viewer?

The files are robot_obj.obj and robot_mtl.mtl. The obj file shows up as a model asset in the asset viewer. It’s the same in all three locations. The mtl file only shows up inside Codea as an auto completion option when I type asset-dot-this-or-that.

@UberGoober - rename them to robot.obj and robot.mtl and change that in you project then run it.

@Bri_G yes! Thank you! Victory over everything!

…the only thing is, it won’t work from inside the project’s own assets.

Using the following code I can verify that “robot.mtl” actually is in the project assets:


foo = readText(asset.documents .. "robot.mtl")
print(foo)
saveText(asset.."robot.mtl", foo)
bar = readText(asset .. "robot.mtl")
print(bar)

So the exact same files are in my project assets and in my documents folder, but in the documents folder they load properly and in the project assets they don’t.

Also the little obj preview in the documents folder looks colored-in, and the one in the project assets is blank.

@UberGoober - are you sure the assets in your project file are named the same. They may have been changed when the project was built then exported.

@simeon @John could you please explain this. I know why you did it but it would be useful to understand the reasons and the details.

@Bri_G pretty sure; the obj file should be the same because I copied it into the project assets directly using Codea’s asset browser, and the code I posted above confirms that the mtl file is the same.

@UberGoober - ah, aha. If you copied it using the internal asset browser it may have changed the naming and renamed as described above. The asset browser may also be designed to accomodate that.

I know when I have say a robot.obj file in Dropbox the new asset lister displays robot_obj. I know the _ is used for non-alphanumerics in paths and thought that was why it is displayed in this way. Hope @Simeon or @John can clear this up.