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


C++ Quad::sVert方法代码示例

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


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

示例1: SharkVertex

Keyframe::Keyframe(map<Vector3f, SharkVertex*, compareVect3> *rawVerts, vector<Quad*> *rawFaces)
{
	//deep copy verts over.
	map<Vector3f, SharkVertex*, compareVect3>::iterator im;
	for(im = rawVerts->begin(); im != rawVerts->end(); im++)
	{
		pair<Vector3f, SharkVertex*> serk = *im;
		SharkVertex * d = new SharkVertex();
		d->sNormal(serk.second->gNormal());
		d->sTransformed(serk.second->gTransformed());
		d->sLocal(serk.second->gLocal());
		uVertices.insert(pair<Vector3f, SharkVertex*>(serk.first, d));
	}

	//create faces.
	vector<Quad*>::iterator iq;
        for(iq = rawFaces->begin(); iq != rawFaces->end(); iq++)
        {
		Quad * nRect = new Quad();
		for(int i = 0; i < 4; i++)
		{
			nRect->sVert(i, uVertices.find((*iq)->gLocalVert(i))->second);
		}
		faces.push_back(nRect);
	}

	//setNormals
	createQuads();
}
开发者ID:KATHYxx,项目名称:SharkSim,代码行数:29,代码来源:Keyframe.cpp

示例2: segmentMatrixMake

/*Subroutine of transformHeiararchy(), this function calculates the position and rotation for a given bone segment and 
* generates quaderlaterals with those transformations */
void Keyframe::segmentMatrixMake( GLfloat segmentRot[], GLfloat segLength[], Mesh *mesh, int segments, glQuaternion *glQuat, int curSegment, 
		MyMat *stackMatrix, float start, float end, int isDownstream)
{
	double rotate = segmentRot[curSegment];                  //get rotation of current segment
	                                   //current shark model segment
	MyMat Matrix = *stackMatrix;
	MyMat transrix;
	transrix.makeTranslate(Vector3f((isDownstream == 2 ? segLength[curSegment] : -segLength[curSegment]), 0, 0));	
	MyMat secondStack = MyMat();
	GLfloat glm[16];
	
	glQuat->CreateFromAxisAngle(0,1,0,isDownstream == 2? -rotate : rotate);
	glQuat->CreateMatrix(glm); 
	MyMat rotatrix = MyMat(glm[0], glm[4], glm[8], glm[12], glm[1], glm[5],glm[9],
			glm[13],glm[2],glm[6],glm[10],glm[14],glm[3],glm[7],
			glm[11],glm[15]);

	Matrix = Matrix.multRight(rotatrix); //roatation goes before translates
	Matrix = Matrix.multRight(transrix); //doesnt matter which order translates are done

	*stackMatrix = Matrix; //advance heirarchy
	MyMat transrix2;
	transrix2.makeTranslate(Vector3f(isDownstream == 2? -end : -start, 0, 0));
	Matrix = Matrix.multRight(transrix2);
	//------------------------------------ 
	float center;
	for(int in = 0; in < mesh->vertCounter; in+=4)
	{
		//find center of face
		center = (mesh->vertList[in].x + mesh->vertList[in+1].x + mesh->vertList[in+2].x 
				+ mesh->vertList[in+3].x ) / 4;
		//draw if face is between start and end
		if(center >= start && center <= end )
		{
			Quad *curQuad = new Quad();
			curQuad->gNormal() = Vector3f(0,0,0);
			for(int corn = 0; corn < 4; corn++) //corner iteration
			{
				SharkVertex *curVert = new SharkVertex();   //current vertex
				curVert->local = mesh->vertList[in+corn];   //setting untransformed vertex
				curVert->transformed = Vector3f(Matrix.multVec(mesh->vertList[in+corn], true)); //setting transformed vertex
				curVert->normal = Vector3f(0,0,0);	//normal of the vertex, away from mesh			
				map<Vector3f, SharkVertex*, compareVect3>::iterator findTest 
					= uVertices.find(mesh->vertList[in+corn]);   //checking to see if vertex is already in the list.
				if(findTest == uVertices.end()) 
				{ 
					//vertex not in list. Add it to the list and to the quad.
					uVertices.insert(pair<Vector3f, SharkVertex*>(mesh->vertList[in+corn]
								, curVert));	
					curQuad->sVert(corn, curVert);
				}
				else   //vertex is in the list, so it's added to the existing quad.
				{
					delete curVert;
					curQuad->sVert(corn, (*findTest).second);
				}
				curQuad->gNormal() += Matrix.multVec(mesh->normals[in+corn], false);  //setting normal of the face
				
			}//end corners
			curQuad->gNormal() /= 4.0; //take average of normals to get the actual normal.
			curQuad->sBoneNo(curSegment); //record the bone this quad belongs to the most.
			faces.push_back(curQuad);
		}//end if
	}//end quads 

}
开发者ID:KATHYxx,项目名称:SharkSim,代码行数:68,代码来源:Keyframe.cpp

