Beispiel #1
0
static int vector_DotOperator(lua_State * L)
{
	vec_t          *a, *b;

	a = lua_getvector(L, 1);
	b = lua_getvector(L, 2);

	lua_pushnumber(L, DotProduct(a, b));

	return 1;
}
Beispiel #2
0
static int vector_Add(lua_State * L)
{
	vec_t          *a, *b, *c;

	a = lua_getvector(L, 1);
	b = lua_getvector(L, 2);
	c = lua_getvector(L, 3);

	VectorAdd(a, b, c);

	return 1;
}
Beispiel #3
0
static int vector_Scale(lua_State * L)
{
	vec_t          *a, b, *c;

	a = lua_getvector(L, 1);
	b = luaL_checknumber(L, 2);
	c = lua_getvector(L, 3);

	VectorScale(a, b, c);

	return 1;
}
Beispiel #4
0
static int vector_Subtract(lua_State * L)
{
	vec_t          *a, *b, *c;

	a = lua_getvector(L, 1);
	b = lua_getvector(L, 2);
	c = lua_getvector(L, 3);

	VectorSubtract(a, b, c);

	return 1;
}
Beispiel #5
0
static int vector_Perpendicular(lua_State * L)
{
	vec_t          *dst;
	vec_t          *src;

	dst = lua_getvector(L, 1);
	src = lua_getvector(L, 2);

	PerpendicularVector(dst, src);

	return 1;
}
Beispiel #6
0
static int vector_SubOperator(lua_State * L)
{
	vec_t          *a, *b;
	vec3_t          c;

	a = lua_getvector(L, 1);
	b = lua_getvector(L, 2);

	VectorSubtract(a, b, c);

	lua_pushvector(L, c);

	return 1;
}
Beispiel #7
0
static int vector_RotatePointAround(lua_State * L)
{
	vec_t          *dst;
	vec_t          *dir;
	vec_t          *point;
	vec_t           degrees;

	dst = lua_getvector(L, 1);
	dir = lua_getvector(L, 2);
	point = lua_getvector(L, 3);
	degrees = luaL_checknumber(L, 4);

	RotatePointAroundVector(dst, dir, point, degrees);

	return 1;
}
Beispiel #8
0
static int vector_ToString(lua_State * L)
{
	vec_t          *vec;

	vec = lua_getvector(L, 1);
	lua_pushstring(L, va("(%i %i %i)", (int)vec[0], (int)vec[1], (int)vec[2]));

	return 1;
}
Beispiel #9
0
static int vector_NormalizeFast(lua_State * L)
{
	vec_t          *a;

	a = lua_getvector(L, 1);

	VectorNormalizeFast(a);

	return 1;
}
Beispiel #10
0
static int vector_Clear(lua_State * L)
{
	vec_t          *a;

	a = lua_getvector(L, 1);

	VectorClear(a);

	return 1;
}
Beispiel #11
0
static int vector_Set(lua_State * L)
{
	vec_t          *v;

	v = lua_getvector(L, 1);

	v[0] = luaL_optnumber(L, 2, 0);
	v[1] = luaL_optnumber(L, 3, 0);
	v[2] = luaL_optnumber(L, 4, 0);

	return 1;
}
Beispiel #12
0
static int vector_Normalize(lua_State * L)
{
	vec_t          *a;
	vec_t           len;

	a = lua_getvector(L, 1);

	len = VectorNormalize(a);
	lua_pushnumber(L, len);

	return 1;
}
Beispiel #13
0
static int vector_Length(lua_State * L)
{
	vec_t          *a;
	vec_t           len;

	a = lua_getvector(L, 1);

	len = VectorLength(a);
	lua_pushnumber(L, len);

	return 1;
}
Beispiel #14
0
static int vector_NegateOperator(lua_State * L)
{
	vec_t          *a;
	vec3_t          b;

	a = lua_getvector(L, 1);

	VectorNegate(a, b);

	lua_pushvector(L, b);

	return 1;
}
Beispiel #15
0
static int entity_Rotate(lua_State * L)
{
	lua_Entity     *lent;
	vec_t          *vec;

	lent = lua_getentity(L, 1);
	vec = lua_getvector(L, 2);
	
	lent->e->s.apos.trType = TR_LINEAR;
	lent->e->s.apos.trDelta[0] = vec[0];
	lent->e->s.apos.trDelta[1] = vec[1];
	lent->e->s.apos.trDelta[2] = vec[2];

	return 1;
}
Beispiel #16
0
// *INDENT-OFF*
static int vector_Index(lua_State * L)
{
	vec_t          *v;
	const char     *i;
	
	v = lua_getvector(L, 1);
	i = luaL_checkstring(L, 2);
	
	switch (*i)
	{
		case '0': case 'x': case 'r': lua_pushnumber(L, v[0]); break;
		case '1': case 'y': case 'g': lua_pushnumber(L, v[1]); break;
		case '2': case 'z': case 'b': lua_pushnumber(L, v[2]); break;
		default: lua_pushnil(L); break;
		//default: lua_pushvector(L, v); break;
	}
	
	return 1;
}
Beispiel #17
0
static int vector_NewIndex(lua_State * L)
{
	vec_t          *v;
	const char     *i;
	vec_t           t;
	
	v = lua_getvector(L, 1);
	i = luaL_checkstring(L, 2);
	t = luaL_checknumber(L, 3);
	
	switch (*i)
	{
		case '0': case 'x': case 'r': v[0] = t; break;
		case '1': case 'y': case 'g': v[1] = t; break;
		case '2': case 'z': case 'b': v[2] = t; break;
		default: break;
	}
	
	return 1;
}