ZioRed Posted February 25, 2010 Share Posted February 25, 2010 I am trying to load the tunnels.sbx scene within the sample maps in LE SDK 2.31 and add a TController to navigate throught it, but it happens that the Controller falls down as if the collision between the scene and the controller didn't work. The same happens trying to load every map, both the samples (deserthighway.sbx, terrain_arctic.sbx) and my custom. As you can see I have set both Collisions and Body Mass on the Controller, the code is the folling: Initialize(); RegisterAbstractPath("C:/Leadwerks Engine SDK"); SetAppTitle( "SceneTest" ) ; Graphics( 800, 600 ) ; AFilter(); TFilter(); TWorld world; world = CreateWorld() ; if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); return Terminate(); } TBuffer gbuffer = CreateBuffer(GraphicsWidth(),GraphicsHeight(),BUFFER_COLOR|BUFFER_DEPTH|BUFFER_NORMAL); TCamera cam = CreateCamera(); CameraClearColor(cam,Vec4(0,0,1,1)); TModel scene = LoadScene("abstract::tunnels.sbx"); EntityType(scene, 2); Collisions(1, 2, true); TController player=CreateController(); EntityType(player, 1); SetBodyMass(player, 1); SetBodyDamping(player,0.0); SetWorldGravity(Vec3(0,-20,0)); PositionEntity(player, Vec3(-3.41, 1.78, -4.86)); float move=0.0, strafe=0.0; TVec3 camrotation=Vec3(0); float mx=0, my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); // Game loop while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { 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(cam,camrotation); move = 3 * (KeyDown(KEY_W) - KeyDown(KEY_S)); strafe = 3 * (KeyDown(KEY_D) - KeyDown(KEY_A)); //Jumping float jump=0.0; if (KeyHit(KEY_SPACE)) { if (!ControllerAirborne(player)) { jump=4.0; } } //Run if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) { if (!ControllerAirborne(player)) { move*=2.0; strafe*=2.0; } } UpdateController(player, camrotation.Y, move, strafe, jump, 500.0f); // Update timing and world UpdateAppTime(); UpdateWorld(AppSpeed()) ; //Position the camera TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75,camerapos.Y,2.0); camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z); camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z); PositionEntity(cam,camerapos); // Render SetBuffer(gbuffer); RenderWorld(); SetBuffer(BackBuffer()); RenderLights(gbuffer); // Send to screen Flip(0) ; } } Am I forgetting something in the code? Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 25, 2010 Share Posted February 25, 2010 Try positioning the camera in the editor to a place inside the map thats above a surface then open the .sbx file in notepad and use the camerapositon co-ordinates to set the position of the controller , see if that helps. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 25, 2010 Share Posted February 25, 2010 Or as a test if you have not moved anything in the standard Tunnels.sbx : Try: PositionEntity(player, Vec3(29.3175259,3.12580490,-18.8330040)); Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 25, 2010 Share Posted February 25, 2010 You might also think about using Framework saves a lot of hassle and setup. http://leadwerks.com/werkspace/index.php?/topic/381-scene-loading-example/page__view__findpost__p__5665 But after trying out your code it seems it was simply the position of the controller when spawned, it was half way through the floor. Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
Marleys Ghost Posted February 25, 2010 Share Posted February 25, 2010 Here I converted your code over to use Framewerk just make sure you point the Abstract path to your SDK folder and have the DLL's , shader.pak and scripts folder in your app folder: #include "engine.h" int main(int argc, char** argv) { Initialize(); RegisterAbstractPath("PATH TO YOUR SDK FOLDER"); Graphics(800,600); AFilter(4) ; TFilter(1) ; TWorld world = CreateWorld() ; if (!world) { MessageBoxA(0,"Error","Failed to create world.",0); return Terminate(); } TFramework framework=CreateFramework(); TLayer layer = GetFrameworkLayer(0); TCamera cam=GetLayerCamera(layer); //Set Lua variable BP L=GetLuaState(); lua_pushobject(L,framework); lua_setglobal(L,"fw"); lua_pop(L,1); // Setup Initial Post Processing FX SetGodRays(0); SetHDR(1); SetSSAO(1); SetBloom(1); SetAntialias(1); SetStats(2); LoadScene("abstract::tunnels.sbx"); TController player=CreateController(); EntityType(player, 1); SetBodyMass(player, 1); SetBodyDamping(player,0.0); SetWorldGravity(Vec3(0,-20,0)); PositionEntity(player, Vec3(38.9101448,6.67733288,1.72972393)); float move=0.0, strafe=0.0; TVec3 camrotation=Vec3(0); float mx=0, my=0; HideMouse(); MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2); // Game loop while( !KeyHit() && !AppTerminate() ) { if( !AppSuspended() ) // We are not in focus! { 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(cam,camrotation); move = 3 * (KeyDown(KEY_W) - KeyDown(KEY_S)); strafe = 3 * (KeyDown(KEY_D) - KeyDown(KEY_A)); //Jumping float jump=0.0; if (KeyHit(KEY_SPACE)) { if (!ControllerAirborne(player)) { jump=4.0; } } //Run if (KeyDown(KEY_LSHIFT)||KeyDown(KEY_RSHIFT)) { if (!ControllerAirborne(player)) { move*=2.0; strafe*=2.0; } } UpdateController(player, camrotation.Y, move, strafe, jump, 500.0f); //Position the camera TVec3 playerpos=EntityPosition(player); TVec3 camerapos=EntityPosition(cam); camerapos.Y=Curve(playerpos.Y+1.75,camerapos.Y,2.0); camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z); camerapos=Vec3(playerpos.X,camerapos.Y,playerpos.Z); PositionEntity(cam,camerapos); UpdateFramework(); RenderFramework(); // Send to screen Flip(0) ; } } } Quote AMD Bulldozer FX-4 Quad Core 4100 Black Edition 2 x 4GB DDR3 1333Mhz Memory Gigabyte GeForce GTX 550 Ti OC 1024MB GDDR5 Windows 7 Home 64 bit BlitzMax 1.50 • Lua 5.1 • MaxGUI 1.41 • UU3D Pro • MessiahStudio Pro • Silo Pro 3D Coat • ShaderMap Pro • Hexagon 2 • Photoshop, Gimp & Paint.NET LE 2.5/3.4 • Skyline • UE4 • CE3 SDK • Unity 5 • Esenthel Engine 2.0 Marleys Ghost's YouTube Channel • Marleys Ghost's Blog "I used to be alive like you .... then I took an arrow to the head" Link to comment Share on other sites More sharing options...
ZioRed Posted February 25, 2010 Author Share Posted February 25, 2010 Thank you for reply, I solved just while you were writing the last post only copying shaders.pak and Scripts folder in the compiled directory (I believed that since was declared RegisterAbstractPath thingoid than it was not necessary to copy those files). Now I'm receiving an error "Null framewerk" when hitting ESCAPE to shut down the program, I'll investigate about it (may use the Framework API instead of C [i love OOP and coming from C# ]), may be it's used inside some lua script of that scene/models. Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.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.