Esempio n. 1
0
ee::SprPtr LoadFromPSD::LoadItem(const Json::Value& value, const std::string& dir, int tw, int th)
{
	std::string type = value["type"].asString();
	if (type == "layer") {
		return LoadLayer(value, dir, tw, th);
	} else if (type == ee::SYM_GROUP_TAG) {
		return LoadGroup(value, dir, tw, th);
	} else {
		return NULL;
	}
}
Esempio n. 2
0
void EnviroFrame::OnDrop(const wxString &str)
{
	vtString utf8 = (const char *) str.ToUTF8();

	if (!str.Right(4).CmpNoCase(_T(".kml")))
	{
		g_App.ImportModelFromKML(utf8);
	}
	else
		LoadLayer(utf8);
}
Esempio n. 3
0
// Load new map
bool j1Map::Load(const char* file_name)
{
    bool ret = true;
    int numTileSets = 0;
    p2SString tmp("%s%s", folder.GetString(), file_name);

    char* buf;
    int size = App->fs->Load(tmp.GetString(), &buf);
    pugi::xml_parse_result result = map_file.load_buffer(buf, size);

//	RELEASE(buf);

    if(result == NULL)
    {
        LOG("Could not load map xml file %s. pugi error: %s", file_name, result.description());
        ret = false;
    }

    if(ret == true)
    {

        numTileSets = LoadMapInfo();// TODO 3: Create and call a private function to load and fill all your map data

    }

    if (numTileSets > 0)
        loadTileSet(numTileSets);// TODO 4: Create and call a private function to load a tileset

    if (map.numLayers > 0)
        LoadLayer(map.numLayers);//Fills maplayer with its information




    map_loaded = ret;

    return ret;
}
Esempio n. 4
0
/* entry point */
int main (int argc, char *argv[])
{
    int c;
    int pitch, size;
    BYTE* framebuffer;
    DWORD t0, t1;

    /* setup engine */
    TLN_Init (WIDTH,HEIGHT, MAX_LAYER, 0, 1);
    TLN_SetRasterCallback (raster_callback);
    TLN_SetBGColor (0,128,238);

    /* load resources*/
    LoadLayer (LAYER_FOREGROUND, "Sonic_md_fg1");
    LoadLayer (LAYER_BACKGROUND, "Sonic_md_bg1");

    /* load sequences */
    sp = TLN_LoadSequencePack ("Sonic_md_seq.sqx");
    sequence = TLN_FindSequence (sp, "seq_water");

    /* assign color sequence to various entries in palette */
    palette = TLN_GetTilesetPalette (layers[LAYER_BACKGROUND].tileset);
    TLN_SetPaletteAnimation (0, palette, sequence, false);

    /* compute increments for variable background scrolling speeds */
    inc_background[0] = float2fix(0.562f);
    inc_background[1] = float2fix(0.437f);
    inc_background[2] = float2fix(0.375f);
    inc_background[3] = float2fix(0.625f);
    inc_background[4] = float2fix(1.0f);
    inc_background[5] = float2fix(2.0f);

    /* framebuffer */
    pitch = WIDTH*4;
    size = pitch*HEIGHT;
    framebuffer = malloc (size);
    TLN_SetRenderTarget (framebuffer, pitch);

    /* main loop */
    printf ("Rendering 5 seconds... ");
    speed = 1.0;
    t0 = t1 = TLN_GetTicks ();
    while (t1 - t0 < 5000)
    {
        /* timekeeper */
        time = frame;

        /* scroll */
        pos_foreground += (int2fix(3)*speed);
        TLN_SetLayerPosition (LAYER_FOREGROUND, fix2int(pos_foreground), ypos);
        for (c=0; c<6; c++)
            pos_background[c] += (inc_background[c] * speed);

        /* render to window */
        TLN_UpdateFrame (time);
        frame++;
        t1 = TLN_GetTicks ();
    }
    printf ("%d fps\n", frame*1000/(t1 - t0));

    /* deinit */
    free (framebuffer);
    FreeLayer (LAYER_FOREGROUND);
    FreeLayer (LAYER_BACKGROUND);
    TLN_DeleteSequencePack (sp);
    TLN_Deinit ();

    return 0;
}
Esempio n. 5
0
bool csGLShaderFFP::Load (iShaderDestinationResolver*, iDocumentNode* node)
{
  if(!node)
    return false;

  csRef<iDocumentNode> mtexnode = node->GetNode("fixedfp");
  if(mtexnode)
  {
    {
      size_t idx = 0;
      csRef<iDocumentNodeIterator> layerIt = mtexnode->GetNodes ("layer");
      while(layerIt->HasNext())
      {
        csRef<iDocumentNode> child = layerIt->Next();
        if(child->GetType() != CS_NODE_ELEMENT) continue;
	const char* name = child->GetAttributeValue ("name");
	if (name != 0)
	  layerNames.Put (name, (int)idx);
        idx++;
      }
    }

    csRef<iDocumentNodeIterator> it = mtexnode->GetNodes();
    while(it->HasNext())
    {
      csRef<iDocumentNode> child = it->Next();
      if(child->GetType() != CS_NODE_ELEMENT) continue;
      const char* value = child->GetValue ();
      csStringID id = tokens.Request (value);
      switch(id)
      {
        case XMLTOKEN_LAYER:
          {
            mtexlayer ml;
            if (!LoadLayer(&ml, child))
              return false;
            texlayers.Push (ml);
          }
          break;
	case XMLTOKEN_FOG:
	  {
	    if (!ParseFog (child, fog))
	      return false;
	  }
	  break;
	case XMLTOKEN_COLORSUM:
	  {
	    bool b;
	    if (!synsrv->ParseBool (child, b, true))
	      return false;
	    colorSum = b;
	  }
	  break;
        default:
	  {
	    switch (commonTokens.Request (value))
	    {
	      case XMLTOKEN_PROGRAM:
	      case XMLTOKEN_VARIABLEMAP:
		// Don't want those
		synsrv->ReportBadToken (child);
		return false;
		break;
	      default:
		if (!ParseCommon (child))
		  return false;
	    }
	  }
      }
    }
    CompactLayers();
    texlayers.ShrinkBestFit();
  }
  else
  {
    synsrv->ReportError ("crystalspace.graphics3d.shader.fixed.fp",
      node, "<fixedfp> node missing");
    return false;
  }
  return true;
}
Esempio n. 6
0
// Load new map
bool j1Map::Load(const char* file_name)
{
	bool ret = true;
	p2SString tmp("%s%s", folder.GetString(), file_name);

	pugi::xml_parse_result result = map_file.load_file(tmp.GetString());

	if(result == NULL)
	{
		LOG("Could not load map xml file %s. pugi error: %s", file_name, result.description());
		ret = false;
	}

	// Load general info ----------------------------------------------
	if(ret == true)
	{
		ret = LoadMap();
	}

	// Load all tilesets info ----------------------------------------------
	pugi::xml_node tileset;
	for(tileset = map_file.child("map").child("tileset"); tileset && ret; tileset = tileset.next_sibling("tileset"))
	{
		TileSet* set = new TileSet();

		if(ret == true)
		{
			ret = LoadTilesetDetails(tileset, set);
		}

		if(ret == true)
		{
			ret = LoadTilesetImage(tileset, set);
		}

		data.tilesets.add(set);
	}

	// Load layer info ----------------------------------------------
	pugi::xml_node layer;
	for(layer = map_file.child("map").child("layer"); layer && ret; layer = layer.next_sibling("layer"))
	{
		MapLayer* lay = new MapLayer();

		ret = LoadLayer(layer, lay);

		if(ret == true)
			data.layers.add(lay);
	}

	if(ret == true)
	{
		LOG("Successfully parsed map XML file: %s", file_name);
		LOG("width: %d height: %d", data.width, data.height);
		LOG("tile_width: %d tile_height: %d", data.tile_width, data.tile_height);

		p2List_item<TileSet*>* item = data.tilesets.start;
		while(item != NULL)
		{
			TileSet* s = item->data;
			LOG("Tileset ----");
			LOG("name: %s firstgid: %d", s->name.GetString(), s->firstgid);
			LOG("tile width: %d tile height: %d", s->tile_width, s->tile_height);
			LOG("spacing: %d margin: %d", s->spacing, s->margin);
			item = item->next;
		}

		p2List_item<MapLayer*>* item_layer = data.layers.start;
		while(item_layer != NULL)
		{
			MapLayer* l = item_layer->data;
			LOG("Layer ----");
			LOG("name: %s", l->name.GetString());
			LOG("tile width: %d tile height: %d", l->width, l->height);
			item_layer = item_layer->next;
		}
	}

	map_loaded = ret;

	return ret;
}
Esempio n. 7
0
BPN::BPN(const char* file, int thrs) {
  std::ifstream fin;
  fin.open(file, std::ifstream::in);

  if(!fin.is_open()) {
    ConstructDefault(thrs);
    return;
  }

  unsigned i;
  max_threads = thrs < 0 ? 0 : thrs;

  readString(fin);
  fin>>initial_scale;

  readString(fin);
  fin>>eta;

  readString(fin);
  fin>>alpha;

  readString(fin);
  fin>>scale_factor;

  readString(fin);
  fin>>size;

  if(size >0) {
    unsigned f, layersize, prevsize=0;
    bool bias;

    //  input layer - no bias
    readString(fin);
    readString(fin);
    fin>>layersize;

    readString(fin);
    fin>>bias;

    readString(fin);
    fin>>f;

    bias = false;
    layers = new bpnLayer*[size];
    layers[0] = new bpnLayer(layersize, prevsize, bias, (outFunction) f, max_threads + 1);
    prevsize = layersize;

    for(i=1; i<size; ++i) {  //  itterate all layer above input
      readString(fin);
      readString(fin);
      fin>>layersize;

      readString(fin);
      fin>>bias;

      readString(fin);
      fin>>f;

      layers[i] = new bpnLayer(layersize, prevsize, bias, (outFunction) f, max_threads + 1);
      prevsize = layersize;
    }

    unsigned lowerSize = layers[size-1]->size;

    if(lowerSize > 0)
      {
	train_output = new double[lowerSize];
	for(i=0; i < lowerSize; ++i) {
	  train_output[i] = 0.0f;
	}
      }

    char ch;
    fin>>ch;

    if(ch =='x') {
      fin.close();
      InitializeWeights();
      return;
    }

    for(i=0; i<size; ++i) {
      LoadLayer(layers[i], fin);
    }
  }
// Load new map
bool j1Map::Load(const char* file_name)
{
	bool ret = true;
	p2SString tmp("%s%s", folder.GetString(), file_name);

	char* buf;
	int size = App->fs->Load(tmp.GetString(), &buf);
	pugi::xml_parse_result result = map_file.load_buffer(buf, size);

	RELEASE(buf);

	if(result == NULL)
	{
		LOG("Could not load map xml file %s. pugi error: %s", file_name, result.description());
		ret = false;
	}

	// Load general info ----------------------------------------------
	if(ret == true)
	{
		ret = LoadMap();
	}

	// Load all tilesets info ----------------------------------------------
	pugi::xml_node tileset;
	for(tileset = map_file.child("map").child("tileset"); tileset && ret; tileset = tileset.next_sibling("tileset"))
	{
		TileSet* set = new TileSet();

		if(ret == true)
		{
			ret = LoadTilesetDetails(tileset, set);
		}

		if(ret == true)
		{
			ret = LoadTilesetImage(tileset, set);
		}

		//STL CHANGE
		data.tilesets.push_back(set);
	}

	// Load layer info ----------------------------------------------
	pugi::xml_node layer;
	for(layer = map_file.child("map").child("layer"); layer && ret; layer = layer.next_sibling("layer"))
	{
		MapLayer* lay = new MapLayer();

		ret = LoadLayer(layer, lay);
		//STL CHANGE
		if(ret == true)
			data.layers.push_back(lay);
	}

	if(ret == true)
	{
		LOG("Successfully parsed map XML file: %s", file_name);
		LOG("width: %d height: %d", data.width, data.height);
		LOG("tile_width: %d tile_height: %d", data.tile_width, data.tile_height);
		//STL CHANGE
		list<TileSet*>::iterator item = data.tilesets.begin();
		while(item != data.tilesets.end())
		{
			TileSet* s = *item;
			LOG("Tileset ----");
			LOG("name: %s firstgid: %d", s->name.GetString(), s->firstgid);
			LOG("tile width: %d tile height: %d", s->tile_width, s->tile_height);
			LOG("spacing: %d margin: %d", s->spacing, s->margin);
			item++;
		}
		//STL CHANGE
		list<MapLayer*>::iterator item_layer = data.layers.begin();
		while(item_layer != data.layers.end())
		{
			MapLayer* l = *item_layer;
			LOG("Layer ----");
			LOG("name: %s", l->name.GetString());
			LOG("tile width: %d tile height: %d", l->width, l->height);
			item_layer++;
		}
	}

	map_loaded = ret;

	return ret;
}