Ejemplo n.º 1
0
SCM script_ogre_attach_object(SCM s_parent, SCM s_child)
{
  void *parent = (void*)scm_to_uint64(s_parent),
       *child  = (void*)scm_to_uint64(s_child);

  ogre_attach_object(parent, child);
  return scm_from_int32(1);
}
Ejemplo n.º 2
0
SCM script_ogre_set_position(SCM s_obj, SCM s_x, SCM s_y, SCM s_z)
{
  void *obj = (void*)scm_to_uint64(s_obj);

  float x = scm_to_double(s_x), y = scm_to_double(s_y), z = scm_to_double(s_z);
  ogre_set_position(obj, x, y, z);
  return scm_from_int32(1);
}
Ejemplo n.º 3
0
bool updateTimer(guihckContext* ctx, guihckElementId id, void* data)
{
  (void) data;

  bool running = scm_is_true(guihckElementGetProperty(ctx, id, "running"));
  if(running)
  {
    double nextTimeout = scm_to_double(guihckElementGetProperty(ctx, id, "next-timeout"));
    double current = guihckContextGetTime(ctx);

    if(nextTimeout < 0)
    {
      double interval = scm_to_double(guihckElementGetProperty(ctx, id, "interval"));
      guihckElementProperty(ctx, id, "next-timeout", scm_from_double(current + interval));
      guihckElementProperty(ctx, id, "cycle", scm_from_int32(0));
    }
    else if(current >= nextTimeout)
    {
      int repeat = scm_to_int32(guihckElementGetProperty(ctx, id, "repeat"));
      int cycle = scm_to_int32(guihckElementGetProperty(ctx, id, "cycle"));
      cycle += 1;

      if(repeat < 0 || repeat > cycle)
      {
        double interval = scm_to_double(guihckElementGetProperty(ctx, id, "interval"));
        guihckElementProperty(ctx, id, "next-timeout", scm_from_double(nextTimeout + interval));
      }
      else
      {
        running = false;
        guihckElementProperty(ctx, id, "next-timeout", scm_from_double(-1));
        guihckElementProperty(ctx, id, "running", SCM_BOOL_F);
      }

      guihckElementProperty(ctx, id, "cycle", scm_from_int32(cycle));
      SCM onTimeout = guihckElementGetProperty(ctx, id, "on-timeout");
      guihckStackPushElement(ctx, id);
      SCM expression = scm_list_2(onTimeout, scm_from_int32(cycle));
      guihckContextExecuteExpression(ctx, expression);
      guihckStackPopElement(ctx);
    }
  }
  return running;
}
Ejemplo n.º 4
0
SCM guileKeyCode(SCM keyName)
{
  char* keyNameStr;
  if(scm_is_symbol(keyName))
    keyNameStr = scm_to_utf8_string(scm_symbol_to_string(keyName));
  else if(scm_is_string(keyName))
    keyNameStr = scm_to_utf8_string(keyName);
  else
    assert(false && "Key name must be a symbol or a string");
  guihckKey keyCode = guihckContextGetKeyCode(threadLocalContext.ctx, keyNameStr);
  free(keyNameStr);

  return scm_from_int32(keyCode);
}
Ejemplo n.º 5
0
SCM guileGetElementChildCount()
{
  return scm_from_int32(guihckStackGetElementChildCount(threadLocalContext.ctx));
}