Пример #1
0
static duk_ret_t Terrain_GetTerrainHeightRange_float_float(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    float minHeight = (float)duk_require_number(ctx, 0);
    float maxHeight = (float)duk_require_number(ctx, 1);
    thisObj->GetTerrainHeightRange(minHeight, maxHeight);
    return 0;
}
Пример #2
0
static duk_ret_t Line_ProjectToAxis_float3_float_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    float3& direction = *GetCheckedValueObject<float3>(ctx, 0, float3_ID);
    float outMin = (float)duk_require_number(ctx, 1);
    float outMax = (float)duk_require_number(ctx, 2);
    thisObj->ProjectToAxis(direction, outMin, outMax);
    return 0;
}
Пример #3
0
static duk_ret_t Terrain_PatchExists_uint_uint(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint patchX = (uint)duk_require_number(ctx, 0);
    uint patchY = (uint)duk_require_number(ctx, 1);
    bool ret = thisObj->PatchExists(patchX, patchY);
    duk_push_boolean(ctx, ret);
    return 1;
}
Пример #4
0
static duk_ret_t Terrain_GetPoint_uint_uint(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint x = (uint)duk_require_number(ctx, 0);
    uint y = (uint)duk_require_number(ctx, 1);
    float ret = thisObj->GetPoint(x, y);
    duk_push_number(ctx, ret);
    return 1;
}
Пример #5
0
static duk_ret_t Terrain_SetPointHeight_uint_uint_float(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint x = (uint)duk_require_number(ctx, 0);
    uint y = (uint)duk_require_number(ctx, 1);
    float height = (float)duk_require_number(ctx, 2);
    thisObj->SetPointHeight(x, y, height);
    return 0;
}
Пример #6
0
static duk_ret_t Terrain_MakePatchFlat_uint_uint_float(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint patchX = (uint)duk_require_number(ctx, 0);
    uint patchY = (uint)duk_require_number(ctx, 1);
    float heightValue = (float)duk_require_number(ctx, 2);
    thisObj->MakePatchFlat(patchX, patchY, heightValue);
    return 0;
}
Пример #7
0
static duk_ret_t Line_ToLineSegment_float_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    float dStart = (float)duk_require_number(ctx, 0);
    float dEnd = (float)duk_require_number(ctx, 1);
    LineSegment ret = thisObj->ToLineSegment(dStart, dEnd);
    PushValueObjectCopy<LineSegment>(ctx, ret, LineSegment_ID, LineSegment_Finalizer);
    return 1;
}
Пример #8
0
static duk_ret_t Line_Distance_LineSegment_float_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    LineSegment& other = *GetCheckedValueObject<LineSegment>(ctx, 0, LineSegment_ID);
    float d = (float)duk_require_number(ctx, 1);
    float d2 = (float)duk_require_number(ctx, 2);
    float ret = thisObj->Distance(other, d, d2);
    duk_push_number(ctx, ret);
    return 1;
}
Пример #9
0
static duk_ret_t Line_ClosestPoint_LineSegment_float_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    LineSegment& other = *GetCheckedValueObject<LineSegment>(ctx, 0, LineSegment_ID);
    float d = (float)duk_require_number(ctx, 1);
    float d2 = (float)duk_require_number(ctx, 2);
    float3 ret = thisObj->ClosestPoint(other, d, d2);
    PushValueObjectCopy<float3>(ctx, ret, float3_ID, float3_Finalizer);
    return 1;
}
Пример #10
0
static duk_ret_t Terrain_LoadFromImageFile_String_float_float(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    String filename = duk_require_string(ctx, 0);
    float offset = (float)duk_require_number(ctx, 1);
    float scale = (float)duk_require_number(ctx, 2);
    bool ret = thisObj->LoadFromImageFile(filename, offset, scale);
    duk_push_boolean(ctx, ret);
    return 1;
}
Пример #11
0
static duk_ret_t Line_Intersects_OBB_float_float(duk_context* ctx)
{
    Line* thisObj = GetThisValueObject<Line>(ctx, Line_ID);
    OBB& obb = *GetCheckedValueObject<OBB>(ctx, 0, OBB_ID);
    float dNear = (float)duk_require_number(ctx, 1);
    float dFar = (float)duk_require_number(ctx, 2);
    bool ret = thisObj->Intersects(obb, dNear, dFar);
    duk_push_boolean(ctx, ret);
    return 1;
}
Пример #12
0
static duk_ret_t Line_ClosestPointLineLine_Static_float3_float3_float3_float3_float_float(duk_context* ctx)
{
    float3& start0 = *GetCheckedValueObject<float3>(ctx, 0, float3_ID);
    float3& dir0 = *GetCheckedValueObject<float3>(ctx, 1, float3_ID);
    float3& start1 = *GetCheckedValueObject<float3>(ctx, 2, float3_ID);
    float3& dir1 = *GetCheckedValueObject<float3>(ctx, 3, float3_ID);
    float d = (float)duk_require_number(ctx, 4);
    float d2 = (float)duk_require_number(ctx, 5);
    Line::ClosestPointLineLine(start0, dir0, start1, dir1, d, d2);
    return 0;
}
Пример #13
0
static duk_ret_t Terrain_Resize_uint_uint_uint_uint(duk_context* ctx)
{
    int numArgs = duk_get_top(ctx);
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    uint newWidth = (uint)duk_require_number(ctx, 0);
    uint newHeight = (uint)duk_require_number(ctx, 1);
    uint oldPatchStartX = numArgs > 2 ? (uint)duk_require_number(ctx, 2) : 0;
    uint oldPatchStartY = numArgs > 3 ? (uint)duk_require_number(ctx, 3) : 0;
    thisObj->Resize(newWidth, newHeight, oldPatchStartX, oldPatchStartY);
    return 0;
}
Пример #14
0
static duk_ret_t SignalWrapper_RigidBody_NewPhysicsCollision_Emit(duk_context* ctx)
{
    SignalWrapper_RigidBody_NewPhysicsCollision* wrapper = GetThisValueObject<SignalWrapper_RigidBody_NewPhysicsCollision>(ctx, SignalWrapper_RigidBody_NewPhysicsCollision_ID);
    if (!wrapper->owner_) return 0;
    Entity* param0 = GetWeakObject<Entity>(ctx, 0);
    float3& param1 = *GetCheckedValueObject<float3>(ctx, 1, float3_ID);
    float3& param2 = *GetCheckedValueObject<float3>(ctx, 2, float3_ID);
    float param3 = (float)duk_require_number(ctx, 3);
    float param4 = (float)duk_require_number(ctx, 4);
    wrapper->signal_->Emit(param0, param1, param2, param3, param4);
    return 0;
}
Пример #15
0
int js_getentint(duk_context* c) {
	int index = duk_require_number(c,-1);
	int offset = duk_require_number(c,-2);
	ENTITY* ent = game->getEntity(index);
	if(ent) {
		int value;
		ent->get(offset, &value, sizeof(value));
		duk_push_int(c,value);
	} else {
		duk_push_int(c,0);
	}
	return 1;
}
static duk_ret_t PhysicsWorld_Raycast_float3_float3_float_int_int(duk_context* ctx)
{
    int numArgs = duk_get_top(ctx);
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    float3& origin = *GetCheckedValueObject<float3>(ctx, 0, float3_ID);
    float3& direction = *GetCheckedValueObject<float3>(ctx, 1, float3_ID);
    float maxDistance = (float)duk_require_number(ctx, 2);
    int collisionGroup = numArgs > 3 ? (int)duk_require_number(ctx, 3) : -1;
    int collisionMask = numArgs > 4 ? (int)duk_require_number(ctx, 4) : -1;
    PhysicsRaycastResult ret = thisObj->Raycast(origin, direction, maxDistance, collisionGroup, collisionMask);
    PushValueObjectCopy<PhysicsRaycastResult>(ctx, ret, PhysicsRaycastResult_ID, PhysicsRaycastResult_Finalizer);
    return 1;
}
static duk_ret_t SignalWrapper_PhysicsWorld_PhysicsCollision_Emit(duk_context* ctx)
{
    SignalWrapper_PhysicsWorld_PhysicsCollision* wrapper = GetThisValueObject<SignalWrapper_PhysicsWorld_PhysicsCollision>(ctx, SignalWrapper_PhysicsWorld_PhysicsCollision_ID);
    if (!wrapper->owner_) return 0;
    Entity* param0 = GetWeakObject<Entity>(ctx, 0);
    Entity* param1 = GetWeakObject<Entity>(ctx, 1);
    float3& param2 = *GetCheckedValueObject<float3>(ctx, 2, float3_ID);
    float3& param3 = *GetCheckedValueObject<float3>(ctx, 3, float3_ID);
    float param4 = (float)duk_require_number(ctx, 4);
    float param5 = (float)duk_require_number(ctx, 5);
    bool param6 = duk_require_boolean(ctx, 6);
    wrapper->signal_->Emit(param0, param1, param2, param3, param4, param5, param6);
    return 0;
}
static duk_ret_t PhysicsWorld_SetMaxSubSteps_int(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    int steps = (int)duk_require_number(ctx, 0);
    thisObj->SetMaxSubSteps(steps);
    return 0;
}
Пример #19
0
/**
 * fd, buffer, offset, length, position
 */
