Gilmer Posted October 8, 2010 Share Posted October 8, 2010 Hello, im trying load the scene in c++, but im having the following problem. The models auto disappear. If i pass with the camera in a certain limit, all models, that are not vegetation, disappear. I was directly changing the file .sbx, and realized that when have few models, the problem is less, but if have lot models, the problem is greater. My code is this: // ==================================================================== // This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard // Written by Rimfrost Software // http://www.rimfrost.com // ==================================================================== #include "engine.h" void Fxs(); int main( int argn, char* argv[] ) { //Resolution int width=1680,height=1050; Initialize() ; RegisterAbstractPath("D:/Projetos/Rally"); SetAppTitle( "Rally" ) ; Graphics( width, height,32 ) ; AFilter() ; TFilter() ; // Cria FrameWork TFramework framework=CreateFramework(); // Pega Layer da Camera main TLayer layer = GetFrameworkLayer(0); // Pega Camera principal(main) TCamera camera=GetLayerCamera(layer); //Load Scene - Pista1 LoadScene("abstract::pista1.sbx"); // CONFIGURA O CENARIO ################## //Camera PositionEntity(camera,Vec3(-818,19,832)); //CameraRange(camera,0.1,1000); //SkyBox SetSkybox(LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat")); SetBackgroundColor(Vec4(1,1,1,1)); //Lights // Direcional TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(39,159,54)); //Luz ambiente //AmbientLight(Vec3(0.5,0.43,0.34)); //EntityColor(light,Vec4(0,0,0,1.5)); Fxs(); // ###################################### TVec3 camrotation=Vec3(0); float mx=0,my=0; float move=0,strafe=0.0; // Game loop while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { //FREE LOOK mx = Curve(MouseX()-GraphicsWidth()/2, mx,6); my = Curve(MouseY()-GraphicsHeight()/2, my,6); MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2); camrotation.X = camrotation.X+my/10.0; camrotation.Y = camrotation.Y-mx/10.0; RotateEntity(camera, camrotation); //MOVE CAMERA move = Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,10); strafe = Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,10); MoveEntity(camera,Vec3(strafe,0,move)); // Update timing and world UpdateAppTime(); UpdateWorld(AppSpeed()) ; // Render UpdateFramework(); RenderFramework(); // Send to screen Flip(0) ; } } // Done return Terminate() ; } void Fxs(){ //GodRays SetGodRays(1); //HDR SetHDR(1); //Bloom SetBloom(1); //SSAO //SetSSAO(1); //AnitAliasing SetAntialias(1); //Vegetation Shadow SetVegetationShadowMode(1); } Anyone had the same problem? i dont know what do. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 8, 2010 Share Posted October 8, 2010 You can try SetEntityViewRange(scene,3,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...
Gilmer Posted October 8, 2010 Author Share Posted October 8, 2010 i cant, show this error: error C3861: 'SetEntityViewRange': identifier not found I do: TEntity scene = LoadScene("abstract::pista1.sbx"); SetEntityViewRange(scene,3,1); Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 8, 2010 Share Posted October 8, 2010 It might be called SetEntityViewrange() or EntityViewRange(). Oh yeah, the Wiki says it's called EntityViewRange: http://www.leadwerks.com/wiki/index.php?title=Entities#EntityViewRange 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...
Gilmer Posted October 8, 2010 Author Share Posted October 8, 2010 Another strange thing, that happens, is the FPS that drops, when i add some "road_node" in the map. For sample, in the map, have a lot "road_node", this influence on something? Because, look this: With the road: http://i52.tinypic.com/10rsvfq.jpg Without the road: http://i54.tinypic.com/18hov9.jpg very strange this.. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 8, 2010 Share Posted October 8, 2010 I think it's because the Lua script is doing calculations all the time. It could be fixed by having a global Lua variable like "nocalc=1", which would stop all all Lua scripts from doing anything. 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...
Gilmer Posted October 8, 2010 Author Share Posted October 8, 2010 hmm..i understand.. i will test this about the road scripr, because is making the lot diference in the FPS. Now, about the camera, i test this command, it compile, but continue to dont work, the models hide in a certain distance from camera to some model, that i dont know what is. Thanks lumooja Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 8, 2010 Share Posted October 8, 2010 have you set any view distance options for them via their default lua script? Quote Link to comment Share on other sites More sharing options...
Gilmer Posted October 11, 2010 Author Share Posted October 11, 2010 No Aggror, i see script by script, and none is be setting this. I found this function in Wiki: SetWorldCullRange(), but ever time that i execute, resulted in "C Stack Overflow". I deleted the "atmosphere" entity from editor, to set this function in own code. My code is this now: // ==================================================================== // This file was generated by Leadwerks C++/LEO/BlitzMax Project Wizard // Written by Rimfrost Software // http://www.rimfrost.com // ==================================================================== #include "engine.h" void Fxs(); int main( int argn, char* argv[] ) { //Resolution int width=800,height=600; Initialize() ; RegisterAbstractPath("D:/Projetos/Rally"); SetAppTitle( "Rally" ) ; Graphics( width, height ) ; AFilter() ; TFilter() ; // Cria FrameWork TFramework framework=CreateFramework(); // Pega Layer da Camera main TLayer layer = GetFrameworkLayer(0); // Pega Camera principal(main) TCamera camera=GetLayerCamera(layer); //Load Scene - Pista1 TEntity scene = LoadScene("abstract::pista1.sbx"); // CONFIGURA O CENARIO ################## //Camera PositionEntity(camera,Vec3(-818,19,832)); CameraRange(camera,0.1,1000); //EntityViewRange(scene,3,1); SetWorldCullRange(50,125,500); //SkyBox SetSkybox(LoadMaterial("abstract::FullskiesBlueClear0016_2_L.mat")); SetBackgroundColor(Vec4(1,1,1,1)); //Lights // Direcional TLight light=CreateDirectionalLight(); RotateEntity(light,Vec3(39,159,54)); //Luz ambiente //AmbientLight(Vec3(0.5,0.43,0.34)); //EntityColor(light,Vec4(0,0,0,1.5)); Fxs(); // ###################################### TVec3 camrotation=Vec3(0); float mx=0,my=0; float move=0,strafe=0.0; // Game loop while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { //FREE LOOK mx = Curve(MouseX()-GraphicsWidth()/2, mx,6); my = Curve(MouseY()-GraphicsHeight()/2, my,6); MoveMouse(GraphicsWidth()/2, GraphicsHeight()/2); camrotation.X = camrotation.X+my/10.0; camrotation.Y = camrotation.Y-mx/10.0; RotateEntity(camera, camrotation); //MOVE CAMERA move = Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,10); strafe = Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,10); MoveEntity(camera,Vec3(strafe,0,move)); // Update timing and world UpdateAppTime(); UpdateWorld(AppSpeed()) ; // Render UpdateFramework(); RenderFramework(); // Send to screen Flip(0) ; } } // Done return Terminate() ; } void Fxs(){ //GodRays SetGodRays(1); //HDR SetHDR(1); //Bloom SetBloom(1); //SSAO //SetSSAO(1); //AnitAliasing SetAntialias(1); //Vegetation Shadow SetVegetationShadowMode(1); } Quote Link to comment Share on other sites More sharing options...
Gilmer Posted October 11, 2010 Author Share Posted October 11, 2010 Just to you could see the difference: The map in editor: And the same map, with the same camera angle, in c++: Quote Link to comment Share on other sites More sharing options...
ZioRed Posted October 11, 2010 Share Posted October 11, 2010 It really seems issue with view range, in your previous code you called (now commented): EntityViewRange(scene,3,1); But it is not intended to be used in that way, you should cycle through all the scene entities/children and call EntityViewRange for each of them and not just to the scene. But since you are using a SBX and calls LoadScene then I think it's easier if you set the view range to INFINITE directly from the editor interface for each object. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 11, 2010 Share Posted October 11, 2010 Also when an object has the default lua menu you can set its viewrange to either near, far or infite. Have you tried that? Quote Link to comment Share on other sites More sharing options...
ZioRed Posted October 11, 2010 Share Posted October 11, 2010 It really seems issue with view range, in your previous code you called (now commented): EntityViewRange(scene,3,1); But it is not intended to be used in that way, you should cycle through all the scene entities/children and call EntityViewRange for each of them and not just to the scene. But since you are using a SBX and calls LoadScene then I think it's easier if you set the view range to INFINITE directly from the editor interface for each object. Well, after thinking that all the objects in the scene loaded with LoadScene are children, I tried your code with "EntityViewRange(scene,3,1);" (whose third parameter is recursion) on a sample scene with a house on a terrain and it works, when I move far away from the house it is ever visible, so make sure you have the latest 2.4 engine/newton/shaders.pak Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Gilmer Posted October 13, 2010 Author Share Posted October 13, 2010 Thanks guys for the helps.. So, i saw script by script, and none has this function. I tried change in itself editor the view range, but the problem continue. Uptdated all files, and try ever again, but same problem. The strange is that ever models hidden when I'm in a certain position, until the models that on my side. Quote 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.