ParaToxic Posted January 16, 2013 Share Posted January 16, 2013 Hey like the title says , I want to delete all entites Form the frameworks mainworld.But I can't get it work with resetframework Ort free and create a New framework.Please help Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 16, 2013 Share Posted January 16, 2013 In gamelib I wrote a function which clears the framework worlds. It's a bit tricky because not all entities are part of a world, like sources, so you have to keep pointers for those yourself. 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...
ParaToxic Posted January 16, 2013 Author Share Posted January 16, 2013 But you only create a New framework ? Iam not sure if that works in runtime Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 16, 2013 Share Posted January 16, 2013 It works fine, you just have to make sure you delete everything and recreate everything in the right order. 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...
ParaToxic Posted January 16, 2013 Author Share Posted January 16, 2013 But when I call fw = createframework and Athen create a cube i become not hing, just 2 flipping images of the old renders but no cube Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 16, 2013 Share Posted January 16, 2013 Actually the code was not in gamelib, but in cubix. There I have this code to switch to the next level, clearing and recreating framework (it still uses gamelib functions though): #if devel Keyboard::I****(KEY_F2) || #endif nextlevel ) { // TODO: This will go to GameLib nextlevel=false; //game.scene.framewerk.Free(); game.scene.skyworld.Set(); game.scene.skyworld.Clear(); game.scene.skyworld.Free(); game.scene.world.Set(); game.scene.world.Clear(); game.scene.world.Free(); game.scene.foregroundworld.Set(); game.scene.foregroundworld.Clear(); game.scene.foregroundworld.Free(); FreeEntity(game.scene.outofworldentity["sound_1"].entity); //TODO: free all entities loop game.scene.outofworldentity.clear(); // clear the whole map and resize it to 0 //FreeEntity(game.scene.scene); #if devel printf("LEVEL2: CLEAR\n"); CountEntities(); #endif game.scene.ReInitialize(); game.luat.Create(); // create the LuaTools object game.luat.SetScriptObject("fw",game.scene.framewerk); // set the Lua variable fw game.scene.LoadMap("maps/level2.sbx"); ReInitialize(); SetStats(0); // TODO: Somehow Application should do this BeginRender(); EndRender(); Flip(1,-2); } 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...
ParaToxic Posted January 16, 2013 Author Share Posted January 16, 2013 Why you clear all , call scene.loadmap and then Fall reinitialize() ? Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 16, 2013 Share Posted January 16, 2013 ReInitialize() is just a Cubix game specific reinitialization to create default values for enemies and player: void Cubix::ReInitialize() { pla=game.scene.SetCurrentPlayer("player1"); if(NULL==pla->body)Notify("player1 not found"); pla->SetWeapon("rifle"); CreateEnemies(); cubes.at(0).SetGravityMode(false); // prepare first attacking cube snd2.Load("Models/Cube1/Cube1.ogg"); src2.Create(snd2,LOOP); src2.SetRange(100); src2.SetVolume(0.6); src2.Play(); //SetEntityKey(snd2,"name","snd2"); //SetEntityName(src2,"src2"); sounds["exp"].Load("models/cube1/cubedeath.ogg"); sources["exp"].Create(sounds["exp"],EAX); sources["exp"].SetRange(100); sources["exp"].SetVolume(0.6); sounds["die"].Load("models/player1/playerdeath.ogg"); sources["die"].Create(sounds["die"],EAX); sources["die"].SetRange(100); game.scene.framewerk.listener.SetPosition(game.scene.cam.GetPosition(GLOBAL)); game.scene.framewerk.listener.SetRotation(game.scene.cam.GetRotation(GLOBAL)); game.scene.framewerk.listener.SetParent(game.scene.cam); //Sound::SetEAXEffect(MOUNTAINS); // engine bug: this disables 3D sounds game.scene.foregroundworld.Set(); emitter1=GetFirstEntityByKey("name","emitter_1",ENTITY_EMITTER); //TEmitter emitter2=GetFirstEntityByKey("name","emitter_1",ENTITY_EMITTER); game.scene.world.Set(); //if(!emitter2)MessageBoxA(0,"NO EMITTER",0,0); //EntityColor(emitter1,Vec4(1,0,0,1)); //emitter1.SetArea(Vec3(1,1,1)); //SetEmitterArea(emitter2,Vec3(1,1,1)); } 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...
ParaToxic Posted January 16, 2013 Author Share Posted January 16, 2013 Hmm i can't get it work.I think I have the save code . -> Quote Link to comment Share on other sites More sharing options...
Canardia Posted January 16, 2013 Share Posted January 16, 2013 You should move the camera a bit backwards to see the cube. 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...
ParaToxic Posted January 16, 2013 Author Share Posted January 16, 2013 The Problem is that the programm crashes Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted January 16, 2013 Author Share Posted January 16, 2013 Hmm when I only create a cube it works fine but when I load a scene it crashs... Quote Link to comment Share on other sites More sharing options...
Josh Posted January 17, 2013 Share Posted January 17, 2013 It's probably better to free the scene root entity when you are done with a scene. Quote My job is to make tools you love, with the features you want, and performance you can't live without. 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.