Jump to content

Recommended Posts

Posted

You can run the Leadwerks engine using BlitzMax to load and render the sbx files, is that what you are meaning? You can't render the levels from an sbx file using just BlitzMax, at least not without writing a parser and handling all of the loading and rendering work yourself.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Posted

You should do something like this to load everything.

 

 

Framework leadwerks.engine
Import "c:\leadwerks engine sdk\bmx\framework\framework.bmx"
Include "lua-gluefunctions.bmx"
GCSetMode(2)
RegisterAbstractPath ("c:leadwerks engine sdk")
Graphics(800, 600)
'Create a framework instance called 'fw''
Global fw:TFramework = CreateFramework()
If Not fw RuntimeError "Failed to initialize engine."
'Pass to the lua state'
SetScriptObject("fw", fw)
Global scene:TEntity = LoadScene("abstract::deserthighway.sbx")
PositionEntity(fw.Main.camera, StringToVec3(GetEntityKey(scene, "cameraposition")))
'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
HideMouse()
fw.SetStats(1)
'Main loop'
Repeat
If KeyHit(KEY_ESCAPE) Exit
		 If AppTerminate() Exit
'camera rotation/movement'
CameraUpdate()
fw.Update()
fw.Render()
		 SetBlend(1)
		 DrawText("Use WSAD/Mouse to move/rotate camera",0,20)
SetBlend(0)
Flip(0)
Forever
GCCollect()
ShowMouse()
End
Function CameraUpdate()
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(fw.Main.camera, camrotation)
move = KeyDown(KEY_W) - KeyDown(KEY_S)
strafe = KeyDown(KEY_D) - KeyDown(KEY_A)
MoveEntity(fw.Main.camera, Vec3(strafe / 10.0, 0, move / 10.0))
End Function
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
'These functions allow you to pass framework to the lua state'
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

Intel Corei7-6700, NVIDIA GeForce GTX 980, 32GB DDR4, W-10.

Guest Red Ocktober
Posted

yup... of you expose the framework to lua (see pass to lua the state section in Joh's code above) then lua will take care of all the parsing of the sbx file, and should load the scene as it appears in the editor...

 

 

--Mike

  • 2 months later...
Posted

You should do something like this to load everything.

 

 

Framework leadwerks.engine
Import "c:\leadwerks engine sdk\bmx\framework\framework.bmx"
Include "lua-gluefunctions.bmx"
GCSetMode(2)
RegisterAbstractPath ("c:leadwerks engine sdk")
Graphics(800, 600)
'Create a framework instance called 'fw''
Global fw:TFramework = CreateFramework()
If Not fw RuntimeError "Failed to initialize engine."
'Pass to the lua state'
SetScriptObject("fw", fw)
Global scene:TEntity = LoadScene("abstract::deserthighway.sbx")
PositionEntity(fw.Main.camera, StringToVec3(GetEntityKey(scene, "cameraposition")))
'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
HideMouse()
fw.SetStats(1)
'Main loop'
Repeat
If KeyHit(KEY_ESCAPE) Exit
		 If AppTerminate() Exit
'camera rotation/movement'
CameraUpdate()
fw.Update()
fw.Render()
		 SetBlend(1)
		 DrawText("Use WSAD/Mouse to move/rotate camera",0,20)
SetBlend(0)
Flip(0)
Forever
GCCollect()
ShowMouse()
End
Function CameraUpdate()
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(fw.Main.camera, camrotation)
move = KeyDown(KEY_W) - KeyDown(KEY_S)
strafe = KeyDown(KEY_D) - KeyDown(KEY_A)
MoveEntity(fw.Main.camera, Vec3(strafe / 10.0, 0, move / 10.0))
End Function
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
'These functions allow you to pass framework to the lua state'
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

how to do this in C#?

Posted

You can use the installer that comes with the Sdk to set up a C# project. When that is done, you have a base app which takes care of the framework and the main loop. Then you can convert the rest of the code how it is neccesary.

Posted

in the setup program is used CreateWorld (), and I need to CreateFramework ()

  • Upvote 1

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.

×
×
  • Create New...