require "luascape.reflect"
require "luascape.system"

loadModule("ai")
reflect.makeNamespaceGlobal("scape::ai")
reflect.makeNamespaceGlobal("scape::ai::fuzzy")
reflect.makeNamespaceGlobal("scape::ai::model")
reflect.makeNamespaceGlobal("scape::ai::sensor")
reflect.makeNamespaceGlobal("scape::ai::drive")

ai = {}

function ai.generateNavMesh(scene)
  local producer = scape.ai.NavMeshProducer()
  producer:produce(scene)
  local mesh = producer:mesh() 
  return mesh
end

function ai.saveNavMesh(navMesh,filename)
  scape.io.Serializer.saveToFile(filename,scape.reflect.Value(navMesh),scape.io.XMLSaveToken())
end

function ai.loadNavMesh(filename)
  local navMesh = scape.io.Serializer.loadFromFile(filename)
  return navMesh
end