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


C++ VertexList::add方法代码示例

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


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

示例1: CreatePath

iGraphic* CreatePath(float fromx,float fromy, float fromz, 
		   float tox,float toy, float toz){
    VertexList<Vertex>* vertexList = 
     (VertexList<Vertex>*)CreateVertexList<Vertex>(LINE_LIST, 1);
        vertexList->add(Vertex(Vector((float)fromx, (float)fromy, (float)fromz),Vector( 0, 1, 0)));
		vertexList->add(Vertex(Vector((float)tox, (float)toy, (float)toz),Vector( 0, 1, 0)));
	return vertexList;
}
开发者ID:cathyatseneca,项目名称:gam671-astar,代码行数:8,代码来源:Graphic.cpp

示例2: CreateGrid

// CreateGrid builds a grid-like line list of n by n lines in the x-z plane
//
iGraphic* CreateGrid(float min, float max, int n) {
    
    VertexList<Vertex>* vertexList = 
     (VertexList<Vertex>*)CreateVertexList<Vertex>(LINE_LIST, 2*n+2);

    float x = (min + max) / 2;
    min -= x;
    max -= x;
    float cur = min, inc = (max - min) / float(n - 1);
    for (int i = 0; i < n; i++, cur += inc) {
        // in the local x direction
        vertexList->add(Vertex(Vector(min, 0, cur), Vector(0, 1, 0)));
        vertexList->add(Vertex(Vector(max, 0, cur), Vector(0, 1, 0)));
        // in the local z direction
        vertexList->add(Vertex(Vector(cur, 0, min), Vector(0, 1, 0)));
        vertexList->add(Vertex(Vector(cur, 0, max), Vector(0, 1, 0)));
    }

    return vertexList;
}
开发者ID:cathyatseneca,项目名称:gam671-astar,代码行数:22,代码来源:Graphic.cpp

示例3: TriangleList

// TriangleList reads a triangle list from file
//
iGraphic* TriangleList(const wchar_t* file, const Colour& colour) {
    
    iGraphic* graphic = nullptr;

	// construct filename with path
	int len = strlen(file) + strlen(ASSET_DIRECTORY) + 1;
	wchar_t* absFile = new wchar_t[len + 1];
	::nameWithDir(absFile, ASSET_DIRECTORY, file, len);

    // open file for input
    std::wifstream in(absFile, std::ios::in);
    delete [] absFile;

    float x, y, z, xc = 0, yc = 0, zc = 0;
    unsigned no = 0;

    // count the number of records
    while (in) { 
        in >> x >> y >> z;
        xc += x;
        yc += y;
        zc += z;
        no++;
    }
    in.clear();
    in.seekg(0);
    if (no) {
        VertexList<LitVertex>* vertexList = 
         (VertexList<LitVertex>*)CreateVertexList<LitVertex>(TRIANGLE_LIST, no);
        xc /= no;
        yc /= no;
        zc /= no;
        for (unsigned i = 0; i < no; i++) {
            in >> x >> y >> z;
            vertexList->add(LitVertex(Vector(x - xc, y - yc, (z - zc) * MODEL_Z_AXIS), 
                colour));
        }
        graphic = vertexList;
    }
    
    return graphic;
}
开发者ID:cathyatseneca,项目名称:gam671-astar,代码行数:44,代码来源:Graphic.cpp

示例4: streamSubmesh

	//bool MeshXMLExporter::streamSubmesh(std::ostream &of, IGameNode *node, std::string &mtlName) {
	bool MeshXMLExporter::streamSubmesh(std::ostream &of, IGameObject *obj, std::string &mtlName) {
		
		//IGameObject* obj = node->GetIGameObject();
		if (obj->GetIGameType() != IGameMesh::IGAME_MESH)
			return false;

		// InitializeData() is important -- it performs all of the WSM/time eval for us; no face data without it
//		obj->InitializeData();
		IGameMesh* mesh = (IGameMesh*) obj;
		int vertCount = mesh->GetNumberOfVerts();
		int faceCount = mesh->GetNumberOfFaces();

		Tab<int> matIds = mesh->GetActiveMatIDs();
		Tab<DWORD> smGrpIds = mesh->GetActiveSmgrps();
		Tab<int> texMaps = mesh->GetActiveMapChannelNum();

		of << "\t\t<submesh ";
		
		if (mtlName.length() > 0)
			of << "material=\"" << mtlName << "\" ";

		of << "usesharedvertices=\"false\" use32bitindexes=\"";
		of << (vertCount > 65535);
		of << "\">" << std::endl;

		// *************** Export Face List ***************
		of << "\t\t\t<faces count=\"" << faceCount << "\">" << std::endl;

		//std::vector<UVVert

		// iterate the face list, putting vertices in the list for this submesh
		VertexList vertexList;

		for (int i=0; i<faceCount; i++) {

			of << "\t\t\t\t<face";
			FaceEx* face = mesh->GetFace(i);

			// do this for each vertex on the face
			for (int vi=0; vi<3; vi++) {
				Point3 p = mesh->GetVertex(face->vert[vi]);

				Vertex v(p.x, p.y, p.z);

				if (m_config.getExportVertexColours()) {
					Point3 c = mesh->GetColorVertex(face->vert[vi]);
					float a = mesh->GetAlphaVertex(face->vert[vi]);

					v.setColour(c.x, c.y, c.z, a);
				}

				Point3 n = mesh->GetNormal(face, vi);
				v.setNormal(n.x, n.y, n.z);

				// get each set of texcoords for this vertex
				for (int ch=0; ch < texMaps.Count(); ch++) {

					Point3 tv;
					DWORD indices[3];

					if (mesh->GetMapFaceIndex(texMaps[ch], i, indices))
						tv = mesh->GetMapVertex(texMaps[ch], indices[vi]);
					else
						tv = mesh->GetMapVertex(texMaps[ch], face->vert[vi]);

					v.addTexCoord(texMaps[ch], tv.x, tv.y, tv.z);
				}

				int actualVertexIndex = vertexList.add(v);

				of << " v" << vi + 1 << "=\"" << actualVertexIndex << "\"";
			}
 
			of << " />" << std::endl;
		}

		of << "\t\t\t</faces>" << std::endl;
		// *************** End Export Face List ***************


		// *************** Export Geometry ***************
		of << "\t\t\t<geometry vertexcount=\"" << vertexList.size() << "\">" << std::endl;

		// *************** Export Vertex Buffer ***************
		bool exportNormals = true;

		of << std::boolalpha;
		of << "\t\t\t\t<vertexbuffer positions=\"true\" normals=\"" << exportNormals << "\" colours_diffuse=\"" << m_config.getExportVertexColours() << "\" texture_coords=\"" << texMaps.Count() << "\"";
		
		for (int i=0; i<texMaps.Count(); i++)
			of << " texture_coords_dimensions_" << i << "=\"2\"";
		
		of << ">" << std::endl;

		int numVerts = vertexList.size();
		for (int i=0; i < numVerts; i++) 
		{
			const Vertex& v = vertexList.front();

//.........这里部分代码省略.........
开发者ID:sdfwds4,项目名称:ogre3d-game-editor,代码行数:101,代码来源:OgreMaxMeshXMLExport.cpp


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