Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
load and deload; when I want to
Topic Started: Jul 28 2006, 03:45 PM (207 Views)
migileke
Unregistered

My game is making quite alot of progress, but now I have yet another problem: loading takes too long. All models/textures are loaded in the first step of the game, but I want to load the models when I need to (when my character enters a new room/area where the model is needed. So I want to load my models then, and deload them when I don't need them anymore (for optimization, if deloading models isn't nessesary, then I won't)

Thanks in advance!
migileke
Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Loading the resources at the place you need them is no problem. You don't need to call LoadMesh, LoadTexture and PreloadMesh when the game starts. You can do this whenever you want. But in the current version of U3D there's no function to release textures. And the Destroy() function of the models contains a known bug so it can cause exceptions sometimes (Unexpected errors, that's how GM calls it).

Currently the only way to release a texture is loading another texture to the same index. In U3D 2.0 the whole model loader will be rewritten so the Destroy-bug won't exist anymore and there will be a function to release textures. It's kinda funny this you ask this right now because I rewrote the ReleaseTexture function and the Destroy() function of the models a few hours ago ^_^ .

I recommend making one object for every scene that needs to be loaded. Then you use it's create event to load the textures and to preload the meshs (if this is necessary). When U3D 2.0 is out you can use the Destroy events of these objects to call the Release functions.
Offline Profile Quote Post Goto Top
 
migileke
Unregistered

Thanks!

Now I have 2 more questions:
Do I have to call all destroy events when the game ends to clear all used resources?
Does every object (of the same kind) load the mesh (animation of .3ds's) again, or does it only load them once for all of them. Like, when I have 30 spiders crawling around, will they all have to load the 'crawling' animation and textures? If so, how could I make them to load it only once?
Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
When the game ends Ultimate 3D releases all resources automatically.
And U3D will never load the same model file twice. If two model objects use the same file the second one will create a reference to the first one. But you don't need to care about that. Just call Destroy for every object (the references need to be destroyed, too).
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply