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


C++ MeshData类代码示例

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


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

示例1: makeRectangle

    MeshData MeshUtils::makeRectangle(vec3 v0, vec3 v1, vec3 v2, vec3 v3,
            vec3 t0, vec3 t1, vec3 t2, vec3 t3) {


        MeshData m;
        //m.create();

        vec3 n = glm::cross(v0 - v1, v2 - v0); //to do: double check direction...
        n = glm::normalize(n);

        const vec3 vs[] = { v0, v1, v2, v3 };
        const vec3 ns[] = { n, n, n, n };
        const vec3 ts[] = { t0, t1, t2, t3 };
        const unsigned int indices[] = { 0,1,2, 2,1,3 };
        //static const unsigned int indices[] = { 0,1,2, 1,2,3 };

        m.vertex(vs, 4);
        m.normal(ns, 4);
        m.texCoord(ts, 4);
        m.index(indices, 6);
     /*
      cout << "v0 : " << to_string(vs[0]) << "\n";
      cout << "v1 : " << to_string(vs[1]) << "\n";
      cout << "v2 : " << to_string(vs[2]) << "\n";
      cout << "v3 : " << to_string(vs[3]) << "\n";

      cout << "n0 : " << to_string(ns[0]) << "\n";
      cout << "n1 : " << to_string(ns[1]) << "\n";
      cout << "n2 : " << to_string(ns[2]) << "\n";
      cout << "n3 : " << to_string(ns[3]) << "\n";
     // exit(0);
      */
      return m;
    }
开发者ID:CreativeCodingLab,项目名称:aluminum,代码行数:34,代码来源:MeshUtils.cpp

示例2: CreateScreenQuad

void								CreateScreenQuad(
	MeshData&							Quad)
{
	AttribData<vec3> Vertices(4);
	Vertices.Set(0, vec3(-1.0f, -1.0f,  0.0f));
	Vertices.Set(1, vec3( 1.0f, -1.0f,  0.0f));
	Vertices.Set(2, vec3( 1.0f,  1.0f,  0.0f));
	Vertices.Set(3, vec3(-1.0f,  1.0f,  0.0f));

	AttribData<vec2> TexCoords(4);
	TexCoords.Set(0, vec2(0.0f, 0.0f));
	TexCoords.Set(1, vec2(1.0f, 0.0f));
	TexCoords.Set(2, vec2(1.0f, 1.0f));
	TexCoords.Set(3, vec2(0.0f, 1.0f));

	AttribData<GLFace16> Faces(2);
	Faces.Set(0, GLFace16(0, 1, 2) );
	Faces.Set(1, GLFace16(2, 3, 0) );
	
	Polygons Polylist1;
	Polylist1.SetMaterial(0);
	Polylist1.SetFaces(Faces);

	AttribData<poly> Polygons(1);
	Polygons.Set(0, Polylist1);

	Quad.SetVertexArray(Vertices);
	Quad.SetUVArray(TexCoords);
	Quad.SetPolygonList(Polygons);
	Quad.GenerateNormals(false);
	Quad.GenerateTangents();
}
开发者ID:TimelessVisions,项目名称:GLEngine,代码行数:32,代码来源:GLData.cpp

示例3: MeshData

MeshData *TetGenCaller::CopyTetMesh(tetgenio *io)
{
    MeshData *NewMesh = new MeshData(this->Mesh->BoundingBox);

    // Add vertices
    for (int i = 0; i < io->numberofpoints; i++) {
        double *c;
        c = &io->pointlist[3 * i];
        NewMesh->VertexOctreeRoot->AddVertex(c[0], c[1], c[2]);
    }

    // Add triangles
    for (int i = 0; i < io->numberoftrifaces; i++) {
        int *triface;
        int marker = io->trifacemarkerlist[i];
        triface = &io->trifacelist[3 * i];
        TriangleType *t = NewMesh->AddTriangle({triface[0], triface[1], triface[2]});
        t->InterfaceID = marker;
    }

    // Add tetrahedrons
    for (int i = 0; i < io->numberoftetrahedra; i++) {
        int *tet = &io->tetrahedronlist[4 * i];
        TetType *t = NewMesh->AddTetrahedron({tet[0], tet[1], tet[2], tet[3]});

        if (io->numberoftetrahedronattributes == 1) {
            int tetattr = io->tetrahedronattributelist[i];
            t->MaterialID = tetattr;
        } else {
            t->MaterialID = 0;
        }
    }

    return NewMesh;
}
开发者ID:CarlSandstrom,项目名称:Voxel2Tet,代码行数:35,代码来源:TetGenCaller.cpp