static int
es_file_write(duk_context *ctx)
{
  es_fd_t *efd = es_fd_get(ctx, 0);
  duk_size_t bufsize;
  char *buf = duk_to_buffer(ctx, 1, &bufsize);
  int len;

  const int offset = duk_to_int(ctx, 2);
  if(duk_is_null(ctx, 3)) {
    len = bufsize;
  } else {
    len = duk_to_int(ctx, 3);
  }

  // Don't read past buffer end
  if(offset + len > bufsize)
    len = bufsize - offset;

  if(!duk_is_null(ctx, 4)) {
    // Seek
    fa_seek(efd->efd_fh, duk_require_number(ctx, 4), SEEK_SET);
  }

  int r = fa_write(efd->efd_fh, buf + offset, len);
  if(r < 0)
    duk_error(ctx, DUK_ERR_ERROR, "Write error to '%s'", efd->efd_path);

  duk_push_int(ctx, r);
  return 1;
}
Пример #20
0
static duk_ret_t
js_Font_drawZoomedText(duk_context* ctx)
{
	int x = duk_require_int(ctx, 0);
	int y = duk_require_int(ctx, 1);
	float scale = duk_require_number(ctx, 2);
	const char* text = duk_to_string(ctx, 3);
	
	ALLEGRO_BITMAP* bitmap;
	font_t*         font;
	color_t         mask;
	int             text_w, text_h;

	duk_push_this(ctx);
	font = duk_require_sphere_obj(ctx, -1, "Font");
	duk_get_prop_string(ctx, -1, "\xFF" "color_mask"); mask = duk_require_sphere_color(ctx, -1); duk_pop(ctx);
	duk_pop(ctx);
	if (!screen_is_skipframe(g_screen)) {
		text_w = get_text_width(font, text);
		text_h = get_font_line_height(font);
		bitmap = al_create_bitmap(text_w, text_h);
		al_set_target_bitmap(bitmap);
		draw_text(font, mask, 0, 0, TEXT_ALIGN_LEFT, text);
		al_set_target_backbuffer(screen_display(g_screen));
		al_draw_scaled_bitmap(bitmap, 0, 0, text_w, text_h, x, y, text_w * scale, text_h * scale, 0x0);
		al_destroy_bitmap(bitmap);
	}
	return 0;
}
static duk_ret_t EntityReference_Ctor_entity_id_t(duk_context* ctx)
{
    entity_id_t id = (entity_id_t)duk_require_number(ctx, 0);
    EntityReference* newObj = new EntityReference(id);
    PushConstructorResult<EntityReference>(ctx, newObj, EntityReference_ID, EntityReference_Finalizer);
    return 0;
}
static duk_ret_t IAssetStorage_SetTrustState_TrustState(duk_context* ctx)
{
    IAssetStorage* thisObj = GetThisWeakObject<IAssetStorage>(ctx);
    IAssetStorage::TrustState trustState_ = (IAssetStorage::TrustState)(int)duk_require_number(ctx, 0);
    thisObj->SetTrustState(trustState_);
    return 0;
}
static duk_ret_t IAssetStorage_TrustStateToString_Static_TrustState(duk_context* ctx)
{
    IAssetStorage::TrustState s = (IAssetStorage::TrustState)(int)duk_require_number(ctx, 0);
    String ret = IAssetStorage::TrustStateToString(s);
    duk_push_string(ctx, ret.CString());
    return 1;
}
Пример #24
0
static duk_ret_t Terrain_ComponentChanged_AttributeChange__Type(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    AttributeChange::Type change = (AttributeChange::Type)(int)duk_require_number(ctx, 0);
    thisObj->ComponentChanged(change);
    return 0;
}
static duk_ret_t PhysicsWorld_SetPhysicsUpdatePeriod_float(duk_context* ctx)
{
    PhysicsWorld* thisObj = GetThisWeakObject<PhysicsWorld>(ctx);
    float updatePeriod = (float)duk_require_number(ctx, 0);
    thisObj->SetPhysicsUpdatePeriod(updatePeriod);
    return 0;
}
static duk_ret_t ParticleSystem_ComponentChanged_AttributeChange__Type(duk_context* ctx)
{
    ParticleSystem* thisObj = GetThisWeakObject<ParticleSystem>(ctx);
    AttributeChange::Type change = (AttributeChange::Type)(int)duk_require_number(ctx, 0);
    thisObj->ComponentChanged(change);
    return 0;
}
Пример #27
0
static duk_ret_t Terrain_SetUpdateMode_AttributeChange__Type(duk_context* ctx)
{
    Terrain* thisObj = GetThisWeakObject<Terrain>(ctx);
    AttributeChange::Type defaultmode = (AttributeChange::Type)(int)duk_require_number(ctx, 0);
    thisObj->SetUpdateMode(defaultmode);
    return 0;
}
Пример #28
0
/**
 * fd, buffer, offset, length, position
 */
