Load file data?

Blitz3D Forums/Blitz3D Beginners Area/Load file data?

Guy Fawkes(Posted 2013) [#1]
Hi all. I was working on my program and all was well. Until I ran into a little snag. For some reason, when I try to load my saved text file in order to load models from various locations, it froze my program, and I had to close it... It does this every single time I try to read the file. And yes, ALL the data IS correct.

Anyways, here is the code...

Load_Meshes.bb:



The file data from above is written to a text file. In which case, I can use a key or option to attempt to load the mesh. It also saves animated X files to the specified folder.

If you need me to explain more in-depth, I will be happy to!

Thanks again guys!

Thundros


Midimaster(Posted 2013) [#2]
You should add more DEBUGLOGs to know exactly what happens and where.

I always keep a lot of DEBUGLOGs in the code during the development. So I can see, where the code is working t the moment.

Your idea to log the steps into a second file is not so good, because in a case of error the new "filecheck" file will never get the "Closefile". But this is important to open it later to see the content. Without the "CloseFile" you never can be sure to see all lines. Some maybe lost in the file buffer...

So better use DEBUGLOG:

      c\filename$ = ReadLine(loadfile)
   Debuglog "Filename=" +  c\filename$
      ....
      ....
      c\FX% = ReadLine(loadfile)
   ;api_MessageBox(0, c\filename$, c\filename$, 0)
   Debuglog "will load Anim Mesh"
      c\mesh = LoadAnimMesh(c\filename$)
   Debuglog "Anim Mesh ready"
      ....
      ....
      EntityFX(c\mesh, c\FX%)
   Debuglog "**********************"
Next



Also I never would interupt a loading with a Messagebox. Also here use better a DebugLog.

Do this changes and tell me then what the last Debug-line was.

I would guess the code line with LoadAnimMesh() will make trouble.


Guy Fawkes(Posted 2013) [#3]
The problem is with the for loop itself.

I don't know WHY it's freezing starting after "For c.Obj = Each Obj", but it is. and that's not good, because I need to be able to both load AND select objects from the saved level data file :/



How do I know?

Because it didn't debuglog "HALLO OUTER DIMENSIONAL WORLD!",

But it DID debuglog "HALLO WORLD!"...


Midimaster(Posted 2013) [#4]
oh! This looks like there is no object at tht moment, Did you forget to create the objects?

In this case the While loop would run infinite....

I don't know your game. but it looks like this is the function to create new objects depending on the loadfile. If it is like that, a FOR EACH is not necessary.

Maybe that is better:

While Not Eof(loadfile)
	DebugLog "HALLO WORLD!"
	c.Obj = New Obj
	DebugLog "HALLO OUTER DIMENSIONAL WORLD!"
	c\filename$ = ReadLine(loadfile)
.....



Guy Fawkes(Posted 2013) [#5]
THIS works, but now I can't "pick" my object at all with the mouse. :(




Guy Fawkes(Posted 2013) [#6]
Ok, I've isolated the picking problem.

The problem NOW is that it won't let me use "LoadAnimMesh()" which I NEED in order to load ANIMATED models and make them available for picking.

It's only allowing me to use "LoadMesh()" for picking :(


Midimaster(Posted 2013) [#7]
this sounds like another problem, ... sounds like has to do nothing with the loadfile reading procedure... And I don't understand why there should be a relation between the picking problem and this code here....

Do you work this code, before the game starts? Or is the loading a reaction after picking an object, that already exists?


Guy Fawkes(Posted 2013) [#8]
It actually uses a loading menu to load the level data file & inside THAT, contains the correct data needed for all the 3D meshes that get loaded back in as animated (*.x)'s. It's not a game, it's a program.

For some reason, it's not letting me pick using LoadAnimMesh() even though my directX code saves any loaded 3D model back into textured, animated X files.


Stevie G(Posted 2013) [#9]
For an animesh I think you need to recursively set the entitypickmode for each of the root meshes children and their children etc....

Something like this (not tested but pretty sure it will work) .... where the Original Mesh is the root.

Function AnimMeshPickMode( Mesh, ID )

   Local c

   If Entityclass$( Mesh ) = "Mesh" Entitypickmode Mesh, ID
   for c = 1 to countchildren( Mesh )
      AnimMeshPickMode( getchild( mesh, c ) , ID )
   next

end function



Guy Fawkes(Posted 2013) [#10]
Drat. It doesn't work :(




RGR(Posted 2013) [#11]
Programming is the art to use the brain.
You either can do it or you don't ...

Its the same as composing music - you either can do it or you don't

Its the same as constucting bridges - you either can do it or you don't

Some of it can be learned if you have basic abilities - then you have to sit down and study and work and work and work ...

But you will never see a bridge constructed by someone who asks in a forum how it can de done
And you will never hear a song composed by a band which is going on and on asking in forums how they could do it
And you will never see a guy showing HIS Level Editor who begs since 2 or 3 years in all different forums to write code for him to build HIS Level Editor ...

No reason to cry tears - its only the truth you'll have to face ... if you are not able to even get the easiest parts into your brain on your own after 3 years of working on it ... having already got 1000s of lines of code and advice and help from many good guys who spent 1000s of hours of their lives to guide you and you still don't understand what they explain ... then you never will make it!



.


Guy Fawkes(Posted 2013) [#12]
RGR, go find your own thread to complain on. I'm done with you and all your little people who jump me constantly.

I'm ignoring you. Goodbye.


Stevie G(Posted 2013) [#13]
Entitytype has a 3rd paramater which when set to TRUE will apply the collision type to all children.

I'm afraid I've no idea how your meshes are set up or how you are picking them so can't help with the limited information you have supplied.


Guy Fawkes(Posted 2013) [#14]
EDIT: Fixed the PMK code, see my other post in "The Blitz3D Export Project wants you" thread.