Thanks To Blitzmax And Leadwerks

Miscellaneous Forums/General Discussion/Thanks To Blitzmax And Leadwerks

I like Leadwerks Engine 2 as it is somewhat familiar to a Blitzer.

I am going to stick with version 2.0 rather than the new 2.1 just to get comfortable with it.

"halo" has clearly put considerable time into making his video tutorials, which have an accompanying PDF. I am sure there are more of them to come. His video tutorials are actually well explained and great for a complete novice to follow.

Although it doesn't ship with loads of examples (as it is not a programming language), it has two main demos - an internal FPS-type level demo and an external Far-Cry-ish terrain demo that come with code/scripts.

I do think it possible that the Leadwerks Engine will become a major player and I can envisage development teams licensing it - perhaps as a cheaper alternative to some of the big-boy engines. Some people will criticise the hardware requirements, but anybody looking to commercially develop with this engine probably will not (considering hardware requirements can increase before a project is complete - which is often a reason why games are delayed - baring in mind a game can spend a couple of years in development). In addition, the hardware requirements enable the forums to be somewhat professional development - so it works two ways.

I haven't fully played with the engine - I only installed it a couple of days ago, so I cannot vouch for how complete or stable it is. However, it certainly seems to be constant work-in-progress (like all the other engines out there). I can't imagine that "halo" would just give up on it, etc - I think he is somewhat driven by improving it and he probably sees it as an engine for commercial developers.

You have to take into account you will also need Ultimate Unwrap, etc to import your models/meshes in to the gmf format.

This is what the BMax code looks like for the FPS-like level - the one featured in the video - http://www.youtube.com/watch?v=cmN7OLy6yUY

The video is the Sandbox editor in action - the BMax code is to basically walk through the level (in a FPS spectator-style). Unfortunatley, the video doesn't show the large rotating fan-blades which have a light behind them - casting moody, Doom 3-like, shadows up a corridor. You'll have to buy the engine for that.

Strict

Framework leadwerks.engine
Import "AppSettings.bmx"

AppLogMode 0

RegisterAbstractPath("../")

AppTitle=StripAll(AppFile)

SetGraphicsDriver GLGraphicsDriver(),GRAPHICS_BACKBUFFER|GRAPHICS_DEPTHBUFFER
If Not Graphics(Int(AppSetting("GFXWidth","1024")),Int(AppSetting("GFXHeight","768")))
	Notify "Failed to initialize graphics window.",1
	End
EndIf

Local lightquality=Int(AppSetting("LightQuality","2"))

If Not CreateWorld()
	Notify "Failed to create world.",1
	End
EndIf

Local spectator:TBody=CreateBodySphere(0.45)
PositionEntity spectator,Vec3(2,4,-4)
SetBodyGravity spectator,0
SetBodyMass spectator,1.0
SetBodyDamping spectator,1.0,0.0
EntityType spectator,1

EntityType LoadBody("abstract::room.phy"),1

Collisions 1,1,1

Local cam:TCamera=CreateCamera()
cam.clsmode=CLS_DEPTH
cam.clscolor=Vec4(0,0,1,1)
CameraRange cam,0.1,40' always use the shortest camera range possible in indoor scenes

AFilter 4
TFilter 1

Local scene:TMesh
scene=LoadMesh("abstract::room.gmf")
HideEntity FindChild(scene,"cardboard")' this object doesn't have a material assigned so I will just hide it.

Local vsync=0
Local camspeed#=5.0
Local mx#,my#,camrotation:TVec3

Local light1:TLight
light1=CreatePointLight(3,FindChild(scene,"light1"))
EntityColor light1,Vec4(1,0.5,0.0,3)
EntityViewRange light1,15,15
LightRange light1,5
If LightQuality=3 SetShadowMapSize light1,256

Local corona:TCorona
Local light2:TLight
light2=CreateSpotLight(8,FindChild(scene,"corona2"))
LightConeAngles light2,45,55
LightRange light2,5
RotateEntity light2,Vec3(90,0,0)
EntityViewRange light2,15,15
If LightQuality=3 SetShadowMapSize light2,256

Local light3:TLight
light3=CreateSpotLight(8,FindChild(scene,"fanlight"))
LightConeAngles light3,15,20
LightRange light3,25
EntityColor light3,Vec4(1,1,1,8)
corona=CreateCorona(light3)
corona.paint loadmaterial("abstract::flare1.mat")
SetCoronaRadius corona,3,3
EntityViewRange corona,17,20
If LightQuality=3 SetShadowMapSize light3,256

