I have just successfully converted one of the Unity (LUA) DBPro plugin examples to PureGDK.
The only change I have made from the original DBPro project installed as part of the Unity installer is I have moved all the media into the media directory.
I am very very impressed with PureGDK. You can consider me a customer when this is released.
I have several other DBPro extensions so I am going to try converting some of these. I will post more when they are done.
Code: Select all
;Conversion of an example of using Unity
Procedure.l f(frame, obj)
fr = Int(frame * (dbTotalObjectFrames(obj) / 650.0))
ProcedureReturn fr
EndProcedure
;A few Interface functions
Procedure MakePath(name.s)
dbLuaSetFunction("MakePath", 1, 0)
dbLuaPushString(name)
dbLuaCall()
EndProcedure
Procedure AddWayPoint(path.s, x.f, y.f, z.f)
dbLuaSetFunction("AddWaypoint", 4, 0)
dbLuaPushString(path)
dbLuaPushFloat(x)
dbLuaPushFloat(y)
dbLuaPushFloat(z)
dbLuaCall()
EndProcedure
Procedure AddObject(objnum.l, path.s, speed.f)
dbLuaSetFunction("AddObject", 3, 0)
dbLuaPushInt(objnum)
dbLuaPushString(path)
dbLuaPushFloat(speed)
dbLuaCall()
EndProcedure
; show the PureGDK render window
hDBWnd=OpenDBWnd(0,0,800,600,32,#GDK_Window_SystemMenu|#GDK_Window_ScreenCentered)
;set up the environment
dbSetAmbientLight(50)
dbColorBackdrop(0)
dbSyncRate(70)
dbSyncOn()
dbSetTextFont("verdana")
dbSetDir("media")
;load the main lua script
r = dbLoadLua("waypointscript.lua")
;load the example level
dbLoadObject("warehouse.x", 1)
dbLoadObject("warehouse_lmap.x",2)
dbGhostObjectOn(2)
;Make an object to be used as our 'cursor'
dbMakeObjectCube(999, 20)
dbHideObject(999)
;Load the security men
For o = 100 To 101
dbLoadObject("security.x", o)
dbScaleObject(o, 300, 300, 300)
dbXRotateObject(o, 270)
dbFixObjectPivot(o)
dbSetObjectSpeed(o, 15000)
dbLoopObject(o,f(570,o),f(630,o))
Next
;Set default camera position
camx.f = 0
camy.f = 0
camz.f = 0
dbPositionCamera(0, 900, 500)
;Make some paths, interfacing with the lua functions
MakePath("Patrol1")
AddWaypoint("Patrol1",-950,0,-728)
AddWaypoint("Patrol1",-950,0,-72)
AddWaypoint("Patrol1",-294,0,-72)
AddWaypoint("Patrol1",-294,0,-728)
AddObject(100,"Patrol1",4)
MakePath("Patrol2")
AddWaypoint("Patrol2",-950,0,-1432)
AddWaypoint("Patrol2",-238,0,-1432)
AddWaypoint("Patrol2",-174,0,-1968)
AddWaypoint("Patrol2",60,0,-2216)
AddWaypoint("Patrol2",0,0,-2536)
AddWaypoint("Patrol2",-136,0,-2448)
AddWaypoint("Patrol2",100,0,-2176)
AddWaypoint("Patrol2",-120,0,-2000)
AddWaypoint("Patrol2",-64,0,-1368)
AddObject(101,"Patrol2",4)
Repeat
If dbMouseY() < 10
camz = camz + 8
EndIf
If dbMouseY() > dbScreenHeight() - 10
camez = camez - 8
EndIf
If dbMouseX()<10
camx = camx - 8
EndIf
If dbMouseX()> dbScreenWidth() -10
camx = camx + 8
EndIf
If camx > 0
camx = 0
EndIf
If camx < -950
camx = -950
EndIf
If camz > 1100
camz = 1100
EndIf
If camz < -2800
camz = -2800
EndIf
dbPositionCamera(dbCurveValue(camx, dbCameraPositionX(), 10), dbCurveValue(camy + 900, dbCameraPositionY(), 10), dbCurveValue(camz -500, dbCameraPositionZ(), 10))
dbPositionObject(999, camx, 10, camz)
dbPointCamera(camx, camy, camz)
;Call lua function to update position of the objects
dbLuaSetFunction("UpdateObject",1,0)
dbLuaPushInt(100)
dbLuaCall()
dbLuaSetFunction("UpdateObject",1,0)
dbLuaPushInt(101)
dbLuaCall()
dbText(10,5,"LUA WAYPOINTS DEMO: movement of units controlled entirely by scripts")
dbText(10,15,"Move mouse to sides of screen to move")
dbText(10,30,"Frames per second: "+ Str(dbScreenFPS()))
dbSync()
ForEver
; IDE Options = PureBasic 4.10 (Windows - x86)
; CursorPosition = 151
; FirstLine = 108
; Folding = -
; EnableXP
; Executable = Unity_Example.exe
; CompileSourceDirectory