示例3: buildAOBJ

void SharkMesh::buildAOBJ(FILE* readFile) {
	vector<Vector3f> localVerts = vector<Vector3f>();   //in order to use OBJs as keys, need to remember their order.
	while(!feof(readFile)) {
		//tokenize the line identifier. It's only one character and 
		//it should be on the first on the line
		char identifier = fgetc(readFile);
		if(ferror(readFile)){ 
		   printf("888888888Error reading FILE\n"); 
		   exit(-1);
		}

		//load in the vertices
		//v x y z nx ny nz boneName/weight boneName/weight ...
		if(identifier == 'v') {
			char cur = fgetc(readFile);  //space
			if(ferror(readFile)) { 
			   printf("0Error reading FILE\n"); 
			   exit(-1);
			}
			while(cur != '\n') { // per line
				SharkVertex* sv = new SharkVertex();

				//location of vertex    
				Vector3f vert;
				vert.x = atof(nextToken(' ', readFile).c_str());
				vert.y = atof(nextToken(' ', readFile).c_str());
				vert.z = atof(nextToken(' ', readFile).c_str());
				sv->sLocal(vert);

				Vector3f nor; //normal
				nor.x = atof(nextToken(' ', readFile).c_str());
				nor.y = atof(nextToken(' ', readFile).c_str());
				nor.z = atof(nextToken(' ', readFile).c_str());
				sv->sNormal(nor*-1.0);  //TODO magic.  fix blender normals. shouldn't need to reverse them.

				sv->sTransformed(Vector3f(0,0,0));
				//bone / weight repeats
				fseek(readFile, -1, SEEK_CUR);
				cur = fgetc(readFile);
				while(cur != '\n') {
					string boneName = nextToken('/', readFile);
					float weight = atof(nextToken(' ', readFile).c_str());
					sv->sBonePair(boneName, weight);
					fseek(readFile, -1, SEEK_CUR);
					cur = fgetc(readFile);
				}
				localVerts.push_back(vert);
				insertVec(pair<Vector3f, SharkVertex*>(vert, sv));
			}
		}
		//faces
		//f ... vertices in mesh .....
		else if(identifier == 'f') {
			char cur = fgetc(readFile); //space
			if(ferror(readFile)){ printf("4Error reading FILE\n"); exit(-1);}
			Quad *curQuad = new Quad();
			curQuad->sNormal(Vector3f(0,0,0));

			//caution. Vertices listed in mesh may not be consistant with other quads 
			int vertex1 = atoi(nextToken(' ', readFile).c_str());
			int vertex2 = atoi(nextToken(' ', readFile).c_str());
			int vertex3 = atoi(nextToken(' ', readFile).c_str());
			int vertex4 = atoi(nextToken(' ', readFile).c_str());

			curQuad->sVert(0, gVertex(localVerts[vertex1-1]));
			curQuad->sVert(1, gVertex(localVerts[vertex2-1]));
			curQuad->sVert(2, gVertex(localVerts[vertex3-1]));
			curQuad->sVert(3, gVertex(localVerts[vertex4-1]));
			curQuad->calcNormal();

			pushFace(curQuad);	
			//neighboring quads are to be found later, after parsing is done.

			fseek(readFile, -1, SEEK_CUR);
			cur = fgetc(readFile);
			while(cur != '\n') {
				cur = fgetc(readFile);
				if(ferror(readFile)) { 
				   printf("5Error reading FILE\n"); 
				   exit(-1);
				}
			}
		}		
		else if(identifier == 'b') {
			return;
		}
	}
}
开发者ID:mejanly,项目名称:Sharkify,代码行数:88,代码来源:SharkMesh.cpp


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