#Include "Ninfa3d.bi"

'Don't use this BSP map for comercial purpose

dim Shared camera As nCAMERA

'Enable vertical synch.
EnableVsync()

'Starts the Ninfa3D Engine
InitEngine(1024,768,32,0)
	BackGroundColor(128,128,128)'Background Color
	AmbientLight(64,64,64)'Ambient color
    WorldSize(30000,30000,30000)
    WorldGravity(0,-200,0)
    PhysicQuality(Q_LINEAR)
'Include the file "SampleFuntions.bi.
'It contains useful features, such as drawing the interface and create the test area.
#Include "SampleFunctions.bi"

'Create a camera
camera = CreateCameraFPS(100,1)
camerarange(camera,1,11000)
PositionEntity(camera,0,180,0)' Position

	
'Ninfa3d, As "Irrlichter" used to display graphics and load files,
'you can load files like "zip" and "PK3".
'When you load a file "zip" or "PK3",
'all content is loaded into memory and only have to tell you the name of the file to load.
LoadZip("data/chiropteraDM.pk3")

DIM AS UINTEGER PTR BSPMesh = LoadMeshBSP("chiropteraDM.bsp")
DIM AS UINTEGER PTR BSPNode = CreateNodeBSPfromMeshBSP( BSPMesh )

dim as nbody bdybsp=CreateBodyTreeBSP(BSPMesh,BSPNode)

StaticCollisionsBSP(BSPMesh,BSPNode,camera)

dim as nTEXTURE tex02 = LoadTexture("media\FullskiesOvercast0036_1_S.jpg")
CreateSkyDome(tex02,10000)'Creates the sky

While(EngineRun)'Returns 1 if the engine is running.

	'Begins scene
	BeginScene()
	
	'By pressing the "ESCAPE" closes the engine.
	If KeyHit(KEY_ESCAPE) Then CloseEngine()
	'Update the Engine.
	'Changing the value (only affects the physics) that will update the
	'Physical faster or slower.
	UpdateEngine(0.05)
    WorldMousePick(MouseX(),MouseY(),MouseDown(MOUSE_LEFT))
    If MouseHit(MOUSE_RIGHT) Then CreateBullet()
	'Displays the interface (FPS and triangles)
	'Interface()
    Text(15,75,"MouseLeft=pick, MouseRight=shoot")
	'End the scene
	EndScene()
	
Wend

'Ends Ninfa3D Engine
EndEngine()