Exemplo n.º 1
0
/*
{
  name = ***
  type = GENERATOR_MESH_CONFIG
}
*/
void generator_mesh::load_section_generator_config(DATA_FILE_SECTION *p_section)
{
  DATA_FILE_SECTION *p_line = p_section->section_child_get();
  if(!p_line)
    return;
  
  // Set name of this generator
  name_set(p_section->name_get());
  
  int modificator_index = -1;
  int target_index = -1;
  do {
    if(p_line->is_line()) {
      
      if(p_line->match_name("modificator")) {
        modificator_index++;
        target_index = -1;
        GENERATOR_MESH_MODIFICATOR_CONFIG *p_modificator = config.modificator_ref(modificator_index);
        strncpy(p_modificator->modificator_name, p_line->line_value_string_get(), MAX_NAME);
        p_line->line_mark_loaded();        
        continue;
      }
      else if(modificator_index >= 0) {        
        GENERATOR_MESH_MODIFICATOR_CONFIG *p_modificator = config.modificator_ref(modificator_index);

        // modificator target - for unique targets (TEXTURE/MESH)
        if(p_line->match_name("modificator_target")) {
          target_index++;
          GENERATOR_MESH_MODIFICATOR_TARGET_CONFIG *p_target = p_modificator->target_config_ref(target_index);
          p_target->target_type = modificator_target_translate(p_line->line_value_string_get());
          if(p_target->target_type == MODIFICATOR_TARGET_NONE) {            
            ppset(p_line->source_file_get(), p_line->source_line_get());
            pperror(TRUE, "'%s' is not a valid modificator target!",p_line->line_value_string_get());
            ppclear();
          }
          p_line->line_mark_loaded();
          continue;
        }
        else {
          GENERATOR_MESH_MODIFICATOR_TARGET_CONFIG *p_target = p_modificator->target_config_ref(target_index);
          
          // For other targets (BITMAP/HEIGHTMAP/AUX)
          if(p_line->match_name("modificator_target_name")) {
            strncpy(p_target->target_name, p_line->line_value_string_get(), MAX_NAME);
            p_line->line_mark_loaded();
            continue;
          }
      
          // Load repeat
          load_int(p_target->repeat,"modificator_repeat");
                    
          // Load mask
          p_target->mask.load_line(p_line, generator_get());
        }
      }
    }
  } while((p_line = p_line->section_next()));
}
Exemplo n.º 2
0
static int lyajl_gen_get_buf (lua_State *L) {
  const unsigned char *buf;
  size_t len;
  luvit_generator_t *generator = generator_get(L, 1);
  yajl_gen_get_buf(generator->gen, &buf, &len);
  lua_pushlstring(L, (const char*)buf, len);
  yajl_gen_clear(generator->gen);
  return 1;
}
Exemplo n.º 3
0
void editor::configure(void)
{
  AGE_MAIN *p_age;
  
#ifdef ENABLE_GUI
  if(state.config.gui_enabled) {
    GUI_INTERFACE *p_interface = gui_interface_get();
    p_age = p_interface->age_get();
  } else
#endif
    p_age = new AGE_MAIN;  
  
  SCENE *p_scene = p_age->scene_new();
  p_age->scene_active_set(p_scene);
  
  GRAPH3D *p_grf = p_age->graph_get();
  if(p_grf) {
    p_grf->config_draw_grid(FALSE);
    p_grf->config_draw_mouse_cursor(FALSE);
    p_grf->config_draw_boxes(FALSE);
    p_grf->config_draw_console(FALSE);
    p_grf->config_draw_fps(FALSE);
    p_grf->config_draw_normals(FALSE);
    p_grf->config_opengl_lighting(FALSE);
    p_grf->config_draw_all_objects(TRUE);
    p_grf->config_draw_pivots(TRUE);
    p_grf->config_draw_selection(TRUE);
    //p_grf->config_render_mode_set(RENDER_WIRED);
  }
  
  GENERATOR *p_gen = generator_get();
  GENERATOR_CONFIG *p_config = p_gen->config_get();
  
  char tmp[MAX_FILENAME];
  strncpy(tmp, state.config.script_file, MAX_FILENAME);
  p_config->output_file_set(tail_change(tmp, ".bmp"));
  
  p_gen->load(state.config.script_file);
  p_gen->run(p_scene);
  
  p_scene->update();
}
Exemplo n.º 4
0
/*
 * Launch this mesh generator
 */
