AggrorJorn Posted May 29, 2010 Share Posted May 29, 2010 I am looking in to a good level switching system but my program keeps crashing. Am I forgetting something? I tried: ClearWorld(fw.main.world) as wel as: ClearWorld(fw.main) The debugger tells me at both times: Attempt to access field or method of Null object. Quote Link to comment Share on other sites More sharing options...
macklebee Posted May 29, 2010 Share Posted May 29, 2010 are you sure its ClearWorld() you want? you used to be able to just create a new instance of CreateFramework() and it would automatically free the world and all its objects and let you load a new scene... but since that has changed in 2.32 and of course there is no documentation of it being changed or why it was changed... it appears to still work, except I am not sure everything is being freed since there is no mention in log whether its deleting the instances or freeing the classes anymore... Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
macklebee Posted May 29, 2010 Share Posted May 29, 2010 require("Scripts/constants/engine_const") RegisterAbstractPath("") Graphics(800,600) fw=CreateFramework() scene=LoadScene("Maps/deserthighway.sbx") PositionEntity(fw.main.camera, Vec3(1140,157,-444)) RotateEntity(fw.main.camera, Vec3(4,83,-8)) while KeyHit(KEY_ESCAPE)==0 do fw:Update() fw:Render() if KeyHit(KEY_F)==1 then fw=CreateFramework() scene=LoadScene("Maps/test.sbx") PositionEntity(fw.main.camera, Vec3(0, 2, 0)) end SetBlend(1) DrawText("Press F key to switch worlds", 0, 20) SetBlend(0) Flip(0) end if you run the above example in 2.31 and 2.32 you will see that 2.31 frees/deletes the previous scene, whereas there is no mention of this in 2.32's log... it appears to give the same result, but now i am not to sure its actually clearing out the scene... 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 29, 2010 Author Share Posted May 29, 2010 Hi M! The main world already contains an sbx file and several by hand loaded models. When I load a second level I need to clear this world (not free!) and then create a new camera. So ClearWorld seems like an a logical choise. **EDIT nvm.. I already see you posted it. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted May 29, 2010 Author Share Posted May 29, 2010 Okay I tried your code block and it seems to be working well. At least I haven't come across any probles so far. I will update if there is something to report. Thanks for the quick response. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 3, 2010 Author Share Posted June 3, 2010 A little update here. The level switching works okay in the beginning. A second level gets loaded. However after a few seconds in the new level, you will notice that the game will not respond. This lasts for 2 to 3 seconds. The problem: The program creates a new framework and thereby deletes the previous scene (gmf, textures etc.). Then the next scene gets loaded. so far so good. However then after a couple of seconds in the new level you see the console removing all of the references that still exist from the first level. this is a part of the log file. -- here the program loads the new level succesfully. The previous world has already been deleted due to the new framework. Loading mesh "c:/users/jorn/desktop/media/models/tutlevel1/tutlevel1_level1tut.gmf"... Loading material "c:/users/jorn/desktop/media/models/tutlevel1/material #25.mat"... "zip::c:/users/jorn/desktop/shaders.pak//postfilters/postfilter.frag"... --after a few seconds in the new level, all the references and class still need to be freed. Causing the game to stop responding for a few seconds. Freeing class trigger_tutorial1 Freeing class info Freeing class sign_quit Deleting mesh reference "c:/users/jorn/desktop/media/models/triggers/tutorial1 trigger/trigger_tutorial1.gmf" Deleting mesh reference "c:/users/jorn/desktop/media/models/sign/sign_pole.gmf" Deleting mesh reference "c:/users/jorn/desktop/media/models/block/test_test blok.gmf" Is there a way to remove the references before the second level gets loaded? Or any other suggestion that is usefull ofcourse. Quote Link to comment Share on other sites More sharing options...
Canardia Posted June 3, 2010 Share Posted June 3, 2010 fw:Free() Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.