/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#include "binding_helpers.h"
#include "script_squirrel/cobject/matrix_decl.h"
#include "scene3d/mitem_event_interface.h"
#include "scene3d/scene_ace_manager.h"
#include "scene3d/mcamera.h"
#include "scene3d/mlight.h"
#include "scene3d/mobject.h"
#include "scene3d/memitter.h"
#include "scene3d/mtrigger.h"
#include "scene3d/instance.h"
#include "scene3d/scene.h"
#include "scene3d/group.h"
#include "motion/motion_automation_source.h"
#include "script/scripted_object.h"
#include "script/script_unit.h"
#include "metafile/nml_object.h"
#include "core/resource_factories.h"
using namespace GS;
using namespace GS::S3D;
using namespace GS::Script;
static CObjectType item_derived_types[] = { typetag_Item, typetag_Camera, typetag_Object, typetag_Light, typetag_Trigger, typetag_Emitter, typetag_Undefined };
//------------------------------------------------------------------------------
SQInteger ItemTranslate(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(i, MItem, item_derived_types)
__SQ_GETVECTOR(t)
__SQ_GETEND
i->GetBaseItem()->SetPosition(i->GetBaseItem()->GetPosition() + t);
__SQ_RETURN
}
SQInteger ItemRotate(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(i, MItem, item_derived_types)
__SQ_GETVECTOR(e)
__SQ_GETEND
i->GetBaseItem()->SetRotation(i->GetBaseItem()->GetRotation() + e);
__SQ_RETURN
}
SQInteger ItemScale(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(i, MItem, item_derived_types)
__SQ_GETVECTOR(s)
__SQ_GETEND
i->GetBaseItem()->SetScale(i->GetBaseItem()->GetScale() * s);
__SQ_RETURN
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemCastToEmitter(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(i, MItem, typetag_Item)
if (i->GetItemType() != Type_Emitter)
return sq_throwerror(vm, "Invalid item cast, item is not a particle emitter.");
__SQ_RETURNSAFEPTR((MEmitter *)i, typetag_Emitter)
}
SQInteger ItemCastToCamera(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(i, MItem, typetag_Item)
if (i->GetItemType() != Type_Camera)
return sq_throwerror(vm, "Invalid item cast, item is not a camera.");
__SQ_RETURNSAFEPTR((MCamera *)i, typetag_Camera)
}
SQInteger ItemCastToObject(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(i, MItem, typetag_Item)
if (i->GetItemType() != Type_Object)
return sq_throwerror(vm, "Invalid item cast, item is not an object.");
__SQ_RETURNSAFEPTR((MObject *)i, typetag_Object)
}
SQInteger ItemCastToTrigger(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(i, MItem, typetag_Item)
if (i->GetItemType() != Type_Trigger)
return sq_throwerror(vm, "Invalid item cast, item is not a trigger.");
__SQ_RETURNSAFEPTR((MTrigger *)i, typetag_Trigger)
}
SQInteger ItemCastToLight(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(i, MItem, typetag_Item)
if (i->GetItemType() != Type_Light)
return sq_throwerror(vm, "Invalid item cast, item is not a light.");
__SQ_RETURNSAFEPTR((MLight *)i, typetag_Light)
}
SQInteger ItemCastToInstance(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(i, MItem, typetag_Item)
if (i->GetItemType() != Type_Instance)
return sq_throwerror(vm, "Invalid item cast, item is not an instance.");
__SQ_RETURNSAFEPTR((Instance *)i, typetag_Instance)
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemDerivedCastToItem(HSQUIRRELVM vm)
{
MItem *item = NULL;
//-----------------------------------
#define __GrabDerivedItem(__T__)\
{\
__T__ *i;\
CObject::Get(vm, -1, (void **)&i);\
item = i;\
}\
break;
//-----------------------------------
CObjectType type;
if (!CObject::GetType(vm, -1, type))
return -1;
switch (type)
{
case typetag_Camera:
__GrabDerivedItem(MCamera)
case typetag_Light:
__GrabDerivedItem(MLight)
case typetag_Object:
__GrabDerivedItem(MObject)
case typetag_Trigger:
__GrabDerivedItem(MTrigger)
case typetag_Emitter:
__GrabDerivedItem(MEmitter)
case typetag_Item:
__GrabDerivedItem(MItem)
default: break;
}
sq_pop(vm, 1);
__SQ_RETURNSAFEPTR(item, typetag_Item)
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemRegistrySetKey(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(key)
GS::Variant value;
HSQOBJECT o;
sq_getstackobj(vm, __SQ_STACKPOS, &o);
switch (sq_type(o))
{
case OT_BOOL:
{ __SQ_GETBOOL(v) value = asbool(v); } break;
case OT_INTEGER:
{ __SQ_GETINT(v) value = (int)v; } break;
case OT_FLOAT:
{ __SQ_GETFLOAT(v) value = v; } break;
case OT_STRING:
{ __SQ_GETSTRING(s) value = s; } break;
default: return sq_throwerror(vm, "Unsupported key value type.");
}
item->GetBaseItem()->registry.CreateKey(key, &value);
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemRegistryGetKey(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(key)
__SQ_GETEND
GS::Variant v(-1);
GS::NML::Tag *tag = item->GetBaseItem()->registry.GetTag(key);
if (tag)
v = tag->GetValue();
switch (v.GetType())
{
case GS::Variant::VariantBool: __SQ_RETURNBOOL(v.b_value)
case GS::Variant::VariantInteger: __SQ_RETURNINT(v.i_value)
case GS::Variant::VariantFloat: __SQ_RETURNFLOAT(v.f_value)
case GS::Variant::VariantString: __SQ_RETURNSTRING(v.s_value.c_str())
}
__SQ_RETURNINT(-1)
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemSetCommandList(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(list)
ACEManager::Get()->LoadACECommandList(list, item);
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemResetCommandList(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(item, MItem, typetag_Item)
item->ResetCommandList();
__SQ_RETURN
}
SQInteger ItemIsCommandListDone(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNBOOL(item ? item->IsCommandListDone() : true)
}
//------------------------------------------------------------------------------
SQInteger ItemPrint(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__LOG__ << "Item: " << (asbool(item) ? item->name.c_str() : "Null") << " (Uid = " << (asbool(item) ? item->GetUid() : -1) << ").\n";
__SQ_RETURN
}
SQInteger ItemReset(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
item->Reset();
__SQ_RETURN
}
SQInteger ItemGetType(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNINT(item ? item->GetItemType() : 0)
}
SQInteger ItemRenderSetup(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSAFEPTR(f, Core::ResourceFactories, typetag_ResourceFactories)
__SQ_GETEND
if (item->GetBaseItem())
item->GetBaseItem()->RenderSetup(f);
__SQ_RETURN
}
//------------------------------------------------------------------------------
#define __SQ_GETMITEMSCRIPTOBJECT(__SRC) ScriptedObject *scripted_object = __SRC->scripted_object; if (!scripted_object) return sq_throwerror(vm, "No script system in scene!");
#define __SQ_ASSERTSCRIPTUNITOPEN(__UNIT, __NAME) if (!(__UNIT)->IsOpen()) return sq_throwerror(vm, GS::String::Format("Script unit for '%s' is not open.", __NAME));
SQInteger ItemSetScript(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(script_file)
__SQ_GETSTRING(script_class)
__SQ_GETMITEMSCRIPTOBJECT(item)
if (!scripted_object->GetUnitList().GetCount())
scripted_object->AddUnit(scripted_object->NewUnit());
if (GS::Script::Unit *unit = scripted_object->GetUnitList().ObjectAt(0))
{
unit->script_file = script_file;
unit->script_class = script_class;
}
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemGetScriptInstance(HSQUIRRELVM vm) // LEGACY
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETMITEMSCRIPTOBJECT(item)
if (!scripted_object->GetUnitList().GetCount())
return sq_throwerror(vm, GS::String::Format("Item '%s' has no script unit.", item->name.c_str()));
Script::Unit *unit = scripted_object->GetUnitList()[0];
__SQ_ASSERTSCRIPTUNITOPEN(unit, item->name.c_str())
__SQ_RETURNOBJECT(((Script::SquirrelObject *)unit->Self())->object);
}
SQInteger ItemGetScriptInstanceCount(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETMITEMSCRIPTOBJECT(item)
__SQ_RETURNINT(scripted_object->GetUnitList().GetCount())
}
SQInteger ItemGetScriptInstanceFromIndex(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETEND
__SQ_GETMITEMSCRIPTOBJECT(item)
Script::Unit *unit = scripted_object->GetUnitList().ObjectAt(index);
__SQ_ASSERTSCRIPTUNITOPEN(unit, item->name.c_str())
__SQ_RETURNOBJECT(((Script::SquirrelObject *)unit->Self())->object);
}
SQInteger ItemGetScriptInstanceFromClass(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(_class)
__SQ_GETMITEMSCRIPTOBJECT(item)
Script::Unit *_unit = 0;
ListForeachPtr(Script::Unit *, unit, scripted_object->GetUnitList())
if (unit->script_class == _class)
{
_unit = unit;
break;
}
__SQ_GETEND
if (_unit)
{
__SQ_ASSERTSCRIPTUNITOPEN(_unit, item->name.c_str())
__SQ_RETURNOBJECT(((Script::SquirrelObject *)_unit->Self())->object);
}
return sq_throwerror(vm, "Script unit not found");
}
SQInteger ItemHasScript(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(_class)
__SQ_GETMITEMSCRIPTOBJECT(item)
Script::Unit *_unit = 0;
ListForeachPtr(Script::Unit *, unit, scripted_object->GetUnitList())
if (unit->script_class == _class)
{
_unit = unit;
break;
}
__SQ_GETEND
__SQ_RETURNBOOL(asbool(_unit))
}
SQInteger ItemSetupScript(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETMITEMSCRIPTOBJECT(item)
if (!scripted_object->GetUnitList().GetCount())
scripted_object->AddUnit(scripted_object->NewUnit());
if (Script::Unit *unit = scripted_object->GetUnitList().ObjectAt(0))
unit->Open();
__SQ_RETURN
}
//------------------------------------------------------------------------------
SQInteger ItemCompare(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item_a, MItem, item_derived_types)
__SQ_GETCOBJECTBASE(item_b, MItem, item_derived_types)
__SQ_GETEND
__SQ_RETURNBOOL(item_a == item_b ? true : false)
}
//------------------------------------------------------------------------------
SQInteger ItemIsActive(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNBOOL(item ? item->isActive() : false)
}
//------------------------------------------------------------------------------
SQInteger ItemIsInvisible(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNBOOL(item ? item->GetBaseItem()->item_flags.IsSet(ItemFlagInvisible) : true)
}
SQInteger ItemSetInvisible(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETBOOL(invisible)
__SQ_GETEND
item->GetBaseItem()->item_flags.Raise(ItemFlagInvisible, invisible ? true : false);
__SQ_RETURN
}
//------------------------------------------------------------------------------
static void SetItemInvisibleRecursive(Core::Item *i, bool v)
{
i->item_flags.Raise(ItemFlagInvisible, v);
ListForeachPtr(Core::Item *, c, i->GetChildren())
SetItemInvisibleRecursive(c, v);
}
SQInteger ItemHierarchySetInvisible(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETBOOL(invisible)
__SQ_GETEND
SetItemInvisibleRecursive(item->GetBaseItem(), asbool(invisible));
__SQ_RETURN
}
//------------------------------------------------------------------------------
SQInteger ItemRecordLocation(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
item->SetInitialTransformation();
__SQ_RETURN
}
SQInteger ItemGetMinMax(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
MinMax minmax;
item->GetBaseItem()->ComputeLocalMinMax(minmax);
__SQ_RETURNMINMAX(minmax)
}
SQInteger ItemGetMatrix(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNMATRIX4(item->GetBaseItem()->GetMatrix())
}
SQInteger ItemGetInverseMatrix(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNMATRIX4(item->GetBaseItem()->GetInverseMatrix())
}
SQInteger ItemGetLocalMatrix(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNMATRIX4(item->GetBaseItem()->GetLocalMatrix())
}
SQInteger ItemSetMatrix(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETMATRIX4(mtx)
__SQ_GETEND
item->GetBaseItem()->SetMatrix(mtx);
__SQ_RETURN
}
SQInteger ItemGetRotationMatrix(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNMATRIX3(GS::Matrix3::FromMatrix4(item->GetBaseItem()->GetMatrix()))
}
SQInteger ItemSetRotationMatrix(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETMATRIX3(mtx)
__SQ_GETEND
item->GetBaseItem()->SetRotation(mtx);
__SQ_RETURN
}
SQInteger ItemSnapshotTransformation(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
item->GetBaseItem()->SnapshotTransformation(item->GetBaseItem()->GetMatrix());
__SQ_RETURN
}
SQInteger ItemSnapshotMatrix(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETMATRIX4(m)
__SQ_GETEND
item->GetBaseItem()->SnapshotTransformation(m);
__SQ_RETURN
}
SQInteger ItemGetGeometry(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
if (item->GetItemType() != Type_Object)
return sq_throwerror(vm, "Item is not an object, cannot get geometry");
if (((MObject *)item)->render_data.IsNull())
__SQ_RETURNNULL
__SQ_RETURNSAFEPTR(((MObject *)item)->render_data->geometry.c_ptr(), typetag_Geometry)
}
SQInteger ItemSaveGeometry(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(path)
__SQ_GETSAFEPTR(f, Core::ResourceFactories, typetag_ResourceFactories)
__SQ_GETEND
if (item->GetItemType() != Type_Object)
return sq_throwerror(vm, "Item is not an object, cannot get geometry");
else
{
NML::SaveToFile(*f->graphic->LoadGeometry(((MObject *)item)->geometry), path);
}
__SQ_RETURN
}
SQInteger ItemGetOpacity(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNFLOAT(item->GetBaseItem()->opacity)
}
SQInteger ItemSetOpacity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(a)
__SQ_GETEND
item->GetBaseItem()->opacity = Types::Clamp(a);
__SQ_RETURN
}
SQInteger ItemSetPriority(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(p)
__SQ_GETEND
item->SetPriority(p);
__SQ_RETURN
}
SQInteger ItemSetExcludeFromRecord(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(exclude)
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemGetExcludeFromRecord(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNBOOL(false)
}
SQInteger ItemGetChild(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(name)
__SQ_GETEND
MItem *_ci = NULL;
ListForeachPtr(Core::Item *, ci, item->GetBaseItem()->GetChildren())
if (Scene::LocateManagedItem(ci)->name == name)
{
_ci = Scene::LocateManagedItem(ci);
break;
}
__SQ_RETURNSAFEPTR(_ci, typetag_Item)
}
SQInteger ItemGetName(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNSTRING(item->name.c_str())
}
SQInteger ItemSetName(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(_name)
item->name = _name;
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemGetRotationOrder(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNINT((int)item->GetBaseItem()->GetRotationOrder())
}
SQInteger ItemSetRotationOrder(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(rorder)
__SQ_GETEND
item->GetBaseItem()->SetRotationOrder((Math::rOrder)rorder);
__SQ_RETURN
}
SQInteger ItemComputeMatrix(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURN
}
SQInteger ItemComputeLocalMatrix(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURN
}
SQInteger ItemComputeMinMax(HSQUIRRELVM vm)
{
__SQ_GETSINGLESAFEPTR(item, MItem, typetag_Item)
MinMax minmax;
item->GetBaseItem()->ComputeLocalMinMax(minmax);
__SQ_RETURN
}
SQInteger ItemSetLinkInheritsPositionOnly(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETBOOL(flag)
__SQ_GETEND
item->GetBaseItem()->item_flags.Raise(ItemFlagInheritPositionOnly, asbool(flag));
__SQ_RETURN
}
SQInteger ItemSetPosition(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
item->GetBaseItem()->SetPosition(p);
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemGetPosition(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->GetPosition())
}
SQInteger ItemSetScale(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(s)
__SQ_GETEND
item->GetBaseItem()->SetScale(s);
__SQ_RETURN
}
SQInteger ItemGetScale(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->GetScale())
}
SQInteger ItemGetWorldPosition(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->GetMatrix().GetRow(3))
}
SQInteger ItemGetWorldRotation(HSQUIRRELVM vm) {
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(GS::Matrix3::FromMatrix4(item->GetBaseItem()->GetMatrix()).AsEuler())
}
SQInteger ItemGetPreviousWorldPosition(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->GetPreviousMatrix().GetRow(3))
}
SQInteger ItemSetPivot(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETEND
GS::Matrix4 m;
m.SetRow(3, p);
item->GetBaseItem()->SetPivot(m);
__SQ_RETURN
}
SQInteger ItemGetPivot(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->GetPivot().GetRow(3))
}
SQInteger ItemSetRotation(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(e)
__SQ_GETEND
item->GetBaseItem()->SetRotation(e);
__SQ_RETURN
}
SQInteger ItemSetRotationQuaternion(HSQUIRRELVM vm)
{ return ItemSetRotation(vm); }
SQInteger ItemGetRotation(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->GetRotation())
}
SQInteger ItemSetTarget(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(target)
__SQ_GETEND
item->GetBaseItem()->SetTarget(&target);
__SQ_RETURN
}
SQInteger ItemSetNoTarget(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
item->GetBaseItem()->SetTarget(NULL);
__SQ_RETURN
}
SQInteger ItemGetTarget(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(item->GetBaseItem()->target)
}
SQInteger ItemHasTarget(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNBOOL(item->GetBaseItem()->item_flags.IsSet(ItemFlagHasTarget));
}
SQInteger ItemGetParent(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNSAFEPTR(Scene::LocateManagedItem(item->GetBaseItem()->GetParent()), typetag_Item)
}
SQInteger ItemSetLink(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETCOBJECTBASEALLOWNULL(link, MItem, item_derived_types)
__SQ_GETEND
item->GetBaseItem()->SetParent(link ? link->GetBaseItem() : NULL);
__SQ_RETURN
}
SQInteger ItemGetChildList(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
sq_newarray(vm, 0);
ListForeachPtr(Core::Item *, i, item->GetBaseItem()->GetChildren())
{
CObject::Push(vm, (void *)Scene::LocateManagedItem(i), typetag_Item);
sq_arrayappend(vm, -2);
}
return 1;
}
SQInteger ItemGetScriptLogicFrequency(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNFLOAT(-1.f)
}
SQInteger ItemSetScriptLogicFrequency(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(fq)
__SQ_GETEND
// item->logic_fq = fq;
__SQ_RETURN
}
//------------------------------------------------------------------------------
#define __SQ_GETPHYSICITEM(__I__) PhysicItem *iphysic = (__I__)->physic_item.c_ptr(); if (!iphysic) return sq_throwerror(vm, "No physics found, did you setup this item?");
SQInteger ItemGetSpeed(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNFLOAT(iphysic->GetLinearVelocity().Len())
}
SQInteger ItemWake(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
iphysic->SetSleeping(false);
__SQ_RETURN
}
SQInteger ItemSleep(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
iphysic->SetSleeping(true);
__SQ_RETURN
}
SQInteger ItemIsSleeping(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNBOOL(iphysic->IsSleeping())
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemPhysicResetTransformation(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETVECTOR(r)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->SetMatrix(GS::Matrix4::TransformationMatrix(p, r, Vector4(1, 1, 1)));
__SQ_RETURN
}
SQInteger ItemGetLinearDamping(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNFLOAT(iphysic->GetLinearDamping())
}
SQInteger ItemSetLinearDamping(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(d)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->SetLinearDamping(d);
__SQ_RETURN
}
SQInteger ItemSetGravityScale(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(k)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
// item->GetPhysics()->SetGravity(item->GetScene().GetPhysics()->GetGravity() * k);
__LOG_W__ << "ItemSetGravityScale(): STUB\n";
__SQ_RETURN
}
SQInteger ItemSetGravity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(g)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->SetGravity(g);
__SQ_RETURN
}
SQInteger ItemGetGravity(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetGravity())
}
SQInteger ItemGetAngularDamping(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNFLOAT(iphysic->GetAngularDamping())
}
SQInteger ItemSetAngularDamping(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETFLOAT(k)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->SetAngularDamping(k);
__SQ_RETURN
}
SQInteger ItemGetAngularVelocity(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetAngularVelocity())
}
SQInteger ItemSetAngularVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(w)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->SetAngularVelocity(w);
__SQ_RETURN
}
SQInteger ItemGetMass(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNFLOAT(item->physic_item_desc.GetMass())
}
SQInteger ItemCollided(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNBOOL(false) // TODO
}
SQInteger ItemUpdateInertiaTensorFromCollision(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
// iphysic->SetupBody();
__LOG_E__ << "ItemUpdateInertiaTensorFromCollision::FIXME\n";
__SQ_RETURN
}
SQInteger ItemPhysicGetFlag(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNINT(0)
}
SQInteger ItemPhysicSetFlag(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(f)
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemGetPhysicMode(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNINT(item->physic_item_desc.physic_mode)
}
SQInteger ItemSetPhysicMode(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(m)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
item->physic_item_desc.physic_mode = PhysicItemDesc::Mode(m);
__SQ_RETURN
}
SQInteger ItemSetInertiaTensorAndCom(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETMATRIX3(tensor)
__SQ_GETVECTOR(com)
__SQ_GETEND
__SQ_RETURN
}
SQInteger ItemPhysicSetLinearFactor(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(k)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
item->physic_item_desc.linear_factor.Set(k);
iphysic->SetLinearFactor(k);
__SQ_RETURN
}
SQInteger ItemPhysicSetAngularFactor(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(k)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
item->physic_item_desc.angular_factor.Set(k);
iphysic->SetAngularFactor(k);
__SQ_RETURN
}
SQInteger ItemApplyLinearForce(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(F)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->ApplyForce(F);
__SQ_RETURN
}
SQInteger ItemApplyForce(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETVECTOR(F)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->ApplyForce(F, &p);
__SQ_RETURN
}
SQInteger ItemApplyImpulse(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETVECTOR(J)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->ApplyImpulse(J, &p);
__SQ_RETURN
}
SQInteger ItemApplyLinearImpulse(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(J)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->ApplyImpulse(J);
__SQ_RETURN
}
SQInteger ItemApplyTorque(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(T)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->ApplyTorque(T);
__SQ_RETURN
}
SQInteger ItemGetLinearAcceleration(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(Vector4(0, 0, 0))
}
SQInteger ItemGetLinearVelocity(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetLinearVelocity())
}
SQInteger ItemGetPreviousLinearVelocity(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetLinearVelocity())
}
SQInteger ItemSetLinearVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(V)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->SetLinearVelocity(V);
__SQ_RETURN
}
SQInteger ItemGetLocalPointVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetLocalPointVelocity(p))
}
SQInteger ItemGetWorldPointVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetWorldPointVelocity(p))
}
SQInteger ItemGetPhysicPosition(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
GS::Matrix4 m;
iphysic->GetMatrix(m);
__SQ_RETURNVECTOR(m.GetRow(3))
}
SQInteger ItemSetPhysicPosition(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
GS::Matrix4 m;
iphysic->GetMatrix(m);
m.SetRow(3, p);
iphysic->SetMatrix(m);
__SQ_RETURN
}
SQInteger ItemGetPhysicPreviousPosition(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNVECTOR(Vector4(0, 0, 0))
}
SQInteger ItemSetPhysicPreviousPosition(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(position)
__SQ_GETEND
__LOG_E__ << "OBSOLETE\n";
__SQ_RETURN
}
SQInteger ItemGetPhysicRotation(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
GS::Matrix4 m;
iphysic->GetMatrix(m);
__SQ_RETURNVECTOR(GS::Matrix3::FromMatrix4(m).AsEuler())
}
SQInteger ItemSetPhysicRotation(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(r)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
GS::Matrix4 m;
iphysic->GetMatrix(m);
Vector4 p, s;
m.Decompose(&p, &s);
iphysic->SetMatrix(GS::Matrix4::TransformationMatrix(p, r, s));
__SQ_RETURN
}
SQInteger ItemPhysicSynchronizeCollision(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__ERR__(__LOG_E__ << "OBSOLETE", 0)
}
SQInteger ItemWorldPointVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(wp)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetWorldPointVelocity(wp))
}
SQInteger ItemPointVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(p)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetLocalPointVelocity(p))
}
SQInteger ItemGetCenterOfMass(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_GETPHYSICITEM(item)
__SQ_RETURNVECTOR(iphysic->GetCenterOfMass())
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemPhysicCharacterSetRotationMatrix(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETMATRIX3(m)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->CharacterSetRotationMatrix(m);
__SQ_RETURN
}
SQInteger ItemPhysicCharacterSetVelocity(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETVECTOR(V)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->CharacterSetVelocity(V);
__SQ_RETURN
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemPhysicVehicleSetForce(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETFLOAT(F)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->VehicleSetForce(F, index);
__SQ_RETURN
}
SQInteger ItemPhysicVehicleSetBrake(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETFLOAT(F)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->VehicleSetBrake(F, index);
__SQ_RETURN
}
SQInteger ItemPhysicVehicleSetSteering(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETFLOAT(v)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->VehicleSetSteering(v, index);
__SQ_RETURN
}
SQInteger ItemPhysicVehicleSetFriction(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETFLOAT(f)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
iphysic->VehicleSetFriction(f, index);
__SQ_RETURN
}
SQInteger ItemPhysicVehicleGetWheelMatrix(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETEND
__SQ_GETPHYSICITEM(item)
__SQ_RETURNMATRIX4(iphysic->VehicleGetWheelMatrix(index))
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemGetLocalMinMax(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
MinMax mm;
if (item->GetItemType() == Type_Object)
{
MObject *obj = (MObject *)item;
if (obj->geometry.IsEmpty())
mm.Set(obj->GetMatrix().GetRow(3), obj->GetMatrix().GetRow(3));
else
{
if (obj->render_data.IsNull())
return sq_throwerror(vm, "Object has no render data, you need to call ObjectRenderSetup() first.");
if (obj->render_data->geometry.IsNull())
return sq_throwerror(vm, "Object has no render geometry, you need to call ObjectRenderSetup() first.");
mm = obj->render_data->geometry->minmax;
}
}
__SQ_RETURNMINMAX(mm)
}
SQInteger ItemGetWorldMinMax(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
MinMax mm;
if (item->GetItemType() == Type_Object)
{
MObject *obj = (MObject *)item;
if (obj->geometry.IsEmpty())
mm.Set(obj->GetMatrix().GetRow(3), obj->GetMatrix().GetRow(3));
else
{
if (obj->render_data.IsNull())
return sq_throwerror(vm, "Object has no render data, you need to call ObjectRenderSetup() first.");
if (obj->render_data->geometry.IsNull())
return sq_throwerror(vm, "Object has no render geometry, you need to call ObjectRenderSetup() first.");
OBB obb(obj->render_data->geometry->minmax);
obb.Transform(obj->GetMatrix());
obb.ComputeMinMax(mm);
}
}
__SQ_RETURNMINMAX(mm)
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemGetSkinBoneItemsGroup(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
if (item->GetItemType() != Type_Object)
return sq_throwerror(vm, String("Item '") << item->name << "' is not an object.");
MObject *o = (MObject *)item;
Core::Skin *skin = o->GetSkin();
if (!skin)
return sq_throwerror(vm, String("Object '") << item->name << "' has no skin.");
Group *g = new Group;
for (uint n = 0; n < skin->bones.GetCount(); ++n)
g->Add(Scene::LocateManagedItem(skin->bones[n]));
__SQ_RETURNMANAGEDSAFEPTR(g, typetag_Group)
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemGetMotionCount(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNINT(item->automation_player->GetMotionList().GetCount())
}
SQInteger ItemGetMotionFromIndex(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(index)
__SQ_GETEND
__SQ_RETURNSAFEPTR(item->automation_player->GetMotionFromIndex(index), typetag_Motion)
}
SQInteger ItemStopAllMotions(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
item->automation_player->DisposeAutomationSources();
__SQ_RETURN
}
SQInteger ItemSetMotion(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETSTRING(name)
__SQ_GETFLOAT(blend)
Automation::Source *source = item->automation_player->StartAutomation(new Automation::MotionSource(item->automation_player->GetMotion(name), NULL), blend, Automation::Player::SourceSet);
__SQ_GETEND
__SQ_RETURNSAFEPTR(source, typetag_AutomationSource)
}
SQInteger ItemSetMotionRelative(HSQUIRRELVM vm)
{
__SQ_GETSTART(2)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETBOOL(v)
__SQ_GETEND
item->automation_player->flags.Raise(Automation::Player::FlagRelativeMotion, asbool(v));
__SQ_RETURN
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
SQInteger ItemSetFlags(HSQUIRRELVM vm)
{
__SQ_GETSTART(3)
__SQ_GETCOBJECTBASE(item, MItem, item_derived_types)
__SQ_GETINT(flags)
__SQ_GETBOOL(set_flags)
__SQ_GETEND
item->mitem_flags.Raise(flags, asbool(set_flags));
__SQ_RETURN
}
SQInteger ItemGetFlags(HSQUIRRELVM vm)
{
__SQ_GETSINGLE(__SQ_GETCOBJECTBASE(item, MItem, item_derived_types))
__SQ_RETURNINT(0) // item->item_flags.Get())
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void RegisterItemBinding(HSQUIRRELVM vm)
{
/*#
Topic: Item
Type: Item
Desc: The item object is the base of all scene 3d entities such as cameras, objects, lights or triggers.
It stores the entity transformation and motions.
Related: Scene,Camera,Object,Light,Trigger
#*/
/*#
Section: ItemRegistry
Desc: Item registry
#*/
/*#
Func: ItemRegistrySetKey
Proto: void:Item,string key,value
Desc: Set item registry key value.
#*/
sq_register(vm, ItemRegistrySetKey, "ItemRegistrySetKey", _SC(".xs."));
/*#
Func: ItemRegistryGetKey
Proto: value:Item,string key
Desc: Get item registry key value.
#*/
sq_register(vm, ItemRegistryGetKey, "ItemRegistryGetKey", _SC(".xs"));
/*#
Section: ItemACE
Desc: ACE
#*/
/*#
Func: ItemSetCommandList
Proto: void:Item,string command_list
Desc: Set item asynchronous command list (see ACE).
#*/
sq_register(vm, ItemSetCommandList, "ItemSetCommandList", _SC(".xs"));
/*#
Func: ItemResetCommandList
Proto: void:Item
Desc: Reset item asynchronous command list (see ACE).
#*/
sq_register(vm, ItemResetCommandList, "ItemResetCommandList", _SC(".x"));
/*#
Func: ItemIsCommandListDone
Proto: bool:Item
Desc: Reset item asynchronous command list (see ACE).
#*/
sq_register(vm, ItemIsCommandListDone, "ItemIsCommandListDone", _SC(".x"));
/*#
Section: ItemRender
Desc: Rendering
#*/
/*#
Func: ItemGetMinMax
Proto: MinMax:Item
Desc: Return the axis aligned bounding box in world space of the item.
#*/
sq_register(vm, ItemGetMinMax, "ItemGetMinMax", _SC(".x"));
/*#
Func: ItemGetOpacity
Proto: float:Item
Desc: Get item opacity.
#*/
sq_register(vm, ItemGetOpacity, "ItemGetOpacity", _SC(".x"));
sq_register(vm, ItemGetOpacity, "ItemGetAlpha", _SC(".x"));
/*#
Func: ItemSetOpacity
Proto: void:Item,float opacity
Desc: Set item opacity.
#*/
sq_register(vm, ItemSetOpacity, "ItemSetOpacity", _SC(".xn"));
sq_register(vm, ItemSetOpacity, "ItemSetAlpha", _SC(".xn"));
/*#
Section: ItemMotion
Desc: Motion
#*/
/*#
Func: ItemGetMotionCount
Proto: int:Item
Desc: Get the number of motion in the item motion bank.
#*/
sq_register(vm, ItemGetMotionCount, "ItemGetMotionCount", _SC(".x"));
/*#
Func: ItemGetMotionFromIndex
Proto: Motion:Item,int index
Desc: Get a motion from its index in the item motion bank.
#*/
sq_register(vm, ItemGetMotionFromIndex, "ItemGetMotionFromIndex", _SC(".xi"));
/*#
Func: ItemStopAllMotions
Proto: void:Item
Desc: Stop all motions on this item.
#*/
sq_register(vm, ItemStopAllMotions, "ItemStopAllMotions", _SC(".x"));
/*#
Func: ItemSetMotion
Proto: AnimationSource:Item,string name,float blend
Desc: Start a new motion on this item.
#*/
sq_register(vm, ItemSetMotion, "ItemSetMotion", _SC(".xsn"));
/*#
Func: ItemSetMotionRelative
Proto: void:Item,bool relative
Desc: Set this item to use relative motion source. Motion started on this item will automatically be set to the correct evaluation mode (relative/absolute).
#*/
sq_register(vm, ItemSetMotionRelative, "ItemSetMotionRelative", _SC(".xb"));
/*#
Section: ItemTransform
Desc: Transformation
#*/
/*#
Func: TranslateItem
Proto: void:Item item,Vector translation
Desc: Translate an item, the translation vector is expressed in the item parent space.
#*/
sq_register(vm, ItemTranslate, "TranslateItem", _SC(".xx"));
/*#
Func: RotateItem
Proto: void:Item item,Vector rotation
Desc: Rotate an item by a triplet of Euler angles stored in a vector.
#*/
sq_register(vm, ItemRotate, "RotateItem", _SC(".xx"));
/*#
Func: ScaleItem
Proto: void:Item item,Vector scale
Desc: Scale an item by a triplet of scale coefficients stored in a vector.
#*/
sq_register(vm, ItemScale, "ScaleItem", _SC(".xx"));
/*#
Func: ItemSetLinkInheritsPositionOnly
Proto: void:Item,bool inherits
Desc: Set the item to inherits only the position from its parent item.
#*/
sq_register(vm, ItemSetLinkInheritsPositionOnly, "ItemSetLinkInheritsPositionOnly", _SC(".xb"));
/*#
Func: ItemGetPosition
Proto: Vector:Item
Desc: Get item position in parent space (world space if no parent).
#*/
sq_register(vm, ItemGetPosition, "ItemGetPosition", _SC(".x"));
/*#
Func: ItemSetPosition
Proto: void:Item,Vector position
Desc: Set item position in parent space (world space if no parent).
#*/
sq_register(vm, ItemSetPosition, "ItemSetPosition", _SC(".xx"));
/*#
Func: ItemGetScale
Proto: Vector:Item
Desc: Get item scale.
#*/
sq_register(vm, ItemGetScale, "ItemGetScale", _SC(".x"));
/*#
Func: ItemSetScale
Proto: void:Item,Vector scale
Desc: Set item scale.
#*/
sq_register(vm, ItemSetScale, "ItemSetScale", _SC(".xx"));
/*#
Func: ItemGetWorldPosition
Proto: Vector:Item
Desc: Return item position in world space.
#*/
sq_register(vm, ItemGetWorldPosition, "ItemGetWorldPosition", _SC(".x"));
/*#
Func: ItemGetWorldRotation
Proto: Vector:Item
Desc: Get item rotation in world space as Euler angles (x, y, z).
Example:
// Get the world rotation of an item
local world_rot = ItemGetWorldRotation(item)
*/
sq_register(vm, ItemGetWorldRotation, "ItemGetWorldRotation", _SC(".x"));
/*#
Func: ItemGetPreviousWorldPosition
Proto: Vector:Item
Desc: Return item position in world space during the previously rendered frame.
#*/
sq_register(vm, ItemGetPreviousWorldPosition, "ItemGetPreviousWorldPosition", _SC(".x"));
/*#
Func: ItemGetRotation
Proto: Vector:Item
Desc: Get item rotation in Euler angles (x, y, z).
#*/
sq_register(vm, ItemGetRotation, "ItemGetRotation", _SC(".x"));
/*#
Func: ItemSetRotation
Proto: void:Item,Vector euler
Desc: Set item rotation in Euler angles (x, y, z).
Example:
// Set the item rotation to +90 degree on the Y axis.
ItemSetRotation(item, Vector(Deg(0), Deg(90), Deg(0)))
#*/
sq_register(vm, ItemSetRotation, "ItemSetRotation", _SC(".xx"));
/*#
Func: ItemSetRotationQuaternion
Proto: void:Item,Quaternion rotation
Desc: Set item rotation quaternion.
#*/
sq_register(vm, ItemSetRotationQuaternion, "ItemSetRotationQuaternion", _SC(".xx"));
/*#
Func: ItemGetPivot
Proto: Vector:Item
Desc: Get item pivot.
#*/
sq_register(vm, ItemGetPivot, "ItemGetPivot", _SC(".x"));
/*#
Func: ItemSetPivot
Proto: void:Item,Vector pivot
Desc: Set item pivot.
#*/
sq_register(vm, ItemSetPivot, "ItemSetPivot", _SC(".xx"));
/*#
Func: ItemComputeMatrix
Proto: void:Item
Desc: Compute item matrix and inverse matrix.
#*/
sq_register(vm, ItemComputeMatrix, "ItemComputeMatrix", _SC(".x"));
/*#
Func: ItemComputeLocalMatrix
Proto: void:Item
Desc: Compute item local matrix.
#*/
sq_register(vm, ItemComputeLocalMatrix, "ItemComputeLocalMatrix", _SC(".x"));
/*#
Func: ItemComputeMinMax
Proto: void:Item
Desc: Compute item minmax.
#*/
sq_register(vm, ItemComputeMinMax, "ItemComputeMinMax", _SC(".x"));
/*#
Func: ItemGetParent
Proto: Item:Item
Desc: Get item parent item.
#*/
sq_register(vm, ItemGetParent, "ItemGetParent", _SC(".x"));
/*#
Func: ItemSetParent
Proto: void:Item,Item parent
Desc: Set item parent item.
#*/
sq_register(vm, ItemSetLink, "ItemSetLink", _SC(".xx"));
sq_register(vm, ItemSetLink, "ItemSetParent", _SC(".xx"));
/*#
Func: ItemGetChildList
Proto: array:Item
Desc: Returns an array containing child items of this item.
#*/
sq_register(vm, ItemGetChildList, "ItemGetChildList", _SC(".x"));
/*#
Func: ItemSetTarget
Proto: void:Item,Vector world_target
Desc: Set item target position in world space.
#*/
sq_register(vm, ItemSetTarget, "ItemSetTarget", _SC(".xx"));
/*#
Func: ItemSetNoTarget
Proto: void:Item
Desc: Set no item target.
#*/
sq_register(vm, ItemSetNoTarget, "ItemSetNoTarget", _SC(".x"));
/*#
Func: ItemGetTarget
Proto: Vector:Item
Desc: Get item target position in world space.
#*/
sq_register(vm, ItemGetTarget, "ItemGetTarget", _SC(".x"));
/*#
Func: ItemHasTarget
Proto: bool:Item
Desc: Returns true if the item is set to target a specific location.
#*/
sq_register(vm, ItemHasTarget, "ItemHasTarget", _SC(".x"));
/*#
Func: ItemGetRotationOrder
Proto: RotationOrder:Item
Desc: Return the item rotation order.
#*/
sq_register(vm, ItemGetRotationOrder, "ItemGetRotationOrder", _SC(".x"));
/*#
Func: ItemSetRotationOrder
Proto: void:Item,RotationOrder
Desc: Set the item rotation order.
#*/
sq_register(vm, ItemSetRotationOrder, "ItemSetRotationOrder", _SC(".xi"));
/*#
Func: ItemGetRotationMatrix
Proto: Matrix3:Item
Desc: Return the 3x3 item rotation matrix.
#*/
sq_register(vm, ItemGetRotationMatrix, "ItemGetRotationMatrix", _SC(".x"));
/*#
Func: ItemSetRotationMatrix
Proto: void:Item,Matrix3 rotation
Desc: Set the 3x3 item rotation matrix.
#*/
sq_register(vm, ItemSetRotationMatrix, "ItemSetRotationMatrix", _SC(".xx"));
/*#
Func: ItemGetMatrix
Proto: Matrix4:Item
Desc: Return the 4x4 item transformation matrix in world space.
#*/
sq_register(vm, ItemGetMatrix, "ItemGetMatrix", _SC(".x"));
/*#
Func: ItemGetInverseMatrix
Proto: Matrix4:Item
Desc: Return the inverse 4x4 item transformation matrix.
#*/
sq_register(vm, ItemGetInverseMatrix, "ItemGetInverseMatrix", _SC(".x"));
/*#
Func: ItemGetLocalMatrix
Proto: Matrix4:Item
Desc: Return the 4x4 item transformation matrix in parent space.
#*/
sq_register(vm, ItemGetLocalMatrix, "ItemGetLocalMatrix", _SC(".x"));
/*#
Func: ItemSetMatrix
Proto: void:Item,Matrix4
Desc: Set the 4x4 item transformation matrix.
#*/
sq_register(vm, ItemSetMatrix, "ItemSetMatrix", _SC(".xx"));
/*#
Func: ItemRecordLocation
Proto: void:Item
Desc: Record item start location, item is set back to this location when reseted.
#*/
sq_register(vm, ItemRecordLocation, "ItemRecordLocation", _SC(".x"));
/*#
Func: ItemSnapshotTransformation
Proto: void:Item
Desc: Snapshot current item transformation matrix to the current orientation method.
#*/
sq_register(vm, ItemSnapshotTransformation, "ItemSnapshotTransformation", _SC(".x"));
/*#
Func: ItemSnapshotMatrix
Proto: void:Item,Matrix4
Desc: Snapshot matrix as item transformation.
#*/
sq_register(vm, ItemSnapshotMatrix, "ItemSnapshotMatrix", _SC(".xx"));
/*#
Func: ItemGetLocalMinMax
Proto: MinMax:Item
Desc: Return an item bounding box in local space.
#*/
sq_register(vm, ItemGetLocalMinMax, "ItemGetLocalMinMax", _SC(".x"));
/*#
Func: ItemGetWorldMinMax
Proto: MinMax:Item
Desc: Return an item bounding box in world space.
#*/
sq_register(vm, ItemGetWorldMinMax, "ItemGetWorldMinMax", _SC(".x"));
/*#
Section: ItemCast
Desc: Type cast
#*/
/*#
Func: ItemCastToObject
Proto: Object:Item
Desc: Cast item to object.
#*/
sq_register(vm, ItemCastToObject, "ItemCastToObject", _SC(".x"));
/*#
Func: ItemCastToCamera
Proto: Camera:Item
Desc: Cast item to camera.
#*/
sq_register(vm, ItemCastToCamera, "ItemCastToCamera", _SC(".x"));
/*#
Func: ItemCastToTrigger
Proto: Trigger:Item
Desc: Cast item to trigger.
#*/
sq_register(vm, ItemCastToTrigger, "ItemCastToTrigger", _SC(".x"));
/*#
Func: ItemCastToLight
Proto: Light:Item
Desc: Cast item to light.
Example:
local light = ItemCastToLight(item)
LightSetRange(light, Mtr(20))
#*/
sq_register(vm, ItemCastToLight, "ItemCastToLight", _SC(".x"));
/*#
Func: ItemCastToInstance
Proto: Instance:Item
Desc: Cast item to instance.
#*/
sq_register(vm, ItemCastToInstance, "ItemCastToInstance", _SC(".x"));
/*#
Func: ItemCastToEmitter
Proto: Emitter:Item
Desc: Cast item to emitter.
#*/
sq_register(vm, ItemCastToEmitter, "ItemCastToEmitter", _SC(".x"));
/*#
Func: ItemDerivedCastToItem
Proto: Item:ItemDerived
Desc: Cast an item derived object (camera, object, light, trigger) to an item.
#*/
sq_register(vm, ItemDerivedCastToItem, "ItemDerivedCastToItem", _SC(".x"));
/*#
Section: ItemState
Desc: State
#*/
/*#
Func: ItemIsInvisible
Proto: bool:Item
Desc: Return the visibility state of the item.
#*/
sq_register(vm, ItemIsInvisible, "ItemIsInvisible", _SC(".x"));
/*#
Func: ItemSetInvisible
Proto: void:Item,bool invisible
Desc: Set item display flag, item is still updated but not displayed anymore.
#*/
sq_register(vm, ItemSetInvisible, "ItemSetInvisible", _SC(".xb"));
/*#
Func: ItemHierarchySetInvisible
Proto: void:Item,bool
Desc: Set item and children display flag, item and children are still updated but not displayed anymore.
#*/
sq_register(vm, ItemHierarchySetInvisible, "ItemHierarchySetInvisible", _SC(".xb"));
/*#
Func: ItemIsActive
Proto: bool:Item
Desc: Return true if the given item is active, false otherwise.
#*/
sq_register(vm, ItemIsActive, "ItemIsActive", _SC(".x"));
/*#
Section: Item
Desc: General
#*/
/*#
Func: ItemReset
Proto: void:Item
Desc: Reset an item, effectively calling its OnReset script callbacks and resetting its physic state to the current item transformation.
#*/
sq_register(vm, ItemReset, "ItemReset", _SC(".x"));
/*#
Func: ItemRenderSetup
Proto: void:Item,ResourceFactory
Desc: Setup the resources required to render an item.
#*/
sq_register(vm, ItemRenderSetup, "ItemRenderSetup", _SC(".xx"));
/*#
Func: ItemSetup
Proto: void:Item
Desc: Setup an item.
Deprecated: SceneSetupItem
#*/
;
/*#
Func: ItemGetType
Proto: ItemType:Item
Desc: Return the item type (camera, light, object, trigger, etc...).
#*/
sq_register(vm, ItemGetType, "ItemGetType", _SC(".x"));
/*#
Func: ItemCompare
Proto: bool:Item,Item
Desc: Compare two items, returns true is both items are the same object.
#*/
sq_register(vm, ItemCompare, "ItemCompare", _SC(".xx"));
/*#
Func: ItemGetGeometry
Proto: Geometry:Item
Desc: Get item geometry, an item may have no geometry.
See: ObjectIsValid
#*/
sq_register(vm, ItemGetGeometry, "ItemGetGeometry", _SC(".x"));
/*#
Func: ItemSaveGeometry
Proto: void:Item, path
Desc:save the item geometry into the path.
#*/
sq_register(vm, ItemSaveGeometry, "ItemSaveGeometry", _SC(".xsx"));
/*#
Func: ItemSetPriority
Proto: void:Item,float priority
Desc: Set an item priority.
#*/
sq_register(vm, ItemSetPriority, "ItemSetPriority", _SC(".xn"));
/*#
Func: ItemGetChild
Proto: Item:Item,string name
Desc: Get an item child from its name.
Example: local hand = ItemGetChild(arm_item, "hand")
#*/
sq_register(vm, ItemGetChild, "ItemGetChild", _SC(".xs"));
/*#
Func: ItemGetName
Proto: string:Item
Desc: Get item name.
#*/
sq_register(vm, ItemGetName, "ItemGetName", _SC(".x"));
/*#
Func: ItemSetName
Proto: void:Item,string
Desc: Set item name.
#*/
sq_register(vm, ItemSetName, "ItemSetName", _SC(".xs"));
/*#
Func: ItemGetFlags
Proto: ItemFlag:Item
Desc: Get item flags.
#*/
sq_register(vm, ItemGetFlags, "ItemGetFlags", _SC(".x"));
/*#
Func: ItemSetFlags
Proto: void:Item,ItemFlag flag,bool set
Desc: Set or remove one or several item flags.
#*/
sq_register(vm, ItemSetFlags, "ItemSetFlags", _SC(".xib"));
/*#
Section: ItemSkin
Desc: Skinning
#*/
/*#
Func: ItemGetSkinBoneItemsGroup
Proto: Group:Item
Desc: Return the item skin bone items as an item group.
See: GroupGetRootItem, GroupGetItemList
#*/
sq_register(vm, ItemGetSkinBoneItemsGroup, "ItemGetSkinBoneItemsGroup", _SC(".x"));
/*#
Section: ItemPhysicState
Desc: Physic state
#*/
/*#
Func: ItemWake
Proto: void:Item
Desc: Wake a physic item, all collision and physic evaluation will resume.
#*/
sq_register(vm, ItemWake, "ItemWake", _SC(".x"));
/*#
Func: ItemSleep
Proto: void:Item
Desc: Put a physic item to sleep, all collision and physic evaluation will stop.
#*/
sq_register(vm, ItemSleep, "ItemSleep", _SC(".x"));
/*#
Func: ItemIsSleeping
Proto: bool:Item
Desc: Returns true if the item is sleeping, false otherwise.
#*/
sq_register(vm, ItemIsSleeping, "ItemIsSleeping", _SC(".x"));
/*#
Func: ItemPhysicGetFlag
Proto: PhysicFlag:Item
Desc: Get item physic flag.
#*/
sq_register(vm, ItemPhysicGetFlag, "ItemPhysicGetFlag", _SC(".x"));
/*#
Func: ItemPhysicSetFlag
Proto: void:Item,PhysicFlag
Desc: Set item physic flag.
#*/
sq_register(vm, ItemPhysicSetFlag, "ItemPhysicSetFlag", _SC(".xi"));
/*#
Section: ItemCharacterPhysic
Desc: Character Physic
#*/
/*#
Func: ItemPhysicCharacterSetRotationMatrix
Proto: void:Item,Matrix3 m
Desc: Set physics character rotation matrix.
#*/
sq_register(vm, ItemPhysicCharacterSetRotationMatrix, "ItemPhysicCharacterSetRotationMatrix", _SC(".xx"));
/*#
Func: ItemPhysicCharacterSetVelocity
Proto: void:Item,Vector V
Desc: Set physics character controller velocity.
#*/
sq_register(vm, ItemPhysicCharacterSetVelocity, "ItemPhysicCharacterSetVelocity", _SC(".xx"));
/*#
Section: ItemVehiclePhysic
Desc: Vehicle Physic
#*/
/*#
Func: ItemPhysicVehicleSetForce
Proto: void:Item,int wheel_index,float F
Desc: Set engine force F for a specific wheel in the vehicle model.
#*/
sq_register(vm, ItemPhysicVehicleSetForce, "ItemPhysicVehicleSetForce", _SC(".xin"));
/*#
Func: ItemPhysicVehicleSetBrake
Proto: void:Item,int wheel_index,float F
Desc: Set brake force F for a specific wheel in the vehicle model.
#*/
sq_register(vm, ItemPhysicVehicleSetBrake, "ItemPhysicVehicleSetBrake", _SC(".xin"));
/*#
Func: ItemPhysicVehicleSetSteering
Proto: void:Item,int wheel_index,float angle
Desc: Set steering on a specific wheel of the vehicle model.
#*/
sq_register(vm, ItemPhysicVehicleSetSteering, "ItemPhysicVehicleSetSteering", _SC(".xin"));
/*#
Func: ItemPhysicVehicleSetFriction
Proto: void:Item,int wheel_index,float friction_slip
Desc: Set friction on a specific wheel of the vehicle model.
#*/
sq_register(vm, ItemPhysicVehicleSetFriction, "ItemPhysicVehicleSetFriction", _SC(".xin"));
/*#
Func: ItemPhysicVehicleGetWheelMatrix
Proto: Matrix4:Item,int wheel_index
Desc: Get a specific wheel matrix from the vehicle model.
#*/
sq_register(vm, ItemPhysicVehicleGetWheelMatrix, "ItemPhysicVehicleGetWheelMatrix", _SC(".xi"));
/*#
Section: ItemPhysic
Desc: Physic
#*/
/*#
Func: ItemSetInertiaTensorAndCom
Proto: void:Item,Matrix3 tensor,Vector center_of_mass
Desc: Manually set the item inertia tensor and center of mass.
See: ItemUpdateInertiaTensorFromCollision
#*/
sq_register(vm, ItemSetInertiaTensorAndCom, "ItemSetInertiaTensorAndCom", _SC(".xxx"));
/*#
Func: ItemUpdateInertiaTensorFromCollision
Proto: void:Item
Desc: Compute item inertia tensor and center of mass from the associated collision shape description.
#*/
sq_register(vm, ItemUpdateInertiaTensorFromCollision, "ItemUpdateInertiaTensorFromCollision", _SC(".x"));
/*#
Func: ItemGetSpeed
Proto: float:Item
Desc: Get item center of mass speed (in m.s).
Note: This is the equivalent of ItemGetLinearVelocity(item).Len()
See: ItemPointVelocity, ItemWorldPointVelocity
#*/
sq_register(vm, ItemGetSpeed, "ItemGetSpeed", _SC(".x"));
/*#
Func: ItemApplyLinearForce
Proto: void:Item,Vector force
Desc: Apply a force to the item center of mass. Rotation is not affected.
#*/
sq_register(vm, ItemApplyLinearForce, "ItemApplyLinearForce", _SC(".xx"));
/*#
Func: ItemApplyForce
Proto: void:Item,Vector position,Vector force
Desc: Apply a force at a specific position in world space to the item.
Example:
// Apply thrust to a ship item, the reactor item is parented to the ship item.
local reactor_matrix = ItemGetMatrix(reactor_item)
// Get the reactor position and the vector pointing toward its back (and the back of the ship).
local reactor_world_position = reactor_matrix.GetPosition()
local reactor_back_vector = reactor_matrix.GetBack()
// Apply thrust to the ship at the position of the reactor and in the correct direction.
local thrust_strength = 10.0 // the thrust strength
ItemApplyForce(ship_item, reactor_world_position, reactor_back_vector * thrust_strength)
#*/
sq_register(vm, ItemApplyForce, "ItemApplyForce", _SC(".xxx"));
/*#
Func: ItemApplyLinearImpulse
Proto: void:Item,Vector impulse
Desc: Apply an impulse to the item center of mass. Rotation is not affected. An impulse is an immediate change of velocity. It is expressed as the difference between the target velocity and the current velocity.
See: ItemApplyImpulse
Example:
// Retrieve the current item linear velocity.
local current_v = ItemGetLinearVelocity(item)
// Compute the impulse to force the item velocity to {1, 0, 0}.
local J = Vector(1, 0, 0) - current_v
// Force the item linear velocity to {1, 0, 0}
ItemApplyImpulse(item, J)
#*/
sq_register(vm, ItemApplyLinearImpulse, "ItemApplyLinearImpulse", _SC(".xx"));
/*#
Func: ItemApplyImpulse
Proto: void:Item,Vector position,Vector impulse
Desc: Apply an impulse at a specific position in world space to the item.
See: ItemApplyLinearImpulse
#*/
sq_register(vm, ItemApplyImpulse, "ItemApplyImpulse", _SC(".xxx"));
/*#
Func: ItemApplyTorque
Proto: void:Item,Vector torque
Desc: Apply a torque to the item. The torque is the rotational equivalent of the force. It will increase the body angular velocity which will in turn rotate it.
#*/
sq_register(vm, ItemApplyTorque, "ItemApplyTorque", _SC(".xx"));
/*#
Func: ItemPhysicSetLinearFactor
Proto: void:Item,Vector factor
Desc: Set the scale factor for all forces applied to this item linear velocity. All forces applied directly and indirectly to this item will be scaled by this factor.
Example:
// Restrict all motions to the XY plane by canceling out all forces Z component.
ItemPhysicSetLinearFactor(item, Vector(1, 1, 0))
#*/
sq_register(vm, ItemPhysicSetLinearFactor, "ItemPhysicSetLinearFactor", _SC(".xx"));
/*#
Func: ItemPhysicSetAngularFactor
Proto: void:Item,Vector factor
Desc: Set the scale factor for all forces applied to this item angular velocity. All torques applied directly and indirectly to this item will be scaled by this factor.
Example:
// Restrict all rotations to the Z axis by canceling out all torques on the X and Y axises.
ItemPhysicSetangularFactor(item, Vector(0, 0, 1))
#*/
sq_register(vm, ItemPhysicSetAngularFactor, "ItemPhysicSetAngularFactor", _SC(".xx"));
/*#
Func: ItemPhysicResetTransformation
Proto: void:Item,Vector position,Vector euler
Desc: Reset item physic transformation to specific location (in item local space).
#*/
sq_register(vm, ItemPhysicResetTransformation, "ItemPhysicResetTransformation", _SC(".xxx"));
/*#
Func: ItemGetLinearDamping
Proto: float:Item
Desc: Get item linear damping.
#*/
sq_register(vm, ItemGetLinearDamping, "ItemGetLinearDamping", _SC(".x"));
/*#
Func: ItemSetLinearDamping
Proto: void:Item,float damping
Desc: Set item linear damping by which the item linear velocity is scaled after each solver iteration.
A damping value of 1 will not affect velocity, a damping of 0 will completely cancel velocity and a damping of 0.5 will make the object appear as if moving through a thick invisible material.
Note: A small amount of damping (0.99) can help the solver as it prevents sudden change and oscillation in velocity.
Too much damping can prevent the solver from reaching a stable configuration.
#*/
sq_register(vm, ItemSetLinearDamping, "ItemSetLinearDamping", _SC(".xn"));
/*#
Func: ItemGetAngularDamping
Proto: float:Item
Desc: Get item angular damping.
#*/
sq_register(vm, ItemGetAngularDamping, "ItemGetAngularDamping", _SC(".x"));
/*#
Func: ItemSetAngularDamping
Proto: void:Item,float damping
Desc: Set item angular damping. This is the rotational equivalent of the linear damping.
See: ItemSetLinearDamping
#*/
sq_register(vm, ItemSetAngularDamping, "ItemSetAngularDamping", _SC(".xn"));
/*#
Func: ItemGetAngularVelocity
Proto: Vector:Item
Desc: Get item angular velocity (rad.s). The angular velocity is the rate of change in rotation over time.
Note: The angular velocity only affects rotation, position is affected by the linear velocity.
See: ItemGetLinearVelocity
#*/
sq_register(vm, ItemGetAngularVelocity, "ItemGetAngularVelocity", _SC(".x"));
/*#
Func: ItemSetAngularVelocity
Proto: void:Item,Vector angular_velocity
Desc: Set item angular velocity (rad.s).
Note: This function sets the item angular velocity by bypassing the physics solver. This can lead to all sorts of problems depending on the scene configuration. You are advised to perform such change using an impulse instead.
See: ItemApplyAngularImpulse
#*/
sq_register(vm, ItemSetAngularVelocity, "ItemSetAngularVelocity", _SC(".xx"));
/*#
Func: ItemGetPhysicMode
Proto: PhysicMode:Item
Desc: Get the current item physic mode.
#*/
sq_register(vm, ItemGetPhysicMode, "ItemGetPhysicMode", _SC(".x"));
/*#
Func: ItemSetPhysicMode
Proto: void:Item,PhysicMode mode
Desc: Set item physic mode.
#*/
sq_register(vm, ItemSetPhysicMode, "ItemSetPhysicMode", _SC(".xi"));
/*#
Func: ItemCollided
Proto: bool:Item
Desc: Returns true if the item collided during the last physic step, false otherwise.
#*/
sq_register(vm, ItemCollided, "ItemCollided", _SC(".x"));
/*#
Func: ItemGetLinearAcceleration
Proto: Vector:Item
Desc: Get item linear acceleration (m.s²). Acceleration is the rate of change in speed over time.
#*/
sq_register(vm, ItemGetLinearAcceleration, "ItemGetLinearAcceleration", _SC(".x"));
/*#
Func: ItemGetMass
Proto: float:Item
Desc: Get item mass (in Kg).
#*/
sq_register(vm, ItemGetMass, "ItemGetMass", _SC(".x"));
/*#
Func: ItemGetCenterOfMass
Proto: Vector:Item
Desc: Get item center of mass position in item space.
#*/
sq_register(vm, ItemGetCenterOfMass, "ItemGetCenterOfMass", _SC(".x"));
/*#
Func: ItemGetLocalPointVelocity
Proto: Vector:Item
Desc: Get an item local point velocity (m.s) in world space.
#*/
sq_register(vm, ItemGetLocalPointVelocity, "ItemGetLocalPointVelocity", _SC(".x"));
/*#
Func: ItemGetWorldPointVelocity
Proto: Vector:Item
Desc: Get an item world point velocity (m.s) in world space.
#*/
sq_register(vm, ItemGetWorldPointVelocity, "ItemGetWorldPointVelocity", _SC(".x"));
/*#
Func: ItemGetLinearVelocity
Proto: Vector:Item
Desc: Get the item linear velocity (m.s). Velocity is the rate of change of position over time.
Note: The linear velocity only affects position, rotation is affected by the angular velocity.
See: ItemGetLinearAcceleration, ItemGetAngularVelocity
#*/
sq_register(vm, ItemGetLinearVelocity, "ItemGetLinearVelocity", _SC(".x"));
/*#
Func: ItemGetPreviousLinearVelocity
Proto: Vector:Item
Desc: Get item previous linear velocity (m.s).
#*/
sq_register(vm, ItemGetPreviousLinearVelocity, "ItemGetPreviousLinearVelocity", _SC(".x"));
/*#
Func: ItemSetLinearVelocity
Proto: void:Item,Vector linear_velocity
Desc: Set item linear velocity (m.s).
Note: This function sets the item linear velocity by bypassing the physics solver. This can lead to all sorts of problems depending on the scene configuration. You are advised to perform such change using an impulse instead.
See: ItemApplyLinearImpulse
#*/
sq_register(vm, ItemSetLinearVelocity, "ItemSetLinearVelocity", _SC(".xx"));
/*#
Func: ItemSetGravityScale
Proto: void:Item,float scale
Desc: Set item gravity scale (g = world_gravity * scale).
#*/
sq_register(vm, ItemSetGravityScale, "ItemSetGravityScale", _SC(".xn"));
/*#
Func: ItemSetGravity
Proto: void:Item,Vector g
Desc: Set item gravity (in m.s²).
Example: ItemSetGravity(item, Vector(0.0, -9.8, 0.0)) // Earth gravity.
#*/
sq_register(vm, ItemSetGravity, "ItemSetGravity", _SC(".xx"));
/*#
Func: ItemGetGravity
Proto: Vector:Item
Desc: Get item gravity (m.s²).
#*/
sq_register(vm, ItemGetGravity, "ItemGetGravity", _SC(".x"));
/*#
Func: ItemWorldPointVelocity
Proto: void:Item,Vector world_position
Desc: Compute the velocity of an item particle, particle position is in world space (in m.s).
#*/
sq_register(vm, ItemWorldPointVelocity, "ItemWorldPointVelocity", _SC(".xx"));
/*#
Func: ItemPointVelocity
Proto: void:Item,Vector local_position
Desc: Compute the velocity of an item particle, particle position is in item space (in m.s).
#*/
sq_register(vm, ItemPointVelocity, "ItemPointVelocity", _SC(".xx"));
/*#
Section: ItemPhysicHack
Desc: Physic hacking
#*/
/*#
Func: ItemGetPhysicPosition
Proto: Vector:Item
Desc: Get item physic position.
#*/
sq_register(vm, ItemGetPhysicPosition, "ItemGetPhysicPosition", _SC(".x"));
/*#
Func: ItemSetPhysicPosition
Proto: void:Item,Vector position
Desc: Set item physic position.
Note: Tampering with the internal physic state is likely to cause troubles, use with extreme care!
#*/
sq_register(vm, ItemSetPhysicPosition, "ItemSetPhysicPosition", _SC(".xx"));
/*#
Func: ItemGetPhysicPreviousPosition
Proto: Vector:Item
Desc: Get item physic previous position.
#*/
sq_register(vm, ItemGetPhysicPreviousPosition, "ItemGetPhysicPreviousPosition", _SC(".x"));
/*#
Func: ItemGetPhysicRotation
Proto: Vector:Item
Desc: Get item physic rotation.
#*/
sq_register(vm, ItemGetPhysicRotation, "ItemGetPhysicRotation", _SC(".x"));
/*#
Func: ItemSetPhysicRotation
Proto: void:Item,Vector euler
Desc: Set item physic rotation.
Note: Tampering with the internal physic state is likely to cause troubles, use with extreme care!
#*/
sq_register(vm, ItemSetPhysicRotation, "ItemSetPhysicRotation", _SC(".xx"));
/*#
Func: ItemPhysicSynchronizeCollision
Proto: void:Item
Desc: Synchronize the collision interface to the physic interface.
#*/
sq_register(vm, ItemPhysicSynchronizeCollision, "ItemPhysicSynchronizeCollision", _SC(".x"));
/*#
Section: ItemScript
Desc: Script
#*/
/*#
Func: ItemSetScript
Proto: void:Item,String file,String class
Desc: Set item script file and class to instantiate for the item first script unit.
#*/
sq_register(vm, ItemSetScript, "ItemSetScript", _SC(".xss"));
/*#
Func: ItemSetupScript
Proto: void:Item
Desc: Setup item script.
#*/
sq_register(vm, ItemSetupScript, "ItemSetupScript", _SC(".x"));
/*#
Func: ItemGetScriptInstance
Proto: instance:Item
Desc: Get an item script instance on its first script unit.
See: ItemGetScriptInstanceFromClass
Example:
local enemy_item = SceneFindItem(g_scene, "an_enemy")
local enemy = ItemGetScriptInstance(enemy_item)
// Instance can be used to call the script assigned to the item.
enemy->TakeHit(20)
#*/
sq_register(vm, ItemGetScriptInstance, "ItemGetScriptInstance", _SC(".x"));
/*#
Func: ItemGetScriptInstanceCount
Proto: int:Item
Desc: Get the number of script instance available on an item.
#*/
sq_register(vm, ItemGetScriptInstanceCount, "ItemGetScriptInstanceCount", _SC(".x"));
/*#
Func: ItemGetScriptInstanceFromIndex
Proto: instance:Item,int index
Desc: Get an item script instance from its index.
See: ItemGetScriptInstanceFromClass
#*/
sq_register(vm, ItemGetScriptInstanceFromIndex, "ItemGetScriptInstanceFromIndex", _SC(".xi"));
/*#
Func: ItemGetScriptInstanceFromClass
Proto: instance:Item,string class_name
Desc: Get an item script instance from the name of the class it instantiates.
Example:
local enemy_item = SceneFindItem(g_scene, "an_enemy")
local ai = ItemGetScriptInstanceFromClass(item, "AIComponent")
// Instance can be used to call the AIComponent instance assigned to the enemy item.
ai->Flee()
#*/
sq_register(vm, ItemGetScriptInstanceFromClass, "ItemGetScriptInstanceFromClass", _SC(".xs"));
#if 1
sq_register(vm, ItemSetPhysicPreviousPosition, "ItemSetPhysicPreviousPosition", _SC(".xx"));
#endif
/*#
Func: ItemHasScript
Proto: bool:Item,string class_name
Desc: Test if a specific script is assigned to an item. The script is identified by its class name.
Example:
// Will return true if this script is instantiated for this item.
local has_some_component = ItemHasScript(item, "AComponentClass")
#*/
sq_register(vm, ItemHasScript, "ItemHasScript", _SC(".xs"));
/*#
Section: ItemDebug
Desc: Debug
#*/
/*#
Func: ItemPrint
Proto: void:Item
Desc: Print item instance address in memory.
#*/
sq_register(vm, ItemPrint, "ItemPrint", _SC(".x"));
/*#
Enum: PhysicMode
Values: PhysicModeNone,PhysicModeStatic,PhysicModeDynamic,PhysicModeKinematic
#*/
sq_pushstring(vm, "PhysicModeNone", -1); sq_pushinteger(vm, PhysicItemDesc::Mode_None); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicModeStatic", -1); sq_pushinteger(vm, PhysicItemDesc::Mode_Static); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicModeDynamic", -1); sq_pushinteger(vm, PhysicItemDesc::Mode_Dynamic); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicModeKinematic", -1); sq_pushinteger(vm, PhysicItemDesc::Mode_Kinematic); sq_newslot(vm, -3, true);
#if 1
sq_pushstring(vm, "PhysicModeRigidBody", -1); sq_pushinteger(vm, PhysicItemDesc::Mode_Dynamic); sq_newslot(vm, -3, true);
sq_pushstring(vm, "OrientationEuler", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "OrientationMatrix", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "OrientationQuaternion", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "OrientationExternal", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
#endif
/*#
Enum: PhysicFlag
Values: PhysicFlagNone,PhysicFlagNoGravity,PhysicFlagNoForceField,PhysicFlagMobile,PhysicFlagGhost
#*/
sq_pushstring(vm, "PhysicFlagNone", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicFlagNoGravity", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicFlagNoForceField", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicFlagMobile", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
sq_pushstring(vm, "PhysicFlagGhost", -1); sq_pushinteger(vm, 0); sq_newslot(vm, -3, true);
/*#
Enum: RotationOrder
Values: RotationOrderDefault,RotationOrderZYX,RotationOrderYZX,RotationOrderZXY,RotationOrderXZY,RotationOrderYXZ,RotationOrderXYZ,RotationOrderXY
#*/
sq_pushstring(vm, "RotationOrderDefault", -1); sq_pushinteger(vm, Math::rOrder_Default); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderZYX", -1); sq_pushinteger(vm, Math::rOrder_ZYX); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderYZX", -1); sq_pushinteger(vm, Math::rOrder_YZX); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderZXY", -1); sq_pushinteger(vm, Math::rOrder_ZXY); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderXZY", -1); sq_pushinteger(vm, Math::rOrder_XZY); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderYXZ", -1); sq_pushinteger(vm, Math::rOrder_YXZ); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderXYZ", -1); sq_pushinteger(vm, Math::rOrder_XYZ); sq_newslot(vm, -3, true);
sq_pushstring(vm, "RotationOrderXY", -1); sq_pushinteger(vm, Math::rOrder_XY); sq_newslot(vm, -3, true);
/*#
Enum: ItemType
Values: ItemTypeNone,ItemTypeCamera,ItemTypeObject,ItemTypeLight,ItemTypeTrigger,ItemTypeEmitter,ItemTypeInstance
#*/
sq_pushstring(vm, "ItemTypeNone", -1); sq_pushinteger(vm, Type_None); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemTypeCamera", -1); sq_pushinteger(vm, Type_Camera); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemTypeObject", -1); sq_pushinteger(vm, Type_Object); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemTypeLight", -1); sq_pushinteger(vm, Type_Light); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemTypeTrigger", -1); sq_pushinteger(vm, Type_Trigger); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemTypeEmitter", -1); sq_pushinteger(vm, Type_Emitter); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemTypeInstance", -1); sq_pushinteger(vm, Type_Instance); sq_newslot(vm, -3, true);
/*#
Enum: ItemFlag
Values: ItemFlagNone,ItemFlagBillboard,ItemFlagSolveOverlap
#*/
sq_pushstring(vm, "ItemFlagNone", -1); sq_pushinteger(vm, MItem::Flag_None); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemFlagBillboard", -1); sq_pushinteger(vm, MItem::Flag_Billboard); sq_newslot(vm, -3, true);
sq_pushstring(vm, "ItemFlagSolveOverlap", -1); sq_pushinteger(vm, MItem::Flag_SolveOverlap); sq_newslot(vm, -3, true);
sq_pushstring(vm, "NullGeometry", -1); CObject::Push(vm, NULL, typetag_Geometry); sq_newslot(vm, -3, true);
}
//------------------------------------------------------------------------------