示例4: EngineOSG

void Renderer::unproject(int width, int height, string filename, MeshData &meshData, bool lighting, double* output)
{
	engine = new EngineOSG();

	double *A = new double[9];
	double *R = new double[9];
	double *T = new double[3];

	engine->setParams(width, height, NULL, NULL, filename, 0, 0,
			0, 0, false, /*NULL, NULL, NULL*/A,R,T, output, meshData, "",
			true, NULL, NULL, NULL, lighting, 50, "zxy", true);
	engine->init();

	try
	{
		if (meshData.getVertices().empty()) {
			engine->initDataFromFile();
		} else {
			engine->initData();
		}
		meshData.copy(engine->getMeshData());
		engine->initCamera();

		engine->initCanvas();

		engine->InitFrame();
	}
	catch (char const *e)
	{
		engine->shutdown();
		delete engine;
		throw e;
	}
}
开发者ID:BorenHailin,项目名称:Poses,代码行数:34,代码来源:renderer.cpp

示例5: UpdateShader

bool DirectxEngine::UpdateShader(const MeshData& mesh, 
                                 const IScene& scene,
                                 bool alphaBlend, 
                                 float timer)
{
    const int index = mesh.ShaderID();
    if (index != NO_INDEX)
    {
        auto& shader = m_data->shaders[index];
        if(index != m_data->selectedShader)
        {
            SetSelectedShader(index);
            SendLights(scene.Lights());
            shader->UpdateConstantMatrix("viewProjection", m_data->viewProjection);
            shader->UpdateConstantFloat("cameraPosition", &m_data->cameraPosition.x, 3);
            shader->UpdateConstantFloat("depthNear", &scene.Post().DepthNear(), 1);
            shader->UpdateConstantFloat("depthFar", &scene.Post().DepthFar(), 1);

            if (index == WATER_SHADER)
            {
                shader->UpdateConstantFloat("timer", &timer, 1);
            }
        }

        SendTextures(mesh.TextureIDs());
        SetRenderState(mesh.BackfaceCull(), m_data->isWireframe);
        EnableAlphaBlending(alphaBlend, false);
        return true;
    }
    return false;
}
开发者ID:,项目名称:,代码行数:31,代码来源:

示例6: addPoint

  void MeshUtils::addPoint(MeshData &m, vec3 v) {

    const vec3 vs[] = { v };
    unsigned int off = (unsigned int) m.indices().size();

    const unsigned int indices[] = { off };

    m.vertex(vs, 1);
    m.index(indices, 1);
  }
开发者ID:CreativeCodingLab,项目名称:aluminum,代码行数:10,代码来源:MeshUtils.cpp

示例7: makeGrid

    MeshData MeshUtils::makeGrid(int cols, int rows, vec2 vLL, vec2 vUR) { //needs to be rendered via drawTriangleStrip


        float xl = vLL.x;
        float yl = vLL.y;
        float xu = vUR.x;
        float yu = vUR.y;


        MeshData m;
        vec3* vs = new vec3[cols * rows];
        GLuint* is = new GLuint [(cols*2*(rows-1)+2*(rows-2))];


        for (int y =0; y<rows; y++) {
            for (int x=0; x < cols ; x++) {

                vs[cols*y+x].x= xl +x*(xu-xl)/(float)(cols-1.0);
                vs[cols*y+x].y= yl +y*(yu-yl)/(float)(rows-1.0);
                vs[cols*y+x].z = 0.0f;

            }
        }

        // Index data

        int q = 0;

        for (int y =0; y<rows-1; y++) {
            for (int x=0; x < cols ; x++) {
                is[q] = x + y*cols;
                q++;
                is[q] = x + (y+1)*cols;
                q++;
            }
            if( y < rows-2){ // the degenerate triangles

                //repeating last one
                is[q] = (cols-1) + (y+1)*cols;
                q++;
                //repeating next one
                is[q] =  (y+1)*cols;
                q++;
            }

        }

        m.vertex(vs,cols*rows);
        m.index(is, cols*2*(rows-1)+2*(rows-2));

        delete vs;
        delete is;

        return m;
    }
