Page 1 of 1

Extend ResourceLoadingListener for missing resources

Posted: Thu Mar 03, 2011 1:52 pm
by Sauce
ResourceLoadingListener allows us to handle name collisions, but currently there's no method of handling requests for missing resources, besides handling exceptions for every single resource request at the site of the request. Could the listener be extended to handle this?

I would use this to replace the requested resource with a default resource which we can guarantee to be available - for example, If the requested resource is a mesh then I would replace it with something akin to the glowing red "ERROR" mesh used in the Source engine, or the question mark mesh used by Ogitor.

Image

Materials already default to a white material, but with these changes we could have default meshes, textures (for example the black and purple checkerboard texture, also used by Source), and even default resources for other user-defined types deriving Ogre::Resource.

Image

The current OGRE behaviour isn't very useful (if the exception isn't expected then the program will just crash). Thoughts?

Re: Extend ResourceLoadingListener for missing resources

Posted: Thu Mar 03, 2011 2:02 pm
by jacmoe
Sounds like a very good idea. :)

Re: Extend ResourceLoadingListener for missing resources

Posted: Sat May 28, 2011 7:39 pm
by rhaith
I was just going to implement this in my code as well and was surprised not to find it in Ogre.

Re: Extend ResourceLoadingListener for missing resources

Posted: Sat May 28, 2011 7:57 pm
by Brocan
Yeah, i 've implemented the same but using the resource exception and loading a error.mesh instead.

I think that this behaviour is better than handle the exception in every resource load call. Maybe can be possible also to define if you want to except or load a error mesh...

Furthermore, it's extrange that materials load a default material if not found, but the mesh not found generates an exception.

Re: Extend ResourceLoadingListener for missing resources

Posted: Fri Jun 17, 2011 1:52 am
by Rambus
I like the idea.

I created an error mesh file for anyone to use when implementing this for them selves.
The exported .mesh, a simple .material and the .max(9) source file is included.

Image
346 vertices, 688 faces

Error.mesh
Simple error model with red material. No animations or LOD

AnimatedError.mesh
The mesh has a node animation titled: "rotate" which simply rotates the mesh once.

The model is released into the public domain.

Mirrored for hot linking: http://www.nonlife.net/downloads/error.zip

Enjoy.

Re: Extend ResourceLoadingListener for missing resources

Posted: Sat Jun 18, 2011 11:39 am
by Klaim
Wouldn't a cube with "error" or a cubic shape 3D error text like yours but in cubic shape mesh be more efficient?

Re: Extend ResourceLoadingListener for missing resources

Posted: Mon Jun 20, 2011 5:18 pm
by Rambus
This error text is designed to replicate the error mesh seen in the popular Source game engine. You could use any mesh- but it certainly does not need to be efficient because it should only appear when something has gone wrong in development.

Edit: I imagine they went for 3d text as apposed to a cube with an error message written on it as it may be easier to identify, even from a distance.

Re: Extend ResourceLoadingListener for missing resources

Posted: Mon Jun 20, 2011 5:33 pm
by jacmoe
Bethesda uses a glowing question mark.. :)

Re: Extend ResourceLoadingListener for missing resources

Posted: Mon Jun 20, 2011 10:25 pm
by Rambus
Currently I use the previously supplied error mesh with an additional red glow pass in the material.

Since I could not tell if that ? comment was a request or not...

----

I created an error mesh file for anyone to use when implementing this for them selves.
The exported .mesh, a simple .material and the .max(9) source file is included.

Image
104 vertices, 200 faces

ErrorQuestionMark.mesh
Simple error model with red material. No animations or LOD


The model is released into the public domain.

Mirrored for hot linking: http://www.nonlife.net/downloads/errorquestion.zip

Enjoy.

Re: Extend ResourceLoadingListener for missing resources

Posted: Tue Jun 21, 2011 9:34 am
by Zonder
They probably used a "?" as it is internationally understood :)