Local light4:TLight
light4=CreateSpotLight(8,FindChild(scene,"light4"))
LightConeAngles light4,45,55
LightRange light4,5
RotateEntity light4,Vec3(35,0,0)
EntityColor light4,Vec4(1,0.5,0.0,3)
EntityViewRange light4,30,30
If LightQuality=3 SetShadowMapSize light4,256

Local light5:TLight
light5=CreatePointLight(4,FindChild(scene,"light5"))
EntityColor light5,Vec4(1,0.5,0.0,3)
EntityViewRange light5,10,10
If LightQuality=3 SetShadowMapSize light5,256

Local fan:TEntity=FindChild(scene,"Fanblades")

corona=CreateCorona(FindChild(scene,"corona1"))
EntityViewRange corona,8,10
PaintEntity corona,loadmaterial("abstract::flare1.mat")

corona=CreateCorona(FindChild(scene,"corona2"))
EntityViewRange corona,8,10
PaintEntity corona,loadmaterial("abstract::flare1.mat")

Local buffer:TBuffer=CreateBuffer(GraphicsWidth(),GraphicsHeight())

Global tanks:TEntity=scene.findchild("tanks")

Local postfilter:TShader=LoadShader("abstract::postfilter.vert","abstract::postfilter_ssao.frag")
SetShader postfilter
SetUniform2f GetUniform("screensize"),GraphicsWidth(),GraphicsHeight()
SetUniform2f GetUniform("camerarange"),cam.nearrange,cam.farrange
AmbientLight Vec3(0.3)

'Pre-cache shaders
For Local light:TLight=EachIn CurrentWorld().lights
	PositionEntity cam,EntityPosition(light,1)
	MoveEntity cam,Vec3(0,0,-0.5)
	RotateEntity cam,Vec3(90,0,0)
	RenderWorld()
	RotateEntity cam,Vec3(-90,0,0)
	RenderWorld()
	RotateEntity cam,Vec3(0,90,0)
	RenderWorld()
	RotateEntity cam,Vec3(0,-90,0)
	RenderWorld()
	RotateEntity cam,Vec3(180,0,0)
	RenderWorld()
	RotateEntity cam,Vec3(0,0,0)
	RenderWorld()
Next

Local playerstart:TEntity=FindChild(scene,"playerstart")
If playerstart
	PositionEntity spectator,playerstart.position
	RotateEntity cam,playerstart.rotation
EndIf

HideMouse()
MoveMouse BufferWidth(BackBuffer())/2,BufferHeight(BackBuffer())/2

SceneGraphMode 1
ShadowQuaLITY lightquality
occlusionculling 1

PositionEntity cam,spectator.position

While Not KeyHit(KEY_ESCAPE)
	
	TurnEntity light4,Vec3(0,AppSpeed()*3.0,0)
	If fan fan.turn Vec3(AppSpeed()*2.0,0,0)
	
	mx=Curve(MouseX()-BufferWidth(BackBuffer())/2,mx,4.0/AppSpeed())
	my=Curve(MouseY()-BufferHeight(BackBuffer())/2,my,4.0/AppSpeed())
	MoveMouse BufferWidth(BackBuffer())/2,BufferHeight(BackBuffer())/2
	
	camrotation=EntityRotation(cam)
	camrotation.x:+my*0.1
	camrotation.y:-mx*0.1
	RotateEntity cam,camrotation
	
	AddBodyForce spectator,TFormVector(Vec3((KeyDown(KEY_D)-KeyDown(KEY_A))*camspeed*AppSpeed(),0,(KeyDown(KEY_W)-KeyDown(KEY_S))*camspeed*AppSpeed()),cam,Null)
	
	UpdateWorld()
	
	PositionEntity cam,Vec3(Curve(spectator.position.x,cam.position.x,4),Curve(spectator.position.y,cam.position.y,4),Curve(spectator.position.z,cam.position.z,4))
	
	SetBuffer buffer
	RenderWorld()
	
	setbuffer backbuffer()
	SetShader postfilter
	buffer.depthbuffer.bind(1)
	DrawImage buffer.colorbuffer,0,0
	SetShader Null
	
	SetBlend BLEND_ALPHA
	DrawText "FPS: "+UPS(),0,0
	DrawText cam.LightDrawQueue.count()+" lights",0,20
	DrawText TrisRendered()+" polys",0,40
	DrawText CurrentWorld().shadowsdrawn+" shadows updated",0,60
	SetBlend 0
	Flip 0
Wend

EndRender()
End