开发者ID:CreativeCodingLab,项目名称:aluminum,代码行数:55,代码来源:MeshUtils.cpp

示例8: GetNextItem

void DataListCtrl::EndEdit(bool update)
{
	if (!m_rename_text->IsShown())
		return;

	if (update)
	{
		wxString new_name = m_rename_text->GetValue();

		long item = GetNextItem(-1,
			wxLIST_NEXT_ALL,
			wxLIST_STATE_SELECTED);
		VRenderFrame* vr_frame = (VRenderFrame*)m_frame;
		DataManager* mgr = vr_frame?vr_frame->GetDataManager():0;

		if (item != -1 && mgr)
		{
			wxString name = GetText(item, 1);

			if (new_name != name)
			{
				wxString new_name2 = new_name;
				for (int i=1; mgr->CheckNames(new_name2); i++)
					new_name2 = new_name+wxString::Format("_%d", i);


				if (GetItemText(item) == "Volume")
				{
					VolumeData* vd = mgr->GetVolumeData(name);
					if (vd)
						vd->SetName(new_name2);
				}
				else if (GetItemText(item) == "Mesh")
				{
					MeshData* md = mgr->GetMeshData(name);
					if (md)
						md->SetName(new_name2);
				}
				else if (GetItemText(item) == "Annotations")
				{
					Annotations* ann = mgr->GetAnnotations(name);
					if (ann)
						ann->SetName(new_name2);
				}

				//update ui
				SetText(item, 1, new_name2);
				vr_frame->UpdateTree();
			}
		}
	}

   m_rename_text->Hide();
}
开发者ID:takashi310,项目名称:VVD_Viewer,代码行数:54,代码来源:ListPanel.cpp

示例9: oht_assert_threadmodel

	void DynamicRenderable::wipeBuffers()
	{
		oht_assert_threadmodel(ThrMdl_Single);
		// TODO: Is this necessary now that we employ latent render operations?
		_renderOp.vertexData->vertexBufferBinding->unsetAllBindings();
		for (size_t l = 0; l < getNumLevels(); ++l)
		{
			MeshData * pMeshData = _pvMeshData[l];

			if (pMeshData != NULL)
				pMeshData->clear();
		}
	}
开发者ID:thejasonfisher,项目名称:OhTSM,代码行数:13,代码来源:DynamicRenderable.cpp

示例10: create

Mesh* Mesh::create(const std::vector<float>& vertices, int perVertexSizeInFloat, const IndexArray& indices, const std::vector<MeshVertexAttrib>& attribs)
{
    MeshData meshdata;
    meshdata.attribs = attribs;
    meshdata.vertex = vertices;
    meshdata.subMeshIndices.push_back(indices);
    meshdata.subMeshIds.push_back("");
    auto meshvertexdata = MeshVertexData::create(meshdata);
    auto indexbuffer = IndexBuffer::create(IndexBuffer::IndexType::INDEX_TYPE_SHORT_16, (int)indices.size());
    
    AABB aabb = MeshVertexData::calculateAABB(meshdata.vertex, meshdata.getPerVertexSize(), indices);
    auto indexData = MeshIndexData::create("", meshvertexdata, indexbuffer, aabb);
    
    return create("", indexData);
}
开发者ID:fdmjyoshi3,项目名称:cocos2d-x,代码行数:15,代码来源:CCMesh.cpp

