当前位置: 首页>>代码示例>>C++>>正文


C++ Costume::init方法代码示例

本文整理汇总了C++中Costume::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Costume::init方法的具体用法?C++ Costume::init怎么用?C++ Costume::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Costume的用法示例。


在下文中一共展示了Costume::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

//--------------------------------------------------------------
void ofApp::load(){

	this->splashScreen.init("splashScreen.jpg"); 
	this->splashScreen.begin(); 

	//populate costumesLib map by going through venues directory recursively
	//only works if the names of the files are exactly the same as those inside bonePairs in Costume.cpp
	//will skip over missing files and simply not draw them
	std::string venuesPath = "venues/";
	ofDirectory venues(venuesPath);
	venues.listDir();
	//open venues dir
	for(int i=0; i<venues.numFiles(); i++) {
		ofDirectory venue(venues.getPath(i));
		if(venue.isDirectory()) {
			venue.listDir();
			 //open each venue dir
			for(int j=0;j< venue.numFiles();j++) {
				ofDirectory costume(venue.getPath(j));
				if(costume.isDirectory()) {
					//for each costume:
					//costume.allowExt("dae"); //only look at .dae files (ie ignore texture files)
					costume.listDir();
					std::string cos; //initialize string to name the costume (will get the name late from the absolute path of each file so we have fewer calls to ofSplitString
					std::vector<Segment> segs; //create a vector of segments for each costume that we will populate
					 //open each costume inside each venue
					for(int k=0; k<costume.numFiles();k++) {
						ofDirectory part(costume.getPath(k));
						//initialize model loader for each model
						ofxAssimpModelLoader model; 
						part.allowExt("dae");
						part.listDir();
						//load each .dae file
						model.loadModel(part.getPath(0), true);
						//save the meshes and textures for each file into blocks
						vector<std::pair<ofMesh, ofTexture>> blocks;
						for(int l=0;l<model.getMeshCount();l++) {
							ofMesh mesh = model.getMesh(l); //get each mesh
							ofTexture tex = model.getTextureForMesh(l); //get each texture
							std::pair<ofMesh, ofTexture> block = make_pair(mesh, tex); //associate the two values
							blocks.push_back(block); //add it to blocks vector
						}
						//sort name of each costume out
						vector<std::string> splitString = ofSplitString(costume.getPath(k), "\\"); //split path string on "\" to get venue and costume names
						cos = splitString[2];
						std::vector<std::string> splitPart = ofSplitString(splitString[3], "."); //get the nameof the body part by splitting the string on "." to remove .dae extension
						std::string partName = splitPart[0];
						std::pair<std::string, std::string> pair = std::make_pair(cos, partName);
						//initialize segment with meshes textures and location
						Segment seg;
						seg.init(blocks, partName);
						segs.push_back(seg); //populate segs vector for this costume
						segmentsLib[pair] = seg; // populate segments map for random costumes
					}
					//for each costume create a costume, initialize it with the loaded segments and save it to the costumesLib
					Costume costume;
					costume.init(cos);
					costumesLib[cos] = costume;
					preloadedCostumes.push_back(cos);
				}
			}
		}
	}
	cout<<"List of all "<<costumesLib.size()<<" loaded costumes:"<<endl;
	int i=1;
	map<std::string, Costume>::iterator cos;
	for(cos = costumesLib.begin(); cos != costumesLib.end(); cos++) {
		cout<<i<<": "<<cos->first<<endl;
		i++;
	}
	this->splashScreen.end(); 
	loaded = true;
}
开发者ID:Bentleyj,项目名称:Circulate,代码行数:74,代码来源:ofApp.cpp


注:本文中的Costume::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。