void generator_mesh::run(void)
{
  GENERATOR *p_gen = generator_get();
  
  pprintf("Run generator mesh %s:",name_get());
  
  int i;
  for(i = 0; i < MAX_MODIFICATORS; i++) {
    GENERATOR_MESH_MODIFICATOR_CONFIG *p_conf = config.modificator_get(i);    
    if(!p_conf)
      break;
    
    MODIFICATOR *p_mod = p_gen->modificator_find(p_conf->modificator_name);
    if(!p_mod) {
      generator_loader_error("",0,
                             "Can't find modificator %s",
                             p_conf->modificator_name);
    }
    
    pprintf("  Modificator %s, type %s:",
            p_mod->name_get(), p_mod->modificator_type_name_get());
    
    MODIFICATOR_TARGET_STACK target_stack;
    RECT2DI first_target_size(0); 
    
    int j;
    for(j = 0; j < MAX_MODIFICATOR_TARGETS; j++) {
      GENERATOR_MESH_MODIFICATOR_TARGET_CONFIG *p_tconfig = p_conf->target_config_get(j);
      if(!p_tconfig)
        break;
                
      MODIFICATOR_TARGET *p_target = target_cache.target_get(p_tconfig->target_type,
                                                             p_tconfig->target_name);
      if(j == 0) {
        // Get size of first target
        first_target_size = p_target->target_area_get();
        assert(first_target_size.dx > 0 && first_target_size.dy > 0);
      } else {
        // Set scale to all targets along the first one
        p_target->target_scale_set(first_target_size.size_get());
      }
      
      // Set target mask, if it's active
      if(p_tconfig->mask.mask_active() ||
         p_tconfig->mask.mask_create_active())
      {
        p_target->mask_set(&p_tconfig->mask);
      }
      
      // Add found target to target stack, it's going to be used
      // as a target for this modificator run
      target_stack.push(p_target);
      
      pprintf("    target %s, target name '%s'",
              modificator_target_translate(p_tconfig->target_type),
              p_tconfig->target_name);
    }
    
    // Check if we have any target available. Get a target which was 
    // put to target stack as the firts one
    MODIFICATOR_TARGET *p_target = target_stack.get_first();
    if(!p_target) {
      perror("    Missing target! You have to define at least one.");
    }
    
    // Launch the circus
    MODIFICATOR_PARAMS p;
    RECT2DI pos = p_target->target_area_get();
    p_mod->coordinates_top_set(pos);
    p_mod->init(&target_stack, pos, &p);
    p_mod->apply(&target_stack, &p);
          
    // Reset scale on all targets
    int t, target_num;
    MODIFICATOR_TARGET **p_targets = target_stack.get_all(target_num);
    for(t = 0; t < target_num; t++) {
      p_targets[t]->target_scale_clear();
    }
  }  
}
Exemplo n.º 5
0
static int lyajl_gen_gc(lua_State *L) {
  luvit_generator_t *generator = generator_get(L, 1);
  yajl_gen_free(generator->gen);
  return 0;
}
Exemplo n.º 6
0
static int lyajl_gen_array_close (lua_State *L) {
  luvit_generator_t *generator = generator_get(L, 1);
  yajl_gen_array_close(generator->gen);
  return 0;
}
Exemplo n.º 7
0
static int lyajl_gen_map_open (lua_State *L) {
  luvit_generator_t *generator = generator_get(L, 1);
  yajl_gen_map_open(generator->gen);
  return 0;
}