示例11: Append

	void GeometryBufferData::Append(MeshData data)
	{
		IndexOffsetData appendData;
		appendData.baseVertexOffset = vertices.size();
		appendData.baseIndexOffset = indices.size();
		appendData.indexCount = data.indices.size();

		if (data.getId() >= indexData.size())
		{
			indexData.resize(data.getId() + 10);
		}

		indexData[data.getId()] = appendData;

		vertices.insert(vertices.end(), data.vertices.begin(), data.vertices.end());
		indices.insert(indices.end(), data.indices.begin(), data.indices.end());
	}
开发者ID:jysandy,项目名称:dx11lib,代码行数:17,代码来源:GeometryBufferData.cpp

示例12: AssimpProcessScene

MeshData ResourceManager::AssimpProcessScene(aiNode* node, const aiScene* scene)
{
	MeshData data;

	for (UINT i = 0; i < node->mNumMeshes; i++)
	{
		aiMesh* mesh = scene->mMeshes[i];
		data.Append(AssimpProcessMesh(mesh, scene));
	}

	for (UINT i = 0; i < node->mNumChildren; i++)
	{
		AssimpProcessScene(node->mChildren[i], scene);
	}

	return data;
}
开发者ID:ariabonczek,项目名称:LuminaEngine_OLD,代码行数:17,代码来源:ResourceManager.cpp

示例13: loadMeshData

MeshData* loadMeshData(const char* filename){

	char* aux = strchr (filename, '.');
	aux++;
	MeshData *ret;
	if ((strcmp (aux, "md2") == 0) || (strcmp (aux, "MD2") == 0)){
        ret = new MD2Obj();
        ret->load(filename);
        ret->setMeshType(MD2MESH);
        return ret;
	}else if ((strcmp (aux, "obj") == 0) || (strcmp (aux, "OBJ") == 0)){
		ret = new ObjData();
        ret->load(filename);
        ret->setMeshType(OBJMESH);
        return ret;
	}
	return NULL;
	
}
开发者ID:BackupTheBerlios,项目名称:lutaprakct,代码行数:19,代码来源:meshData.cpp

示例14: addTriangle

   void MeshUtils::addTriangle(MeshData &m, vec3 v0, vec3 v1, vec3 v2,
                                   vec3 t0, vec3 t1, vec3 t2) {


    vec3 n = glm::cross(v1 - v0, v2 - v0);

    const vec3 vs[] = { v0, v1, v2 };
    const vec3 ns[] = { n, n, n };
    const vec3 ts[] = { t0, t1, t2 };
    unsigned int off = (unsigned int) m.indices().size();

    const unsigned int indices[] = { off,off+1,off+2 };

    m.vertex(vs, 3);
    m.normal(ns, 3);
    m.texCoord(ts, 3);
    m.index(indices, 3);

  }
开发者ID:CreativeCodingLab,项目名称:aluminum,代码行数:19,代码来源:MeshUtils.cpp

示例15: parseVertexData

void MeshAppearanceTemplate::parseVertexData(IffStream* iffStream, int idx) {
	int formVersion = 0;'0000';// + idx;

	String idxText = String::valueOf(idx);
	int lengthOfText = idxText.length();

	for (int i = 0; i < 4 - lengthOfText; ++i)
		idxText = "0" + idxText;

	for (int i = 0; i < 4; ++i) {
		char a = idxText.charAt(i);

		formVersion = formVersion << 8;
		formVersion += (int)a;
	}

	iffStream->openForm(formVersion);

	iffStream->openChunk('NAME');

	String shaderName;
	iffStream->getString(shaderName);

	iffStream->closeChunk();

	iffStream->openChunk('INFO');
	iffStream->closeChunk();

	uint32 nextVersion = iffStream->getNextFormType();
	iffStream->openForm(nextVersion);

	iffStream->openChunk('INFO');
	iffStream->closeChunk();

	MeshData meshData;
	meshData.readObject(iffStream);
	meshes->add(meshData);

	iffStream->closeForm(nextVersion);

	iffStream->closeForm(formVersion);
}
开发者ID:Mesagoppinmypants,项目名称:Tools,代码行数:42,代码来源:MeshAppearanceTemplate.cpp


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