Weird behaviour when loading meshes

Blitz3D Forums/Blitz3D Programming/Weird behaviour when loading meshes

Jeroen(Posted 2004) [#1]
DEMO OF PROBLEM HERE: http://wobbles.hku.nl/test.rar

Graphics3D 800,600,32,0
SetBuffer BackBuffer()
e=LoadMesh ("level/level_swamp.b3d")
a=LoadAnimMesh ("level/level_swamp.b3d")


The code above works when I place my project (all files and media) in map 'X'. But when I copy the media to another folder, folder 'Y', Blitz crashes.

When I place the line
e=LoadMesh ("level/level_swamp.b3d")

above
a=LoadAnimMesh ("level/level_swamp.b3d")

...blitz crashes on the second line.
But Blitz also crashes when I swap those two lines! (when swapped, it crashes on the second line too -> loadMesh)

This is weird behaviour. Blitz (1.86) only gives me a memory access violation, nothing more.

What am i doing wrong here? Thank you


GfK(Posted 2004) [#2]
Crashes in what way?

LoadMesh and LoadAnimMesh return 0 if they fail (i.e. if the file doesn't exist) - they won't be causing your program to crash unless there's something wrong with the B3D files themselves.


Isaac P(Posted 2004) [#3]
The memory access violation could be caused by blitz not being able to find the mesh where you specified.


GfK(Posted 2004) [#4]
The memory access violation could be caused by blitz not being able to find the mesh where you specified.
LoadAnimMesh/LoadMesh don't cause runtime errors though.

Memory access violation is a generic error used when something goes wrong and the debugger isn't running.

Switch the debugger on and test it again - you might get a more helpful error message.


Jeroen(Posted 2004) [#5]
I turned the debugger on, and I know that the entity exists.
Blitz always gives a memory access violation on the *second* mesh load.

loadMesh(this)
loadAnimMesh(that) <-- blitz gives an error here

or:

loadAnimMesh(that)
loadMesh(this) <-- blitz gives an error here

When I just load one of the two, they load fine.


GfK(Posted 2004) [#6]
Are you sure you haven't previously used one of your variables as a float or a string or something?


jhocking(Posted 2004) [#7]
You're going to have to give us some more information because I cannot replicate your problem even though I'm using the exact same code (I even replicated your filenames just to be sure.)

That you get a MAV on the second load command is suspicious. Usually you don't get an error on the load command if there is a problem loading, you get a MAV the first time you attempt to use the entity by calling PositionEntity or something.

I'm with GFK is suspecting you aren't actually giving us the full code. Do you get the problem even if you just have those four lines you posted?


jhocking(Posted 2004) [#8]
Oh, have you tried reversing your slashes? It should work either way, but it's worth trying.


Jeroen(Posted 2004) [#9]
hmmm I'm afraid that didnt work. I'm really out of ideas :(
this is the full code.

Graphics3D 800,600,32,0
SetBuffer BackBuffer()

c=CreateCamera()
PositionEntity c,0,20,-20

e=LoadMesh ("level\level_swamp.b3d")
If e=0 RuntimeError "I dont exist ONE"


a=LoadAnimMesh ("level\level_swamp.b3d") ;memory acces violation here
If a=0 RuntimeError "I dont exist TWO"

ScaleEntity e,3,3,3

While Not KeyDown(1)
	TurnEntity c,1,1,1
	UpdateWorld
	RenderWorld
	Flip
Wend
End



jhocking(Posted 2004) [#10]
Wait, so are you getting the RuntimeError defined in your code?

Can you post a zip of your problem, code and model? I want to try running this and see if I get an error.


Jeroen(Posted 2004) [#11]
I have debugmode enabled, so I can see where the error occurs, always at the first mesh load command.
This exact same code works, when I run it in another folder, with exactly the same media files in it.

* The link is: http://wobbles.hku.nl/test.rar

Thank you for helping!


jhocking(Posted 2004) [#12]
That sounds like a Windows problem then. I routinely have to move stuff because files/directories got corrupted. Is there some reason you don't just move everything to another folder and continue working from there? I don't think I'm understanding what you mean by "run it in another folder."


Jeroen(Posted 2004) [#13]
Hi Jhocking, I want to run it in another folder: it has to run on other computers in the end. The game would not be very useful if I ran only on my computer :D

ps: your problem could be defective memory. I had that in the past, and after I replaced my memory, I never had any problems again


jhocking(Posted 2004) [#14]
Can you post that as a zip? I can't unpack rar.

So, if you WANT this to run in a different folder, then just start using a different folder. If it works in a new folder then move everything there and delete the old folder.


Jeroen(Posted 2004) [#15]
Zippedidooda!

http://wobbles.hku.nl/test.zip


jhocking(Posted 2004) [#16]
Thanks.

Well, it works for me. No error, code runs fine. Like I pointed out, stuff gets corrupted in Windows all the time and it sounds like your specific folder got corrupted, so move everything to a new folder and just continue working from there.

Cool level by the way. I can't wait to see a demo of Wobbles!


Jeroen(Posted 2004) [#17]
Hi Joe!

Weird that it works on your computer.
I sent the demo to 3 other people, and they all crash there! So I guess that it's not a corrupt folder, but the b3d that seems to do something weird with memory or textures or something.


Isaac P(Posted 2004) [#18]
Is the folder on your desktop.. in the past ive experience really wierd behaviours for folders kept on the desktop


jhocking(Posted 2004) [#19]
That is odd. And note that the b3d doesn't seem to load correctly in Ultimate Unwrap; the geometry comes through fine, but none of the textures load. Maybe it's just a bad b3d file; try exporting your level again.


Jeroen(Posted 2004) [#20]
It turned out to be a folder problem.
Somehow Blitz chokes on long folder names (depth of folder).
I didn't have my files on the desktop (which is actually a deep folder too) but when I moved the build in c:\blah, the application worked.