Jump to content

[SOLVED] Invalid Mesh Check


photo

Recommended Posts

Hi,

 

What should we do if we want to handle invalid mesh files ourselves? I have mesh files and load them directly from inside the script, and I want to know if they are loaded properly, so that I can terminate the loading of some other objects too. engine.editor.loadMesh claims to provide that, but it does not return 0 when the file is invalid, but gives error in the console and continues working instead. 

 

if(engine.editor.loadMesh(argData.bodyMeshFile) == 0)
{
log.message("\nError - Mesh not loaded: %s\n", argData.bodyMeshFile);
return 1;
}
 

Code does not enter if statement in any case, but prints an error in the console and continues if mesh is invalid.

Link to comment

Hi,

 

engine.editor.loadMesh will return 0 only if you specify wrong mesh name, for example instead of loading statue.mesh file you will try to load statue.mes.

 

You can write custom loadMesh function, something like this:

ObjectMesh loadMesh(string mesh_name) {
	ObjectMesh mesh = new ObjectMesh(mesh_name);
	if(mesh.getNumSurfaces() == 0) {
		delete mesh;
		return NULL;
	}

	return mesh;
}

This function will try to load Mesh and if number of surfaces in loaded mesh will equals to zero it will return NULL. So, if you are not going to load empty meshes (without surfaces) this function will work fine.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment
×
×
  • Create New...