Jump to content

ClearWorld - level switch


AggrorJorn
 Share

Recommended Posts

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...

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

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...

  • Upvote 1

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

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...