[SOLVED] Exception not caught

LR

01-12-2007 20:46:35

Hi there!

First let me thank you for this nice plugin. It already saved me a lot of trouble :D

A while ago I wrote a small hack for impostors to store an additional normal texture that would allow correct lighting of impostors.
This was done in Windows and everything was fine.

Now I moved to develop on Linux and strange things are going on... let me show you:

First an excerpt from Ogre.log:
21:23:00: Creating viewport on target 'rtt/ImpostorTexture1/407719872', rendering from camera 'ImpostorCam2', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
21:23:00: Creating resource group BinFolder
21:23:00: Added resource location '.' of type 'FileSystem' to resource group 'BinFolder'
21:23:36: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource Impostor.General.industry_eco_block1.mesh.png in resource group BinFolder or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 604)
21:23:36: Texture: Impostor.General.industry_eco_block1.mesh.png: Loading 1 faces(PF_A8B8G8R8,1024x512x1) with 10 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,1024x512x1.
21:23:36: Render Target 'rtt/ImpostorTexture1/407719872' Average FPS: 0.0278002 Best FPS: 0.0278002 Worst FPS: 0.0278002
21:24:01: Creating viewport on target 'rtt/ImpostorNormals3/407719872', rendering from camera 'ImpostorCam4', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
21:24:24: Added resource location '.' of type 'FileSystem' to resource group 'BinFolder'
21:26:03: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource Impostor.Normals.General.industry_eco_block1.mesh.png in resource group BinFolder or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 604)


As you can see, Ogre can't find the impostor texture and throws an exception which is caught and the texture is generated as intended.
Then Ogre tries to load the imostor normal texture and again throws an exception. But this time the exception is not caught and the program quits.

This is the corresponding code:
String fileName = "Impostor.Normals." + entity->getMesh()->getGroup() + '.' + entity->getMesh()->getName() + ".png";

//Attempt to load the pre-render file if allowed
bool needsRegen = force;
if (!needsRegen){
try{
normals = TextureManager::getSingleton().load(fileName, "BinFolder", TEX_TYPE_2D, MIP_UNLIMITED);
}
catch (...){
needsRegen = true;
}
}

This code is, except from the filename and the texture pointer, totally similar to the original code from ImpostorTexture::renderTextures - only that the exception doesn't get caught.
Any ideas why this happens?

JohnJ

01-12-2007 23:40:33

Are you saying that this:
try{
normals = TextureManager::getSingleton().load(fileName, "BinFolder", TEX_TYPE_2D, MIP_UNLIMITED);
}
catch (...){
needsRegen = true;
}

Is throwing an exception within the try{} block, but it isn't being caught? If so, then that's certainly weird - I'm not sure why that would be happening. Did you try stepping through the code in debug mode to make sure that the exception is actually occurring within the try block?

LR

02-12-2007 06:01:30

Are you saying that this:

Is throwing an exception within the try{} block, but it isn't being caught? If so, then that's certainly weird - I'm not sure why that would be happening. Did you try stepping through the code in debug mode to make sure that the exception is actually occurring within the try block?

Yes, that's what I was saying. But nevermind, by now I figured that the exception is not the problem. Actually it is caught but some gdb/gcc quirk made it look like the program stopped right inside the try block.

LR

02-12-2007 20:29:44

Very strange... today everything works - without actually changing the code...

Anyway, that's the result: :D


Is there an easy way (i.e. without changing anything in the plugin code) to effect at which angles impostors are drawn?
My game is mostly top-down perspective so I'd favor top-view sprites over side-view.

JohnJ

02-12-2007 22:05:20

Is there an easy way (i.e. without changing anything in the plugin code) to effect at which angles impostors are drawn?
My game is mostly top-down perspective so I'd favor top-view sprites over side-view.

You can't do this without changing the ImpostorPage.cpp / .h code, but it's really not that hard to do. First, open ImpostorPage.h and change this line:
#define IMPOSTOR_PITCH_ANGLES 4
To something like 1 or 2 (depending on how many angles of pitch you want to be included in the impostor render).

But the impostor renderer will still favor side-view renders. To fix this, open ImpostorPage.cpp and change this:
Radian pitch = Degree((90.0f * o) * yDivFactor); //0, 22.5, 45, 67.5

To this:
Radian pitch = Degree((90.0f * (o+1)) * yDivFactor);

LR

02-12-2007 22:27:02

Right, thanks a lot!

Now I remember I already stumbled over that part of the code but was too lazy to have a closer look :oops: