Hey,
There doesn't seem to be a week goes by without someone asking for this so here it is:
But first, an explanation for why AppGameKit behaves the way it does when loading objects.
Whilst it is perfectly possible to create Desktop Apps with AppGameKit, a large part of its appeal is its ability to perform well on mobile platforms. While many modern mobile devices now have processors that can outperform some entry level laptops, they still have quite a limited amount of memory. If AppGameKit were to load the texture for each object as the object was loaded then your mobile device could rapidly run out of memory if the same texture were used on multiple objects and had to have multiple copies of it sat in RAM. So it doesn't do that. It asks you to take care of your own memory management (to a degree) by forcing you to load only the textures you need.
That doesn't seem to be enough for a lot of people and they still want the texture loaded automatically. So here's what you do:
Step 1: Download the attached code and save it somewhere safe (Projects folder sounds good!)
Step 2:
#include the code in any of your own code that loads 3D objects
Step 4: Load the object by calling
Load3Dobject(filename$) or
Load3DobjectWithChildren(filename$)
"Hey! What happened to Step 3" I hear you ask.
That needs more explanation (and is probably the bit that will put people off)
Step 3: You need a separate text file for each object which holds a list of the textures and stages to put them in. I don't see that as a big issue personally because you have separate text files for Atlas textures and this is no different.
For example:
Let's say you have an object and two textures:
MyObject.FBX
diffuse_texture.png
normal_map.png
You would create a text file called "MyObject textures.txt"
And it would contain:
0:diffuse_texture.png
1:normal_map.png
Now when you load the object, it will open the text file and read it. Then place
diffuse_texture.png into stage 0 and
normal_map.png into stage 1.
You could ask "
What's the point, doesn't that defeat the object of saving RAM by loading only single instance of a texture" and you'd be right, but there is another function going on in the background which stops that from happening. So if you then load another object that uses the same textures, they won't be re-loaded but instead use the same images as the previous object.
There are some string comparisons going on in order to perform that, so it will add a millisecond or two to the load time but I think that's a small price to pay.
Small caveat: I've just knocked this code together and haven't been able to test it but it dry runs perfectly well.
Fully tested - It works as advertised
Give me a shout if you have any questions,
Scraggle