-- $LastChangedDate: 2011-03-17 19:59:52 -0400 (Thu, 17 Mar 2011) $
-- Macros written in Lua to expand C++ code for bindings between C++/Lua.
-- Avoid lua_/LUA_ which is reserved by Lua.

bindTable = {

class = "World",
typesig = nil,
luaCanInstantiate = false,

headers =
[[
#include "base/module.hh"
using namespace base;
#include "object/module.hh"
#include "object/object.hh"
using namespace object;
#include "world/module.hh"
using namespace world;
]],

func_Make = {
    comments = "fp World:Make() -- load terrain model",
    code = [[
        GET_WORLD().Make();
    ]]
},

func_Meters2Sim = {
    comments = "fp World:Meters2Sim( Meter )",
    code = [[
        const Meter meter( POP_FP( L ) );
        const fp sim = world::conv::Meters2Sim( meter );
        lua_pushnumber( L, sim );
        return 1;  // stack items to return
    ]]
},

func_Sim2Meters = {
    comments = "Meter World:Sim2Meters( simDistance )",
    code = [[
        const Meter meters = world::conv::Sim2Meters( POP_FP( L ) );
        lua_pushnumber( L, meters.FP() );
        return 1;  // stack items to return
    ]]
},

func_SphereVertex2WorldVertex = {
    comments = "Vec3 World:SphereVertex2WorldVertex( lat,lon,alt|Vec3 )",
    code = [[
        const SphereVertex sv = POP_SPHERE_VERTEX( L );
        const WorldVertex wv = world::conv::SphereVertex2WorldVertex( sv );
        PUSH_VECTOR3<WorldVertex>( L, wv );
        return 1;  // stack items to return
    ]]
},

func_WorldVertex2SphereVertex = {
    comments = "{lat,lon,alt} World:WorldVertex2SphereVertex( Vec3 )",
    code = [[
        const WorldVertex  wv = POP_VECTOR3<WorldVertex>( L );
        const SphereVertex sv = world::conv::WorldVertex2SphereVertex( wv );
        PUSH_SPHERE_VERTEX( L, sv );
        return 1;  // stack items to return
    ]]
},

func_RotateTangential = {
    comments = "World:RotateTangential( Object, lat,lon,alt|Vec3 )\n * Rotate an Object to be level at a point on spherical world.",
    code = [[
        const SphereVertex sv = POP_SPHERE_VERTEX( L );
        shptr<Object> object = POP_USERDATA_AS_SHPTR<Object>( L );
        CHECK_TYPESIG(object,TYPESIG_OBJECT);
        GET_WORLD().RotateTangential( *object, sv );
    ]]
},

func_AltitudeInMeters = {
    comments = "bool World:AltitudeInMeters(worldVertex)",
    code = [[
        const WorldVertex pos = POP_VECTOR3<WorldVertex>( L );
        const SphereVertex sv = world::conv::WorldVertex2SphereVertex( pos );
        lua_pushnumber( L, sv.mAlt.FP() );
        return 1;  // stack items to return
    ]]
},

func_IfLowAltitude = {
    comments = "bool World:IfLowAltitude(pos)",
    code = [[
        const WorldVertex pos = POP_VECTOR3<WorldVertex>( L );
        lua_pushboolean( L, GET_WORLD().IfLowAltitude( pos ) );
        return 1;  // stack items to return
    ]]
},

}
