示例#1
0
void Settings::ParseInitConfig() {
    QFile launcherFile(DirectoryManager::GetInstance()->GetConfigDir() + InitFile);
    if (!launcherFile.open(QFile::ReadOnly)) {
        Logger::GetInstance()->AddLog(tr("Error read launcher config"));
        return;
    }
    YAML::Parser launcherParser;
    std::istringstream launcherStream(launcherFile.readAll().data());
    launcherParser.Load(launcherStream);
    launcherFile.close();

    YAML::Node launcherSettings;
    if (!launcherParser.GetNextDocument(launcherSettings)) {
        Logger::GetInstance()->AddLog(tr("Error parse launcher settings."));
        return;
    }

    AppsConfig newConfig;
    const YAML::Node* pTimer = launcherSettings.FindValue(CONFIG_UPDATE_INTERVAL);
    if (pTimer) {
        QString interval;
        setString(interval, pTimer);
        m_nUpdateTimer = interval.toInt() * 60 * 1000;
    }
    const YAML::Node* Launcher = launcherSettings.FindValue(LAUNCHER);
    if (Launcher) {
        const YAML::Node* LauncherVer = Launcher->FindValue(LAUNCHER_VER);
        if (LauncherVer)
            setString(newConfig.m_Launcher.m_Version, LauncherVer);
        const YAML::Node* LauncherUrl = Launcher->FindValue(LAUNCHER_UPDATE_URL);
        if (LauncherUrl)
            setString(newConfig.m_Launcher.m_Url, LauncherUrl);
    }

    QFile docFile(DirectoryManager::GetInstance()->GetDocumentsDirectory() + InitFile);
    if(docFile.open(QFile::ReadOnly)) {
        YAML::Parser docParser;
        std::istringstream docStream(docFile.readAll().data());
        docParser.Load(docStream);
        docFile.close();

        YAML::Node docSettings;
        docParser.GetNextDocument(docSettings);

        ParseAppConfig(&docSettings, STABLE, newConfig.m_Stable);
        ParseAppConfig(&docSettings, QA, newConfig.m_Test);
        ParseAppConfig(&docSettings, DEVELOPMENT, newConfig.m_Development);
        ParseAppConfig(&docSettings, DEPENDENCIES, newConfig.m_Dependencies);
    }


    m_Config = newConfig;

}
TrackExtractor *loadTEFromDisk (const char *tename) {
    try {
        ifstream is(tename);
        if (is.bad()) {
            is.close();
            cout << "is bad" << endl;
            return defaultTE();
        }

        YAML::Parser parser(is);
        YAML::Node node;
        parser.GetNextDocument(node);
     //   std::cout << "parsed\n";
        if (node.Type() != YAML::NodeType::Map) {
            cout << "failed to parse " << tename << "node is not a map " <<endl;
            return defaultTE();
        }
        if (node.FindValue("max maggot contour angle")) { //it's a maggot
            MaggotTrackExtractor *mte = new MaggotTrackExtractor;
      //      cout << "it's a maggot" << endl;
            mte->fromYAML(node);
            return mte;
        } else {
    //        cout << "basic track extractor" << endl;
            TrackExtractor *te = new TrackExtractor;
            te->fromYAML(node);
            return te;
        }

    } catch (YAML::ParserException &e) {
        std::cout << "Parser Error " << e.what() << "\n";
        return defaultTE();
    }
   
}
string M3JointArrayClient::GetCompDir(string component)
{
    YAML::Node doc;
    GetYamlDoc("m3_config.yml",doc);
    
    if(!doc.FindValue("rt_components")) 
    {
	    ROS_ERROR("No rt_components key in m3_config.yml.");
	    return "";
    }
    
    for(YAML::Iterator it=doc["rt_components"].begin();it!=doc["rt_components"].end();++it) 
    {
	    string dir;

	    it.first() >> dir;
	    
	    for(YAML::Iterator it_dir=doc["rt_components"][dir.c_str()].begin();
		    it_dir!=doc["rt_components"][dir.c_str()].end();++it_dir) 
	    {
		    string  name, type;
		    it_dir.first() >> name;
		    it_dir.second() >> type;
		    if (name == component)		    		    		      		    
		      return dir;
	    }
	    
    }
    ROS_ERROR("No Robot Found.");
    return "";
}
示例#4
0
文件: mod.cpp 项目: Maeyanie/IceCream
Mod::Mod(const YAML::Node& globnode, const YAML::Node& modnode) {
	const Node* key;
	char* value;
	
	if (modnode.FindValue("mod")) {
		modnode["mod"] >> mod;
		modnode["name"] >> name;
		modnode["desc"] >> desc;
	} else { // Backwards compatible mode for <= 0.3
示例#5
0
  void FileDrawNode::load(string const &filename, TextureManager &texRes, SceneManager &sceneRes, ShaderManager &shaderRes, BulletManager &bulletRes)
  {
    for(size_t idx = 0; idx != objects().size(); ++idx)
    {
      // if it's already loaded we can stop
      if(objects()[idx].filename == filename)
      {
        log(__FILE__, __LINE__, LogType::warning, "The file " + filename + " is already loaded");
        return;
      }
    }

    // open the file
    ifstream file(filename);
    if(not file.is_open())
    {
      throw log(__FILE__, __LINE__, LogType::error, "Can't open file " + filename + " for reading");
      return;
    }

    try
    {
      // determine location of the file
      string directory;
      size_t locOfLastSlash = filename.find_last_of('/', string::npos);
      if(locOfLastSlash != string::npos)
        directory = filename.substr(0, locOfLastSlash + 1);

      YAML::Parser parser(file);
      YAML::Node document;
      parser.GetNextDocument(document);

      vector<Scene> scenes = parseScenes(document.FindValue("Scenes"), filename, directory, texRes, sceneRes, bulletRes);
      vector<Shader> shaders = parseShaders(document.FindValue("Shaders"), defaultShaders(), directory, shaderRes);

      objects().push_back({filename, shaders, scenes});
    }
    catch(exception &except)
    {
      throw log(__FILE__, __LINE__, LogType::error, except.what());
    }
  }
示例#6
0
void 
Transfers::load(const YAML::Node & node) 
{
  // xfers are optional...
  const YAML::Node *transfers = node.FindValue("transfers");
  if (transfers) {
    for ( size_t itransfer = 0; itransfer < transfers->size(); ++itransfer ) {
      const YAML::Node & transferNode = (*transfers)[itransfer];
      Transfer *transferInfo = new Transfer(*this);
      transferInfo->load(transferNode);
      this->push_back(transferInfo);
    }
  }
}
/*!
 * Parses the binding config YAML specification.
 *
 * \param[in] node The YAML node containing the binding config specification.
 * \param[out] b The object in which to store the binding configuration information.
 */
void parse_binding_config(YAML::Node const& node, controlit::BindingConfig& bc)
{
    // Parameters
    // for (YAML::Iterator it = node["parameters"].begin();
    //      it !=node["parameters"].end(); ++it)
    // {
    //     std::string paramName;
    //     *it >> paramName;
    //     bc.addParameter(paramName);
    // }

    std::string parameter;
    node["parameter"] >> parameter;
    bc.setParameter(parameter);

    // Direction
    std::string direction;
    node["direction"] >> direction;

    bc.setDirection(controlit::BindingConfig::Direction::Undefined);
    if (direction == "input") bc.setDirection(controlit::BindingConfig::Direction::Input);
    if (direction == "output") bc.setDirection(controlit::BindingConfig::Direction::Output);
    if (direction == "bidirectional") bc.setDirection(controlit::BindingConfig::Direction::Bidirectional);

    // Target
    YAML::Node const& targetNode = *(node.FindValue("target"));
    // targetNode["transportType"] >> bc.transportType;
    std::string transportType;
    std::string transportDataType;

    targetNode["type"] >> transportType;
    targetNode["dataType"] >> transportDataType;

    bc.setTransportType(transportType);
    bc.setTransportDataType(transportDataType);

    // Target properties
    YAML::Node const* propertiesNode = targetNode.FindValue("properties");
    if (propertiesNode != NULL)
    {
        for (YAML::Iterator it = propertiesNode->begin(); it != propertiesNode->end(); ++it)
        {
            std::string key, value;
            it.first() >> key;
            it.second() >> value;
            bc.addProperty(key, value);
        }
    }
}
示例#8
0
bool utl_yaml_read_ip_addr(const YAML::Node& node, 
                         std::string name,
                         uint32_t & val){
    std::string tmp;
    uint32_t ip;
    bool res=false;
    if ( node.FindValue(name) ) {
        node[name] >> tmp ;
        if ( my_inet_pton4((char *)tmp.c_str(), (unsigned char *)&ip) ){
            val=PKT_NTOHL(ip);
            res=true;
        }else{
            printf(" ERROR  not a valid ip %s \n",(char *)tmp.c_str());
            exit(-1);
        }
    }
示例#9
0
void CmdVelMuxNodelet::reloadConfiguration(yocs_cmd_vel_mux::reloadConfig &config, uint32_t unused_level)
{
  std::string yaml_cfg_file;
  ros::NodeHandle &nh = this->getPrivateNodeHandle();
  if( config.yaml_cfg_file == "" )
  {
    // typically fired on startup, so look for a parameter to set a default
    nh.getParam("yaml_cfg_file", yaml_cfg_file);
  }
  else
  {
    yaml_cfg_file = config.yaml_cfg_file;
  }

  /*********************
  ** Yaml File Parsing
  **********************/
  std::ifstream ifs(yaml_cfg_file.c_str(), std::ifstream::in);
  if (ifs.good() == false)
  {
    NODELET_ERROR_STREAM("CmdVelMux : configuration file not found [" << yaml_cfg_file << "]");
    return;
  }
  // probably need to bring the try catches back here
  YAML::Node doc;
#ifdef HAVE_NEW_YAMLCPP
  doc = YAML::Load(ifs);
#else
  YAML::Parser parser(ifs);
  parser.GetNextDocument(doc);
#endif

  /*********************
  ** Output Publisher
  **********************/
  std::string output_name("output");
#ifdef HAVE_NEW_YAMLCPP
  if ( doc["publisher"] ) {
    doc["publisher"] >> output_name;
  }
#else
  const YAML::Node *node = doc.FindValue("publisher");
  if ( node != NULL ) {
    *node >> output_name;
  }
void Configuration::parse(YAML::Node &aDoc, int aPort, int aDelay, int aTimeout, const char *aService)
{
  if (aDoc.FindValue("adapter") != NULL)
  {
    const YAML::Node &adapter = aDoc["adapter"];
    SET_WITH_DEFAULT(adapter, "port", mPort, aPort);
    SET_WITH_DEFAULT(adapter, "scanDelay", mScanDelay, aDelay);
    SET_WITH_DEFAULT(adapter, "timeout", mTimeout, aTimeout);
    SET_WITH_DEFAULT(adapter, "service", mServiceName, aService);
  }
  else
  {
	mPort = aPort;
	mScanDelay = aDelay;
	mTimeout = aTimeout;
	mServiceName = aService;
  }
}
void Property::loadChildren( const YAML::Node& yaml_node )
{
  if( yaml_node.Type() != YAML::NodeType::Map )
  {
    printf( "Property::loadChildren() TODO: error handling - unexpected YAML type.\n" );
    return;
  }

  // A special map entry named "Value" means the value of this property, not a child.
  if( const YAML::Node *value_node = yaml_node.FindValue( "Value" ))
  {
    loadValue( *value_node );
  }

  // Yaml-cpp's FindValue() and operator[] functions are order-N,
  // according to the docs, so we don't want to use those.  Instead we
  // make a hash table of the existing property children, then loop
  // over all the yaml key-value pairs, looking up their targets by
  // key (name) in the map.  This should keep this function down to
  // order-N or close, instead of order N squared.

  // First make the hash table of all child properties indexed by name.
  QHash<QString, Property*> child_map;
  int num_property_children = children_.size();
  for( int i = 0; i < num_property_children; i++ )
  {
    Property* child = children_.at( i );
    child_map[ child->getName() ] = child;
  }

  // Next loop over all yaml key/value pairs, calling load() on each
  // child whose name we find.
  for( YAML::Iterator it = yaml_node.begin(); it != yaml_node.end(); ++it )
  {
    QString key;
    it.first() >> key;
    QHash<QString, Property*>::const_iterator hash_iter = child_map.find( key );
    if( hash_iter != child_map.end() )
    {
      Property* child = hash_iter.value();
      child->load( it.second() );
    }
  }
}
示例#12
0
文件: S3DVox.cpp 项目: wassfila/BPR
//----------------------------------------------------------------------------------
bool g3d::VoxelSpace_c::load(const std::string &FileName,YAML::Node &user_doc)
{
	bool Res = true;
	
	mcv::MixedFileManager_c FManager;
	std::stringstream YamlHeader = FManager.Parse(FileName);
	if(YamlHeader.str().empty())
	{
		std::cout << "VoxelSpace_c::load() Couldn't load File: " << FileName << std::endl;
		return false;
	}
	YAML::Parser parser;
	parser.Load(YamlHeader);
	parser.GetNextDocument(user_doc);
	YAML::Node doc;
	parser.GetNextDocument(doc);
	
	doc["VoxelSize"] >> VoxelSize;
	int TotalVoxels,vXv,vYv,vZv;
	doc["Xv"] >> vXv;
	doc["Yv"] >> vYv;
	doc["Zv"] >> vZv;
	doc["TotalVoxels"] >> TotalVoxels;
	int vNbFill;
	doc["NbFill"] >> vNbFill;
	EigenBox3D vBox;
	doc["VoxBox"] >> vBox;

	//This is the load SetUp as the data is the master with its Xv,Yv,Zv
	//and the <float> is not guarantied through text save and load
	//whether use double if more precision is needed but won't correct the text conversion issue
	//or save the critical information on data, but it becomes no more editable by the user
	//the remaining issue is the float -> text -> float conversion !!! ??? is this safe ?
	Reset(vBox.Low,vXv,vYv,vZv,VoxelSize);//will get Xv = vXv ....

	doc["TypeName"] >> TypeName;
	doc["ColorTable"] >> ColorTable;

	if(doc.FindValue("ClassesNames"))
	{
		doc["ClassesNames"] >> ClassesNames;
	}
示例#13
0
/**
 * Loads the saved battle game from a YAML file.
 * @param node YAML node.
 */
void SavedBattleGame::load(const YAML::Node &node, Ruleset *rule, SavedGame* savedGame)
{
	int a,b;
	int selectedUnit = 0;

	Uint32 startTime = SDL_GetTicks();

	node["width"] >> _mapsize_x;
	node["length"] >> _mapsize_y;
	node["height"] >> _mapsize_z;
	node["missionType"] >> _missionType;
	node["globalshade"] >> _globalShade;
	node["turn"] >> _turn;
	node["selectedUnit"] >> selectedUnit;

	for (YAML::Iterator i = node["mapdatasets"].begin(); i != node["mapdatasets"].end(); ++i)
	{
		std::string name;
		*i >> name;
		MapDataSet *mds = new MapDataSet(name);
		_mapDataSets.push_back(mds);
	}

	initMap(_mapsize_x, _mapsize_y, _mapsize_z);
	
	if (!node.FindValue("tileTotalBytesPer"))
	{
		// binary tile data not found, load old-style text tiles :(
		for (YAML::Iterator i = node["tiles"].begin(); i != node["tiles"].end(); ++i)
		{
			Position pos;
			(*i)["position"][0] >> pos.x;
			(*i)["position"][1] >> pos.y;
			(*i)["position"][2] >> pos.z;
			getTile(pos)->load((*i));
		}
	} else 
	{
示例#14
0
bool CompoundTask::loadConfig(YAML::Node const& doc)
{
    // Before anything, load all of the tasks in the 'tasks' section.
    // We will come back later and query the TaskFactory for the tasks
    // we need.
    std::map<std::string, Task*> taskList;
    YAML::Node const* tasksNode = doc.FindValue("tasks");
    if (tasksNode != NULL)
    {
        for (YAML::Iterator it = tasksNode->begin(); it != tasksNode->end(); ++it)
        {
            // peek into task to get its type and name
            std::string taskType;
            (*it)["type"] >> taskType;
      
            std::string taskName;
            (*it)["name"] >> taskName;
      
            PRINT_DEBUG_STATEMENT_RT("Creating task of type '" << taskType << "' called '" << taskName << "'");
      
            Task* task = taskFactory->loadFromYaml(*it);
      
            if (task != NULL)
            {
                PRINT_DEBUG_STATEMENT_RT("Done creating task '" << taskName << "'");
                taskList.insert(std::make_pair(task->getInstanceName(), task));
            }
            else
            {
                CONTROLIT_PR_ERROR_RT << "Factory failed to create task";
                return false;
            }
        }
    }
    else
    {
示例#15
0
/**
 * Loads a saved game's contents from a YAML file.
 * @note Assumes the saved game is blank.
 * @param filename YAML filename.
 * @param rule Ruleset for the saved game.
 */
void SavedGame::load(const std::string &filename, Ruleset *rule)
{
	std::string s = Options::getUserFolder() + filename + ".sav";
	std::ifstream fin(s.c_str());
	if (!fin)
	{
		throw Exception("Failed to load savegame");
	}
    YAML::Parser parser(fin);
	YAML::Node doc;

	// Get brief save info
    parser.GetNextDocument(doc);
	std::string v;
	doc["version"] >> v;
	if (v != Options::getVersion())
	{
		throw Exception("Version mismatch");
	}
	_time->load(doc["time"]);

	// Get full save data
	parser.GetNextDocument(doc);
	int a = 0;
	doc["difficulty"] >> a;
	_difficulty = (GameDifficulty)a;
	doc["funds"] >> _funds;

	for (YAML::Iterator i = doc["countries"].begin(); i != doc["countries"].end(); ++i)
	{
		std::string type;
		(*i)["type"] >> type;
		Country *c = new Country(rule->getCountry(type), false);
		c->load(*i);
		_countries.push_back(c);
	}

	for (YAML::Iterator i = doc["regions"].begin(); i != doc["regions"].end(); ++i)
	{
		std::string type;
		(*i)["type"] >> type;
		Region *r = new Region(rule->getRegion(type));
		r->load(*i);
		_regions.push_back(r);
	}

	for (YAML::Iterator i = doc["ufos"].begin(); i != doc["ufos"].end(); ++i)
	{
		std::string type;
		(*i)["type"] >> type;
		Ufo *u = new Ufo(rule->getUfo(type));
		u->load(*i);
		_ufos.push_back(u);
	}

	doc["craftId"] >> _craftId;

	for (YAML::Iterator i = doc["waypoints"].begin(); i != doc["waypoints"].end(); ++i)
	{
		Waypoint *w = new Waypoint();
		w->load(*i);
		_waypoints.push_back(w);
	}

	doc["ufoId"] >> _ufoId;
	doc["waypointId"] >> _waypointId;
	doc["soldierId"] >> _soldierId;

	for (YAML::Iterator i = doc["bases"].begin(); i != doc["bases"].end(); ++i)
	{
		Base *b = new Base(rule);
		b->load(*i, this);
		_bases.push_back(b);
	}

	for(YAML::Iterator it=doc["discovered"].begin();it!=doc["discovered"].end();++it)
	{
		std::string research;
		*it >> research;
		_discovered.push_back(rule->getResearchProject(research));
	}

	if (const YAML::Node *pName = doc.FindValue("battleGame"))
	{
		_battleGame = new SavedBattleGame();
		_battleGame->load(*pName, rule, this);
	}

	fin.close();
}
示例#16
0
/**
 * Loads a saved game's contents from a YAML file.
 * @note Assumes the saved game is blank.
 * @param filename YAML filename.
 * @param rule Ruleset for the saved game.
 */
void SavedGame::load(const std::string &filename, Ruleset *rule)
{
	unsigned int size = 0;

	std::string s = USER_DIR + filename + ".sav";
	std::ifstream fin(s.c_str());
	if (!fin)
	{
		throw Exception("Failed to load savegame");
	}
    YAML::Parser parser(fin);
	YAML::Node doc;

	// Get brief save info
    parser.GetNextDocument(doc);
	std::string v;
	doc["version"] >> v;
	if (v != "0.2")
	{
		throw Exception("Version mismatch");
	}
	_time->load(doc["time"]);

	// Get full save data
	parser.GetNextDocument(doc);
	int a;
	doc["difficulty"] >> a;
	_difficulty = (GameDifficulty)a;
	doc["funds"] >> _funds;

	size = doc["countries"].size();
	for (unsigned int i = 0; i < size; i++)
	{
		std::string type;
		doc["countries"][i]["type"] >> type;
		Country *c = new Country(rule->getCountry(type), false);
		c->load(doc["countries"][i]);
		_countries.push_back(c);
	}

	size = doc["regions"].size();
	for (unsigned int i = 0; i < size; i++)
	{
		std::string type;
		doc["regions"][i]["type"] >> type;
		Region *r = new Region(rule->getRegion(type));
		r->load(doc["regions"][i]);
		_regions.push_back(r);
	}
	
	size = doc["ufos"].size();
	for (unsigned int i = 0; i < size; i++)
	{
		std::string type;
		doc["ufos"][i]["type"] >> type;
		Ufo *u = new Ufo(rule->getUfo(type));
		u->load(doc["ufos"][i]);
		_ufos.push_back(u);
	}

	doc["craftId"] >> _craftId;

	size = doc["waypoints"].size();
	for (unsigned int i = 0; i < size; i++)
	{
		Waypoint *w = new Waypoint();
		w->load(doc["waypoints"][i]);
		_waypoints.push_back(w);
	}

	doc["ufoId"] >> _ufoId;
	doc["waypointId"] >> _waypointId;

	size = doc["bases"].size();
	for (unsigned int i = 0; i < size; i++)
	{
		Base *b = new Base(rule);
		b->load(doc["bases"][i], this);
		_bases.push_back(b);
	}

	if (const YAML::Node *pName = doc.FindValue("battleGame"))
	{
		_battleGame = new SavedBattleGame();
		_battleGame->load(*pName);
	}
	
	fin.close();
}
示例#17
0
    void Robots::loadYaml(string filename)
    {
        cout << endl << "Loading yaml configuration " << filename << endl;

        try
        {
            ifstream cfgfile(filename.c_str());
            if(!cfgfile)
                throw string("Failed to open file " + filename);

            YAML::Parser parser(cfgfile);
            YAML::Node doc;

            bool result = parser.GetNextDocument(doc);
            if(!result)
                throw string("Parser failed to load document");

            if(!doc.FindValue("robots"))
            {
                throw string("Config error : no robots entry in yaml doc");
            }
            else
            {
                YAML::Iterator it;
                int i;

                string name, host, environment, move;
                int port;
                vector<string> loadedMoves;

                for(it=doc["robots"].begin();it!=doc["robots"].end();++it)
                {
                    loadedMoves.clear();

                    // Name
                    it.first() >> name;
                    robots[name] = new Robot(new CommandsStore, name);

                    // Host & port
                    if(it.second().FindValue("host"))
                    {
                        if(it.second().FindValue("host"))
                            it.second()["host"] >> host;
                        else
                            host = "localhost";

                        if(it.second().FindValue("port")) {
                            it.second()["port"] >> port;
                        } else {
                            port = 7777;
                        }

                        robots[name]->connect(host.c_str(), port);
                    }

                    // Environment
                    if(it.second().FindValue("environment"))
                    {
                        it.second()["environment"] >> environment;
                        robots[name]->loadEnvironment(environment);
                    }
示例#18
0
void Network::loadFromBundle(const std::string& name)
{
  if (! StringUtils::endsWith(name, ".nta"))
    NTA_THROW << "loadFromBundle: bundle extension must be \".nta\"";

  std::string fullPath = Path::normalize(Path::makeAbsolute(name));

  if (! Path::exists(fullPath))
    NTA_THROW << "Path " << fullPath << " does not exist";

  std::string networkStructureFilename = Path::join(fullPath, "network.yaml");
  std::ifstream f(networkStructureFilename.c_str());
  YAML::Parser parser(f);
  YAML::Node doc;
  bool success = parser.GetNextDocument(doc);
  if (!success)
    NTA_THROW << "Unable to find YAML document in network structure file " 
              << networkStructureFilename;

  if (doc.Type() != YAML::NodeType::Map)
    NTA_THROW << "Invalid network structure file -- does not contain a map";

  // Should contain Version, Regions, Links
  if (doc.size() != 3)
    NTA_THROW << "Invalid network structure file -- contains " 
              << doc.size() << " elements";

  // Extra version
  const YAML::Node *node = doc.FindValue("Version");
  if (node == NULL)
    NTA_THROW << "Invalid network structure file -- no version";
  
  int version;
  *node >> version;
  if (version != 2)
    NTA_THROW << "Invalid network structure file -- only version 2 supported";
  
  // Regions
  const YAML::Node *regions = doc.FindValue("Regions");
  if (regions == NULL)
    NTA_THROW << "Invalid network structure file -- no regions";

  if (regions->Type() != YAML::NodeType::Sequence)
    NTA_THROW << "Invalid network structure file -- regions element is not a list";
  
  for (YAML::Iterator region = regions->begin(); region != regions->end(); region++)
  {
    // Each region is a map -- extract the 5 values in the map
    if ((*region).Type() != YAML::NodeType::Map)
      NTA_THROW << "Invalid network structure file -- bad region (not a map)";
    
    if ((*region).size() != 5)
      NTA_THROW << "Invalid network structure file -- bad region (wrong size)";
    
    // 1. name
    node = (*region).FindValue("name");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- region has no name";
    std::string name;
    *node >> name;

    // 2. nodeType
    node = (*region).FindValue("nodeType");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- region " 
                << name << " has no node type";
    std::string nodeType;
    *node >> nodeType;

    // 3. dimensions
    node = (*region).FindValue("dimensions");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- region "
                << name << " has no dimensions";
    if ((*node).Type() != YAML::NodeType::Sequence)
      NTA_THROW << "Invalid network structure file -- region "
                << name << " dimensions specified incorrectly";
    Dimensions dimensions;
    for (YAML::Iterator valiter = (*node).begin(); valiter != (*node).end(); valiter++)
    {
      size_t val;
      (*valiter) >> val;
      dimensions.push_back(val);
    }

    // 4. phases
    node = (*region).FindValue("phases");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- region"
                << name << "has no phases";
    if ((*node).Type() != YAML::NodeType::Sequence)
      NTA_THROW << "Invalid network structure file -- region "
                << name << " phases specified incorrectly";

    std::set<UInt32> phases;
    for (YAML::Iterator valiter = (*node).begin(); valiter != (*node).end(); valiter++)
    {
      UInt32 val;
      (*valiter) >> val;
      phases.insert(val);
    }
    
    // 5. label
    node = (*region).FindValue("label");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- region"
                << name << "has no label";
    std::string label;
    *node >> label;
    
    Region *r = addRegionFromBundle(name, nodeType, dimensions, fullPath, label);
    setPhases_(r, phases);


  }

  const YAML::Node *links = doc.FindValue("Links");
  if (links == NULL)
    NTA_THROW << "Invalid network structure file -- no links";

  if (links->Type() != YAML::NodeType::Sequence)
    NTA_THROW << "Invalid network structure file -- links element is not a list";

  for (YAML::Iterator link = links->begin(); link != links->end(); link++)
  {
    // Each link is a map -- extract the 5 values in the map
    if ((*link).Type() != YAML::NodeType::Map)
      NTA_THROW << "Invalid network structure file -- bad link (not a map)";
    
    if ((*link).size() != 6)
      NTA_THROW << "Invalid network structure file -- bad link (wrong size)";
    
    // 1. type
    node = (*link).FindValue("type");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- link does not have a type";
    std::string linkType;
    *node >> linkType;

    // 2. params
    node = (*link).FindValue("params");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- link does not have params";
    std::string params;
    *node >> params;

    // 3. srcRegion (name)
    node = (*link).FindValue("srcRegion");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- link does not have a srcRegion";
    std::string srcRegionName;
    *node >> srcRegionName;


    // 4. srcOutput
    node = (*link).FindValue("srcOutput");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- link does not have a srcOutput";
    std::string srcOutputName;
    *node >> srcOutputName;

    // 5. destRegion
    node = (*link).FindValue("destRegion");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- link does not have a destRegion";
    std::string destRegionName;
    *node >> destRegionName;

    // 6. destInput
    node = (*link).FindValue("destInput");
    if (node == NULL)
      NTA_THROW << "Invalid network structure file -- link does not have a destInput";
    std::string destInputName;
    *node >> destInputName;

    if (!regions_.contains(srcRegionName))
      NTA_THROW << "Invalid network structure file -- link specifies source region '" << srcRegionName << "' but no such region exists";
    Region* srcRegion = regions_.getByName(srcRegionName);

    if (!regions_.contains(destRegionName))
      NTA_THROW << "Invalid network structure file -- link specifies destination region '" << destRegionName << "' but no such region exists";
    Region* destRegion = regions_.getByName(destRegionName);

    Output* srcOutput = srcRegion->getOutput(srcOutputName);
    if (srcOutput == NULL)
      NTA_THROW << "Invalid network structure file -- link specifies source output '" << srcOutputName << "' but no such name exists";

    Input* destInput = destRegion->getInput(destInputName);
    if (destInput == NULL)
      NTA_THROW << "Invalid network structure file -- link specifies destination input '" << destInputName << "' but no such name exists";

    // Create the link itself
    destInput->addLink(linkType, params, srcOutput);


  } // links

}
ConnectOneAdapter::ConnectOneAdapter(int aPort)
  : Adapter(aPort, 500), mConnected(0), mLastND(0)
{
  if (!sWriteLockInitialized) {
    INIT(sWriteLock);
    INIT(sSendLock);
    sWriteLockInitialized = true;
  }

  ifstream fin("connectone.yaml");
  YAML::Parser parser(fin);
  YAML::Node doc;
  parser.GetNextDocument(doc);
  const YAML::Node &comms = doc["communications"];
  comms["port"] >> mSerialPort;
  comms["baud"] >> mBaud;
  SET_WITH_DEFAULT(comms, "dataBits", mDataBits, 8);
  comms["stopBits"] >> mStopBits;
  comms["parity"] >> mParity;

  SET_WITH_DEFAULT(comms, "silenceTimeout", mSilenceTimeout, 20);
  SET_WITH_DEFAULT(comms, "honorTimestamp", mHonorTimestamp, false);
  SET_WITH_DEFAULT(comms, "heartBeat", mHeartBeat, 2);

  mSerial = new Serial(mSerialPort.c_str(), mBaud, mParity.c_str(),
                       mDataBits, mStopBits);
  mXBee.setSerial(mSerial);

  // Get the devices to poll.
  if (doc.FindValue("devices") != NULL) {
    const YAML::Node &devices = doc["devices"];
    for(unsigned i = 0; i < devices.size(); i++) {
      const YAML::Node &device = devices[i];
      if (device.FindValue("name") == NULL ||
          device.FindValue("address") == NULL ||
          device.FindValue("prefix") == NULL)
      {
        gLogger->error("Device must have 'name', 'address', and 'prefix'");
        continue;
      }

      string deviceName;
      device["name"] >> deviceName;
      const YAML::Node &address = device["address"];
	  if (address.GetType() != YAML::CT_SEQUENCE || address.size() < 8)
	  {
		gLogger->error("Address must be 8 characters");
		continue;
	  }
      uint32_t msb = 0, lsb = 0;
      for (int j = 0; j < 8; j++) {
        uint32_t v;
        address[j] >> v;
        if (j > 3)
          lsb |= v << (7 - j) * 8;
        else
          msb |= v << (3 - j) * 8;
      }
      XBeeAddress64 xbAddr(msb, lsb);
      ConnectOneDevice *d = new ConnectOneDevice(deviceName, xbAddr);
      device["prefix"] >> d->mPrefix;
      SET_WITH_DEFAULT(device, "silenceTimeout", d->mSilenceTimeout, mSilenceTimeout);
      SET_WITH_DEFAULT(device, "honorTimestamp", d->mHonorTimestamp, mHonorTimestamp);
      SET_WITH_DEFAULT(device, "heartBeat", d->mHeartBeat, mHeartBeat);

      mDevices.push_back(d);
    }
  }
}
示例#20
0
int main()
{
	cout << Base64ToInt(IntToBase64(262154)) << endl;
	cout << Distance3D(vector3(1,1,1), vector3(0,0,0)) << endl;
    std::ifstream fin("test.yaml");
	YAML::Parser parser(fin);
	YAML::Node doc;
	parser.GetNextDocument(doc);
	int ScreenWidth = 800, ScreenHeight = 600;
	*(doc.FindValue("window")->FindValue("width")) >> ScreenWidth;
	*(doc.FindValue("window")->FindValue("height")) >> ScreenHeight;

	
    sf::Window window(sf::VideoMode(ScreenWidth, ScreenHeight), "OpenGL", sf::Style::Default, sf::ContextSettings(32));
    window.setVerticalSyncEnabled(true);
    bool running = true;

	window.setMouseCursorVisible(false);

	glewInit(); //MUST COME AFTER WINDOW INIT;

	space TestSpace;
	
    sf::Event event;

	glClearColor(0.0f, 0.0f, 0.3f, 0.0f);

	glEnable(GL_DEPTH_TEST);

	glDepthFunc(GL_LESS); 

	glEnable(GL_CULL_FACE);
	
	glm::vec3 CameraPos = glm::vec3( 5, 0, 0 ); 
	real FieldOfView = 70.0f;
	
	real MouseSensitivity = 0.009f;
	real MoveSpeed = 5.0f;
	real HorizontalAngle = 0;
	real VerticalAngle = 0;

	glm::mat4 ProjectionMatrix;
	glm::mat4 ViewMatrix;

	// vvvvv F*****G DELETE THIS IF YOU WANT TO LIVE
	GLuint programID = LoadShaders( "TransformVertexShader.vertexshader", "TextureFragmentShader.fragmentshader" );
	GLuint MatrixID = glGetUniformLocation(programID, "MVP");
	// ^^^^^^^^^^^

	sf::Clock Clock;
	sf::Time ElapsedTime;
	int MousePrevX = sf::Mouse::getPosition().x;
	int MousePrevY = sf::Mouse::getPosition().y;

	glm::mat4 ModelMatrix = glm::mat4(1.0);
	
	gl_blocktextureindex TestBlockTextures;
	TestBlockTextures.setTextureSize(64,64);
	
	char* ImgFileBuffer = 0;
	ifstream imgtest ("Testtex.png", ios::in|ios::binary|ios::ate);
	ifstream::pos_type size;
	if (imgtest.is_open())
	{
		size = imgtest.tellg();
		ImgFileBuffer = new char [size];
		imgtest.seekg (0, ios::beg);
		imgtest.read (ImgFileBuffer, size);
	}
	imgtest.close();
	TestBlockTextures.addTexture("test1", static_cast<void*>(ImgFileBuffer), size);
	delete [] ImgFileBuffer;
	
	imgtest.open("Testtex2.png", ios::in|ios::binary|ios::ate);
	if (imgtest.is_open())
	{
		size = imgtest.tellg();
		ImgFileBuffer = new char [size];
		imgtest.seekg (0, ios::beg);
		imgtest.read (ImgFileBuffer, size);
	}
	imgtest.close();
	TestBlockTextures.addTexture("test2", static_cast<void*>(ImgFileBuffer), size);
	delete [] ImgFileBuffer;

	imgtest.open("teststone.png", ios::in|ios::binary|ios::ate);
	if (imgtest.is_open())
	{
		size = imgtest.tellg();
		ImgFileBuffer = new char [size];
		imgtest.seekg (0, ios::beg);
		imgtest.read (ImgFileBuffer, size);
	}
	imgtest.close();
	TestBlockTextures.addTexture("Stone", static_cast<void*>(ImgFileBuffer), size);
	delete [] ImgFileBuffer;

	imgtest.open("testdirt.png", ios::in|ios::binary|ios::ate);
	if (imgtest.is_open())
	{
		size = imgtest.tellg();
		ImgFileBuffer = new char [size];
		imgtest.seekg (0, ios::beg);
		imgtest.read (ImgFileBuffer, size);
	}
	imgtest.close();
	TestBlockTextures.addTexture("Dirt", static_cast<void*>(ImgFileBuffer), size);
	delete [] ImgFileBuffer;
	
	imgtest.open("testgrass.png", ios::in|ios::binary|ios::ate);
	if (imgtest.is_open())
	{
		size = imgtest.tellg();
		ImgFileBuffer = new char [size];
		imgtest.seekg (0, ios::beg);
		imgtest.read (ImgFileBuffer, size);
	}
	imgtest.close();
	TestBlockTextures.addTexture("Grass", static_cast<void*>(ImgFileBuffer), size);
	delete [] ImgFileBuffer;

	imgtest.open("testglass.png", ios::in|ios::binary|ios::ate);
	if (imgtest.is_open())
	{
		size = imgtest.tellg();
		ImgFileBuffer = new char [size];
		imgtest.seekg (0, ios::beg);
		imgtest.read (ImgFileBuffer, size);
	}
	imgtest.close();
	TestBlockTextures.addTexture("Glass", static_cast<void*>(ImgFileBuffer), size);
	delete [] ImgFileBuffer;

	std::cout << TestBlockTextures.getTextureCount() << std::endl;
	std::cout << TestBlockTextures.getTextureIDByName("test1") << std::endl;
	TestBlockTextures.Build();
	glBindTexture(GL_TEXTURE_2D_ARRAY, TestBlockTextures.getTextureArrayID());
	
	glUseProgram(programID);



	
	blockart TestArt1;
	for(int i = 0; i < 6; i++)
	{
		TestArt1.setTexture(i,TestBlockTextures.getTextureIDByName("test1")); 
	}
	blockart TestArt2;
	for(int i = 0; i < 6; i++)
	{
		TestArt2.setTexture(i,TestBlockTextures.getTextureIDByName("test2")); 
	}
	blockart TestArtStone;
	for(int i = 0; i < 6; i++)
	{
		TestArtStone.setTexture(i,TestBlockTextures.getTextureIDByName("Stone")); 
	}
	blockart TestArtDirt;
	for(int i = 0; i < 6; i++)
	{
		TestArtDirt.setTexture(i,TestBlockTextures.getTextureIDByName("Dirt")); 
	}
	blockart TestArtGrass;
	for(int i = 0; i < 6; i++)
	{
		TestArtGrass.setTexture(i,TestBlockTextures.getTextureIDByName("Grass")); 
	}
	blockart TestArtGlass;
	for(int i = 0; i < 6; i++)
	{
		TestArtGlass.setTexture(i,TestBlockTextures.getTextureIDByName("Glass"));
		TestArtGlass.setCullsOthers(NumToAxis[i], false);
	}



	blockindex TestBlockIndex;
	TestBlockIndex.addBlock("air");
	TestBlockIndex.getBlockByID(TestBlockIndex.addBlock("test1"))->setBlockArt(&TestArt1);
	TestBlockIndex.getBlockByID(TestBlockIndex.addBlock("test2"))->setBlockArt(&TestArt2);
	TestBlockIndex.getBlockByID(TestBlockIndex.addBlock("Stone"))->setBlockArt(&TestArtStone);
	TestBlockIndex.getBlockByID(TestBlockIndex.addBlock("Dirt"))->setBlockArt(&TestArtDirt);
	TestBlockIndex.getBlockByID(TestBlockIndex.addBlock("Grass"))->setBlockArt(&TestArtGrass);
	TestBlockIndex.getBlockByID(TestBlockIndex.addBlock("Glass"))->setBlockArt(&TestArtGlass);

	
	
	//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	//glEnable(GL_BLEND);
	glAlphaFunc(GL_GREATER, 0.5);
	glEnable(GL_ALPHA_TEST);

	chunkgenerator TestGen;
	TestGen.regBlockIndex(&TestBlockIndex);

	TestSpace.regChunkGen(&TestGen);

	/*int Gensize = 4;

	for(int XIter = -(Gensize/2); XIter < (Gensize/2); XIter++)
	{
		for(int ZIter = -(Gensize/2); ZIter < (Gensize/2); ZIter++)
		{
			TestSpace.genColumn(XIter,ZIter);
		}
	}*/

	TestSpace.genChunk(0,0,0);



	
	chunkblockmodel TestModel;
	
	TestModel.regBlockIndex(&TestBlockIndex);
	TestModel.regChunk(TestSpace.getChunk(0, 0, 0));
	TestModel.Rebuild();

	int CurrentBrush = 0;

	int PreviousWheel;

    while (running)
    {
		ElapsedTime = Clock.restart();
		
		HorizontalAngle += ((ScreenWidth/2)-sf::Mouse::getPosition(window).x) * MouseSensitivity;
		VerticalAngle += ((ScreenHeight/2)-sf::Mouse::getPosition(window).y) * MouseSensitivity;
		MousePrevX = sf::Mouse::getPosition().x;
		MousePrevY = sf::Mouse::getPosition().y;
		sf::Mouse::setPosition(sf::Vector2i(ScreenWidth/2, ScreenHeight/2), window);

		
		if(VerticalAngle > 1.57)
		{
			VerticalAngle = 1.57;
		}
		else if(VerticalAngle < -1.57)
		{
			VerticalAngle = -1.57;
		}

		if(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
		{
			running = false;
		}
		
		// vvvvvvvv DELETE THIS BEFORE RELEASE
		glm::vec3 direction(
			cos(VerticalAngle) * sin(HorizontalAngle), 
			sin(VerticalAngle),
			cos(VerticalAngle) * cos(HorizontalAngle)
		);
		glm::vec3 right = glm::vec3(
			sin(HorizontalAngle - 3.14f/2.0f), 
			0,
			cos(HorizontalAngle - 3.14f/2.0f)
		);
		glm::vec3 up = glm::cross( right, direction );
		// ^^^^^^^
		
		if(sf::Keyboard::isKeyPressed(sf::Keyboard::A))
		{
			CameraPos -= (ElapsedTime.asSeconds() * MoveSpeed) * right;
		}
		if(sf::Keyboard::isKeyPressed(sf::Keyboard::D))
		{
			CameraPos += (ElapsedTime.asSeconds() * MoveSpeed) * right;
		}
		if(sf::Keyboard::isKeyPressed(sf::Keyboard::W))
		{
			CameraPos += (ElapsedTime.asSeconds() * MoveSpeed) * direction;
		}
		if(sf::Keyboard::isKeyPressed(sf::Keyboard::S))
		{
			CameraPos -= (ElapsedTime.asSeconds() * MoveSpeed) * direction;
		}
		
        // handle events
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                // end the program
                running = false;
            }
            else if (event.type == sf::Event::Resized)
            {
                // adjust the viewport when the window is resized
                glViewport(0, 0, event.size.width, event.size.height);
            }
			else if (event.type == sf::Event::KeyReleased)
			{
				if(event.key.code == sf::Keyboard::F2)
				{
					char* ChunkFileBuffer = TestSpace.getChunk(0, 0, 0)->Save();
					ofstream Save ("test.wlc", ios::out|ios::binary|ios::trunc);
					ofstream::pos_type size = TestSpace.getChunk(0, 0, 0)->SaveSize();
					if (Save.is_open())
					{
						Save.write(ChunkFileBuffer, size);
					}
					Save.close();
					TestSpace.getChunk(0, 0, 0)->DoneSaving();					
				}
				else if(event.key.code == sf::Keyboard::F3)
				{
					real StartTime = Clock.getElapsedTime().asSeconds();
					char* ChunkFileBuffer = 0;
					ifstream Load ("test.wlc", ios::in|ios::binary|ios::ate);
					ifstream::pos_type size;
					if (Load.is_open())
					{
						size = Load.tellg();
						ChunkFileBuffer = new char [size];
						Load.seekg (0, ios::beg);
						Load.read (ChunkFileBuffer, size);
					}
					Load.close();
					TestSpace.getChunk(0, 0, 0)->Load(ChunkFileBuffer, size);
					TestSpace.getChunk(0, 0, 0)->DoneLoading();
					delete [] ChunkFileBuffer;
					TestModel.Rebuild();
					cout << "Load & rebuild time: " << Clock.getElapsedTime().asSeconds() - StartTime << std::endl;
				}
				else if(event.key.code == sf::Keyboard::F4)
				{
					TestGen.GenerateChunk(TestSpace.getChunk(0, 0, 0));
					TestModel.Rebuild();
				}
				else if(event.key.code == sf::Keyboard::Escape)
				{
					running = false;
				}
			}
			else if (event.type == sf::Event::MouseWheelMoved)
			{
				CurrentBrush += event.mouseWheel.delta;
				if(CurrentBrush >= TestBlockIndex.getBlockCount())
				{
					CurrentBrush = 0;
				}
				else if(CurrentBrush < 0)
				{
					CurrentBrush = TestBlockIndex.getBlockCount() - 1;
				}
				cout << TestBlockIndex.getNameByBlockID(CurrentBrush) << std::endl;
			}
			else if (event.type == sf::Event::MouseButtonReleased)
			{
				int tempx, tempy, tempz;
				if (direction.x > 0)
				{
					if(abs(direction.x) >= 0.5)
					{
						tempx = (int)ceil(direction.x);
					}
					else
					{
						tempx = (int)floor(direction.x);
					}
				}
				else
				{
					if(abs(direction.x) >= 0.5)
					{
						tempx = (int)floor(direction.x);
					}
					else
					{
						tempx = (int)ceil(direction.x);
					}
				}
				if (direction.y > 0)
				{
					if(abs(direction.y) >= 0.5)
					{
						tempy = (int)ceil(direction.y);
					}
					else
					{
						tempy = (int)floor(direction.y);
					}
				}
				else
				{
					if(abs(direction.y) >= 0.5)
					{
						tempy = (int)floor(direction.y);
					}
					else
					{
						tempy = (int)ceil(direction.y);
					}
				}
				if (direction.z > 0)
				{
					if(abs(direction.z) >= 0.5)
					{
						tempz = (int)ceil(direction.z);
					}
					else
					{
						tempz = (int)floor(direction.z);
					}
				}
				else
				{
					if(abs(direction.z) >= 0.5)
					{
						tempz = (int)floor(direction.z);
					}
					else
					{
						tempz = (int)ceil(direction.z);
					}
				}
				if(TestSpace.getBlockExists((CameraPos.x+tempx), (CameraPos.y+tempy), (CameraPos.z+tempz)))
				{
					if(event.mouseButton.button == sf::Mouse::Button::Left)
					{
						if(TestSpace.getBlock((CameraPos.x+tempx), (CameraPos.y+tempy), (CameraPos.z+tempz)) != 0)
						{
							real StartTime = Clock.getElapsedTime().asSeconds();
							TestSpace.setBlock((CameraPos.x+tempx), (CameraPos.y+tempy), (CameraPos.z+tempz), 0);
							TestModel.Rebuild();
							cout << "Rebuild time: " << Clock.getElapsedTime().asSeconds() - StartTime << std::endl;
						}
					}
					if(event.mouseButton.button == sf::Mouse::Button::Right)
					{
						if(TestSpace.getBlock((CameraPos.x+tempx), (CameraPos.y+tempy), (CameraPos.z+tempz)) == 0)
						{
							real StartTime = Clock.getElapsedTime().asSeconds();
							TestSpace.setBlock((CameraPos.x+tempx), (CameraPos.y+tempy), (CameraPos.z+tempz), CurrentBrush);
							TestModel.Rebuild();
							cout << "Rebuild time: " << Clock.getElapsedTime().asSeconds() - StartTime << std::endl;
						}
					}
					if(event.mouseButton.button == sf::Mouse::Button::Middle)
					{
						CurrentBrush = TestSpace.getBlock((CameraPos.x+tempx), (CameraPos.y+tempy), (CameraPos.z+tempz));
						cout << TestBlockIndex.getNameByBlockID(CurrentBrush) << std::endl;
					}
				}
			}
        }
        // clear the buffers
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		// vvvvvvv
		ProjectionMatrix = glm::perspective(FieldOfView, 4.0f / 3.0f, 0.1f, 1000.0f);
		// Camera matrix
		ViewMatrix       = glm::lookAt(
									CameraPos,           // Camera is here
									CameraPos+direction, // and looks here : at the same position, plus "direction"
									up                  // Head is up (set to 0,-1,0 to look upside-down)
							   );
		//glEnableVertexAttribArray(0);
     //   glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
       /* glVertexAttribPointer(
           0,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
           3,                  // size
           GL_real,           // type
           GL_FALSE,           // normalized?
           0,                  // stride
           (void*)0            // array buffer offset
        );*/
		/*glEnableVertexAttribArray(1);
		glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
		glVertexAttribPointer(
			1,                                // attribute. No particular reason for 1, but must match the layout in the shader.
			2,                                // size : U+V => 2
			GL_real,                         // type
			GL_FALSE,                         // normalized?
			0,                                // stride
			(void*)0                          // array buffer offset
		);*/


				// Use our shader
		glUseProgram(programID);

		// Bind our texture in Texture Unit 0
		glActiveTexture(GL_TEXTURE0);
		glBindTexture(GL_TEXTURE_2D_ARRAY, TestBlockTextures.getTextureArrayID());
		// Set our "myTextureSampler" sampler to user Texture Unit 0
		//glUniform1i(TestBlockTextures.getTextureArrayID(), 0);
		glm::mat4 MVP = ProjectionMatrix * ViewMatrix * ModelMatrix;
		// Send our transformation to the currently bound shader, 
		// in the "MVP" uniform
		glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
		// ^^^^^^^^ DELETE THIS BEFORE RELEASE
		TestModel.Draw();
		//ModelMatrix = glm::mat4(1.0);

        // end the current frame (internally swaps the front and back buffers)
        window.display();
    }

    // release resources...
	
    return 0;
}