Marleys Ghost Posted January 13, 2010 Share Posted January 13, 2010 Basic 3rd Person Camera If you have used the Simple Scene Loader with Player Controller in Blitzmax, this is a small addition to it that will change the camera view to 3rd person. The additions to the Simple Scene Loader code are enclosed in dashed lines. I hope this will be of some use to someone. SuperStrict Framework leadwerks.engine Import "PATH TO YOUR 2.3 SDK FOLDER\BMX\Framework\framework.bmx" Include "lua-gluefunctions.bmx" AppTitle:String = "3rd Person cam test" GCSetMode(2) 'Register the directory under which the abstract file system will search. RegisterAbstractPath("PATH TO YOUR 2.3 SDK FOLDER") 'Create a Graphics window Graphics(800, 600) AFilter(1) 'Set the anisotropic filter. Range 1-16 'Using AFilter(MaxAFilter()) will use the maximum supported anisotropic filter on your PC 'Adding the line "DrawText ("MaxAFilter = " + MaxAFilter(), 0, 80)" 'after "fw.Render()" will display on screen the maximum supported anisotropic filter. TFilter(1) 'Set trilinear filtering : 0 = off : 1 = on. 'Create a new Framework object. Global fw:TFramework = TFramework.Create() If Not fw RuntimeError "Failed to initialize engine." SetScriptObject("fw", fw)'Setup the global script objects. SetPostFX()'Setup the post processing FX SetVegetationShadowMode(0)'Setup vegetation layer shadows : 0 = off : 1 = on. 'Load the scene. Global scene:TEntity = LoadScene("abstract::YOUR_SCENE.sbx") 'Setup the player controller. Global player:TController = CreateController(2.0) PositionEntity(player, StringToVec3(scene.getkey("cameraposition"))) EntityType(player, 3) SetBodyMass(player, 50.0) SetBodyBuoyancyMode(player,0) Collisions(1, 3, 3) 'Setup the player movement variables. Global move:Float = 0.0 Global strafe:Float = 0.0 Global camrotation:TVec3 = Vec3(0) Global mx:Float = 0.0 Global my:Float = 0.0 Global jump:Float = 0.0 Global playerpos:TVec3 = Vec3(0) '-------------------------------------------------------------------------------- 'Setup the player character model Global player_body:TEntity = CreateCube() ScaleEntity(player_body,Vec3(0.5,1.8,0.5)) playerpos = EntityPosition(player) PositionEntity(player_body,playerpos) EntityParent(player_body,player) 'Setup the camera pivot Global campiv:TPivot = CreatePivot() playerpos.Y = playerpos.Y + 0.80 PositionEntity(campiv,playerpos) '-------------------------------------------------------------------------------- HideMouse() 'Set stats level : 0 = No statistics : 1 = Show frame rate : 2 = Full statistics. fw.SetStats(2) 'Main program loop. Repeat If KeyHit(KEY_ESCAPE) Exit If AppTerminate() Exit UpdateAppTime() UpdateWorld(AppSpeed()) PlayerController() fw.Update() fw.Render() Flip(0) Forever fw.renderer.gbuffer = Null GCCollect() End 'Functions. Function SetPostFX()'0 = off : 1 = on. fw.renderer.SetAntialias(1) fw.renderer.SetBloom(1) fw.renderer.SetGodRays(1) fw.renderer.SetHDR(1) fw.renderer.SetSSAO(0) fw.renderer.SetWireFrame(0) End Function Function PlayerController() 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(campiv,camrotation) '-------------------------------------------------------------------------------- move = KeyDown(KEY_W) - KeyDown(KEY_S) strafe = KeyDown(KEY_D) - KeyDown(KEY_A) jump:Float = 0.0 If KeyHit(KEY_SPACE) & Not ControllerAirborne(player) jump = 4.0 End If If KeyDown(KEY_LSHIFT) | KeyDown(KEY_RSHIFT) move = move * 3.0 strafe = strafe * 3.0 End If '-------------------------------------------------------------------------------- playerpos = EntityPosition(player) playerpos.Y = playerpos.Y + 0.80 PositionEntity(campiv, playerpos) RotateEntity(fw.Main.camera,camrotation) PositionEntity(fw.Main.camera,playerpos) MoveEntity(fw.Main.camera, Vec3(0,0.5,-3)) '-------------------------------------------------------------------------------- UpdateController(player, camrotation.Y, move * 3, strafe * 3, jump, 500, 10) End Function Function StringToVec2:TVec2(text:String, scale:Float = 1.0) Local t:TVec2 = Vec2(1) Local sarr:String[] sarr = text.split(",") If sarr If sarr.length > 0 t.x = Float(sarr[0]) * scale If sarr.length > 1 t.y = Float(sarr[1]) * scale EndIf Return t EndFunction Function StringToVec3:TVec3(text:String, scale:Float = 1.0) Local t:TVec3 = Vec3(1) Local sarr:String[] sarr = text.split(",") If sarr If sarr.length > 0 t.x = Float(sarr[0]) * scale If sarr.length > 1 t.y = Float(sarr[1]) * scale If sarr.length > 2 t.z = Float(sarr[2]) * scale EndIf Return t EndFunction Function StringToVec4:TVec4(text:String, scale:Float = 1.0) Local t:TVec4 = Vec4(1) Local sarr:String[] sarr = text.split(",") If sarr If sarr.length > 0 t.x = Float(sarr[0]) * scale If sarr.length > 1 t.y = Float(sarr[1]) * scale If sarr.length > 2 t.z = Float(sarr[2]) * scale If sarr.length > 3 t.w = Float(sarr[3]) * scale EndIf Return t EndFunction Function SetScriptObject(name:String, o:Object) Local size:Int=GetStackSize() lua_pushbmaxobject(luastate.L,o) lua_setglobal(luastate.L,name) SetStackSize(size) EndFunction Function GetStackSize:Int() Return lua_gettop(luastate.L) EndFunction Function SetStackSize(size:Int) Local currentsize:Int=GetStackSize() If size<currentsize lua_pop(luastate.L,currentsize-size) EndIf EndFunction The above video is a screen capture of a small app that used together the following: Simple Scene Loader Basic Gamepad Control Basic 3rd Person Camera 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...
cassius Posted January 13, 2010 Share Posted January 13, 2010 Thanks Marley. This is the sort of stuff thats really a big help. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
goodone Posted January 13, 2010 Share Posted January 13, 2010 This is something i have tried long time ago without great succes. Thank you so much. [Edit]: Where can i get this Include from: "lua-gluefunctions.bmx" ? Thank`s [Edit]: Aah, found it, sorry. Quote Athlon Phenom 2 X4 965 BE / Windows 7 64bit SP1 / 8G Ram / GForce GTX 460 Link to comment Share on other sites More sharing options...
Marleys Ghost Posted January 15, 2010 Author Share Posted January 15, 2010 Thanks Marley. This is the sort of stuff thats really a big help. No problems cassius glad it might be of use. Just about to update it... shortly ... well .. in a while This is something i have tried long time ago without great succes. Thank you so much. [Edit]: Where can i get this Include from: "lua-gluefunctions.bmx" ? Thank`s [Edit]: Aah, found it, sorry. No probs If anyone else has trouble finding the "Lua-gluefunctions.bmx" the code to generate one is Here. 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 January 29, 2010 Author Share Posted January 29, 2010 When you say "I have the deserthighway map tested" do you mean it works or not and was it tested using the code above? Also check your road_node.lua script has this at line 13 class.roadoffset=0.055 If it does try increasing this to: class.roadoffset=0.1 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...
macklebee Posted January 29, 2010 Share Posted January 29, 2010 i think the standard line is: class.roadoffset=0.005 and this setting works just fine: class.roadoffset=0.05 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...
Canardia Posted January 29, 2010 Share Posted January 29, 2010 I have tested that 0.05 is not enough, but 0.055 is enough. 0.1 is way too much and makes the road levitate at 10cm height. 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...
Marleys Ghost Posted January 29, 2010 Author Share Posted January 29, 2010 I think its now changed Mack, to 0.055 as I have not adjusted mine since the fresh install. I have tested that 0.05 is not enough, but 0.055 is enough. 0.1 is way too much and makes the road levitate at 10cm height. oddly just checked and seems fine at 0.1 on the deserthighway map .. but then the rumour is you exaggerate in matters of length .. seriously though looks fine to me. B) 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...
macklebee Posted January 29, 2010 Share Posted January 29, 2010 hmmm... well i literally had just updated before i posted that and 0.005 was the value that was written in the lua script. And 0.05 worked fine for me using the above script and the desert highway map... but perhaps its something that will need to be tested on various systems or maps to confirm... dunno 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...
Marleys Ghost Posted January 29, 2010 Author Share Posted January 29, 2010 Well I don't remember altering it as I have done no road work but then I don't remember lots of things B) but thats my age .. 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...
macklebee Posted January 29, 2010 Share Posted January 29, 2010 Well I don't remember altering it as I have done no road work B) but then I don't remember lots of things but thats my age .. well, we found the same issue about a month ago if i remember and we talked about this in a PM... i assume you changed it then 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...
Marleys Ghost Posted January 29, 2010 Author Share Posted January 29, 2010 well, we found the same issue about a month ago if i remember and we talked about this in a PM... i assume you changed it then Yeah then, but since have dont a full HDD wipe and reinstall. 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...
macklebee Posted January 29, 2010 Share Posted January 29, 2010 i can only assume that you are scripting in your sleep now... 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...
Marleys Ghost Posted January 29, 2010 Author Share Posted January 29, 2010 i can only assume that you are scripting in your sleep now... hmm possibly but considering I dont DO scripting when awake ... maybe it was one of the other "me's" ? B) 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 January 29, 2010 Author Share Posted January 29, 2010 No problems, glad its all working for you now 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...
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.