static int
es_file_read(duk_context *ctx)
{
  es_fd_t *efd = es_fd_get(ctx, 0);
  duk_size_t bufsize;
  char *buf = duk_require_buffer_data(ctx, 1, &bufsize);

  const int offset = duk_to_int(ctx, 2);
  const int len = duk_to_int(ctx, 3);

  if(offset + len > bufsize)
    duk_error(ctx, DUK_ERR_ERROR, "Buffer too small %zd < %d + %d",
              bufsize, offset + len);

  if(!duk_is_null(ctx, 4)) {
    // Seek
    fa_seek(efd->efd_fh, duk_require_number(ctx, 4), SEEK_SET);
  }

  int r = fa_read(efd->efd_fh, buf + offset, len);
  if(r < 0)
    duk_error(ctx, DUK_ERR_ERROR, "Read error from '%s'", efd->efd_path);

  duk_push_int(ctx, r);
  return 1;
}
Пример #29
0
static int NativePWM(duk_context* ctx)
{
    AJ_Status status;
    double dutyCycle = duk_require_number(ctx, 0);
    uint32_t freq = 0;

    if (dutyCycle > 1.0 || dutyCycle < 0.0) {
        duk_error(ctx, DUK_ERR_RANGE_ERROR, "Duty cycle must be in the range 0.0 to 1.0");
    }
    /*
     * Frequency is optional. If not specified zero is passed into the target code and the default
     * target PWM frequency is used.
     */
    if (!duk_is_undefined(ctx, 1)) {
        freq = duk_require_int(ctx, 1);
        if (freq == 0) {
            duk_error(ctx, DUK_ERR_RANGE_ERROR, "Frequency cannot be zero Hz");
        }
    }
    status = AJS_TargetIO_PinPWM(PinCtxPtr(ctx), dutyCycle, freq);
    if (status != AJ_OK) {
        if (status == AJ_ERR_RESOURCES) {
            duk_error(ctx, DUK_ERR_RANGE_ERROR, "Too many PWM pins");
        } else {
            duk_error(ctx, DUK_ERR_INTERNAL_ERROR, "Error setting PWM %s", AJ_StatusText(status));
        }
    }
    return 0;
}
static duk_ret_t ParticleSystem_SetUpdateMode_AttributeChange__Type(duk_context* ctx)
{
    ParticleSystem* thisObj = GetThisWeakObject<ParticleSystem>(ctx);
    AttributeChange::Type defaultmode = (AttributeChange::Type)(int)duk_require_number(ctx, 0);
    thisObj->SetUpdateMode(defaultmode);
    return 0;
}