• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Mesh函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: switch

Shape Shape::createShape(
	ShapeType type,
	float size /* = 1.0f */,
	float texturing /* = 2.0f */,
	int resolution /* = 16 */,
	float width /* = 0.0f */,
	float height /* = 0.0f */,
	float depth /* = 0.0f */)
{
	this->setSize(size);
	this->setResolution(resolution);

	switch (type)
	{
	case SPHERE:
		this->setVertices(createSphere(size, resolution, true));
		break;
	case PYRAMID:
		this->setVertices(createPyramid(size, texturing));
		break;
	case TETRAHEDRON:
		this->setVertices(createTetrahedron(size, texturing));
		break;
	case CUBOID:
		this->setVertices(createCuboid(size, width, height, depth, texturing));
		break;
	default:

		break;
	}

	this->setMesh(Mesh(this->m_vertices, this->m_vertices.size()));

	return *(this);
}
开发者ID:freakysevenup,项目名称:NewEngine,代码行数:35,代码来源:Shape.cpp


示例2: Mesh

//-----------------------------------------------------------------------
Resource* MeshManager::createImpl(const String& name, ResourceHandle handle,
                                  const String& group, bool isManual, ManualResourceLoader* loader,
                                  const NameValuePairList* createParams)
{
    // no use for createParams here
    return OGRE_NEW Mesh(this, name, handle, group, isManual, loader);
}
开发者ID:LiberatorUSA,项目名称:GUCEF,代码行数:8,代码来源:OgreMeshManager.cpp


示例3: Mesh

/** @brief Update memory using the Transfer object */
void TRMTransportAnalysis::UpdateMemory(){
    
    Mesh()->LoadSolution(fX);
    TPZBuildMultiphysicsMesh::TransferFromMultiPhysics(fmeshvec, Mesh());
    
    // Volumetric update
    if (fSimulationData->IsTwoPhaseQ()) {
        fTransfer->s_To_Transport_Memory(fmeshvec[0], Mesh(),0);
    }

    // Volumetric update
    if (fSimulationData->IsThreePhaseQ()) {
        fTransfer->s_To_Transport_Memory(fmeshvec[0], Mesh(),0);        
        fTransfer->s_To_Transport_Memory(fmeshvec[1], Mesh(),1);
    }
    
}
开发者ID:labmec,项目名称:neopz,代码行数:18,代码来源:TRMTransportAnalysis.cpp


示例4: Attribute

// ------------------------------------
GeomAttr::GeomAttr() :
// ------------------------------------
	Attribute(EATTR_GEOM),
	m_shape(GEOM_SQUARE),
	m_bound(Box(Vector2(-0.5, -0.5), Vector2(1, 1)))
{
	m_mesh = Mesh(m_bound);
}
开发者ID:cliclcly,项目名称:oxalo,代码行数:9,代码来源:eAttribute.cpp


示例5: loadMeshIntoMeshGroup

bool loadMeshIntoMeshGroup(MeshGroup* meshgroup, const char* filename, const FMatrix3x3& transformation, SettingsBaseVirtual* object_parent_settings)
{
    TimeKeeper load_timer;

    const char* ext = strrchr(filename, '.');
    if (ext && (strcmp(ext, ".stl") == 0 || strcmp(ext, ".STL") == 0))
    {
        Mesh mesh = object_parent_settings ? Mesh(object_parent_settings) : Mesh(meshgroup); //If we have object_parent_settings, use them as parent settings. Otherwise, just use meshgroup.
        if(loadMeshSTL(&mesh,filename,transformation)) //Load it! If successful...
        {
            meshgroup->meshes.push_back(mesh);
            log("loading '%s' took %.3f seconds\n",filename,load_timer.restart());
            return true;
        }
    }
    return false;
}
开发者ID:Robo3D,项目名称:CuraEngine,代码行数:17,代码来源:MeshGroup.cpp


示例6: is

Scene Scene::load(const std::string &filename, const json11::Json &settings) {
    std::ifstream is(filename);
    std::stringstream ss;
    ss << is.rdbuf();

    std::string err;
    Json jsonRoot = Json::parse(ss.str(), err);
    if (jsonRoot.is_null()) {
        throw Exception("Failed to load scene from '%s' (error: %s)", filename, err);
    }

    _resolver = filesystem::resolver();
    _resolver.prepend(filesystem::path(filename).parent_path());

    Scene scene;

    // Patch settings
    auto settingsValues = jsonRoot["settings"].object_items();
    for (auto kv : settings.object_items()) {
        settingsValues[kv.first] = kv.second;
    }
    scene.settings = Properties(json11::Json(settingsValues));

    // Parse scene objects
    Json jsonScene = jsonRoot["scene"];
    if (jsonScene.is_object()) {
        auto jsonCamera = jsonScene["camera"];
        if (jsonCamera.is_object()) {
            Properties props(jsonCamera);
            scene.camera = Camera(jsonCamera);
        }
        auto jsonWorld = jsonScene["world"];
        if (jsonWorld.is_object()) {
            Properties props(jsonWorld);
            scene.world = World(jsonWorld);
        }
        for (auto jsonBox : jsonScene["boxes"].array_items()) {
            scene.boxes.emplace_back(Box(Properties(jsonBox)));
        }
        for (auto jsonSphere : jsonScene["spheres"].array_items()) {
            scene.spheres.emplace_back(Sphere(Properties(jsonSphere)));
        }
        for (auto jsonMesh : jsonScene["meshes"].array_items()) {
            scene.meshes.emplace_back(Mesh(Properties(jsonMesh)));
        }
        for (auto jsonCameraKeyframe : jsonScene["cameraKeyframes"].array_items()) {
            scene.cameraKeyframes.emplace_back(Camera(Properties(jsonCameraKeyframe)));
        }
        // Set default camera
        if (!jsonCamera.is_object()) {
            Vector3f center = scene.world.bounds.center();
            scene.camera.position += center;
            scene.camera.target += center;
        }
    }

    return scene;
}
开发者ID:Seashell2011,项目名称:pbsproject,代码行数:58,代码来源:Scene.cpp


示例7: Mesh

Mesh Model::processMesh(aiMesh * mesh, const aiScene * scene)
{
	std::vector<Vertex> vertices;
	std::vector<GLuint> indices;
	std::vector<Texture> textures;

	// process vertices
	for (GLuint i = 0; i < mesh->mNumVertices; i++)
	{
		Vertex vertex;

		vertex.position.x = mesh->mVertices[i].x;
		vertex.position.y = mesh->mVertices[i].y;
		vertex.position.z = mesh->mVertices[i].z;

		vertex.normal.x = mesh->mNormals[i].x;
		vertex.normal.y = mesh->mNormals[i].y;
		vertex.normal.z = mesh->mNormals[i].z;

		if (mesh->mTextureCoords[0])
		{
			vertex.texCoords.x = mesh->mTextureCoords[0][i].x;
			vertex.texCoords.y = mesh->mTextureCoords[0][i].y;
		}
		else
		{
			vertex.texCoords = glm::vec2(0.0f, 0.0f);
		}

		vertices.push_back(vertex);
	}

	// process indices
	for (GLuint i = 0; i < mesh->mNumFaces; i++)
	{
		aiFace face = mesh->mFaces[i];
		for (GLuint j = 0; j < face.mNumIndices; j++)
		{
			indices.push_back(face.mIndices[j]);
		}
	}
	
	// process material
	if (mesh->mMaterialIndex >= 0)
	{
		aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];

		std::vector<Texture> diffuseMaps = this->loadMaterialTextures(material,
									aiTextureType_DIFFUSE, "texture_diffuse");
		textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());

		std::vector<Texture> specularMaps = this->loadMaterialTextures(material,
									aiTextureType_SPECULAR, "texture_specular");
		textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
	}

	return Mesh(vertices, indices, textures);
}
开发者ID:tiagoddinis,项目名称:GParticles,代码行数:58,代码来源:Model.cpp


示例8: bricks

void TestGame::Init(const Window& window)
{
	Material bricks("bricks", Texture("bricks.jpg"), 0.0f, 0, Texture("bricks_normal.jpg"), Texture("bricks_disp.png"), 0.03f, -0.5f);
	Material bricks2("bricks2", Texture("bricks2.jpg"), 0.0f, 0, Texture("bricks2_normal.png"), Texture("bricks2_disp.jpg"), 0.04f, -1.0f);
	
	//Material skin("humanFace", Texture("human.jpg"), 0.0f, 0, Texture("human_normal_inv.jpg"));
	//Material skin("humanFace", Texture("human.jpg"), 0.08f, 8, Texture("human_normal_inv.jpg"));

	IndexedModel square;
	{
		square.AddVertex(1.0f, -1.0f, 0.0f);  square.AddTexCoord(Vector2f(1.0f, 1.0f));
		square.AddVertex(1.0f, 1.0f, 0.0f);   square.AddTexCoord(Vector2f(1.0f, 0.0f));
		square.AddVertex(-1.0f, -1.0f, 0.0f); square.AddTexCoord(Vector2f(0.0f, 1.0f));
		square.AddVertex(-1.0f, 1.0f, 0.0f);  square.AddTexCoord(Vector2f(0.0f, 0.0f));
		square.AddFace(0, 1, 2); square.AddFace(2, 1, 3);
	}
	Mesh customMesh("square", square.Finalize());
	
	AddToScene((new Entity(Vector3f(0, -1, 5), Quaternion(), 32.0f))
		->AddComponent(new MeshRenderer(Mesh("terrain02.obj"), Material("bricks"))));
		
	AddToScene((new Entity(Vector3f(7,0,7)))
		->AddComponent(new PointLight(Vector3f(0,1,0), 0.4f, Attenuation(0,0,1))));
	
	AddToScene((new Entity(Vector3f(20,-11.0f,5), Quaternion(Vector3f(1,0,0), ToRadians(-60.0f)) * Quaternion(Vector3f(0,1,0), ToRadians(90.0f))))
		->AddComponent(new SpotLight(Vector3f(0,1,1), 0.4f, Attenuation(0,0,0.02f), ToRadians(91.1f), 7, 1.0f, 0.5f)));
	
	AddToScene((new Entity(Vector3f(), Quaternion(Vector3f(1,0,0), ToRadians(-45))))
		->AddComponent(new DirectionalLight(Vector3f(1,1,1), 0.4f, 10, 80.0f, 1.0f)));
	
	AddToScene((new Entity(Vector3f(0, 2, 0), Quaternion(Vector3f(0,1,0), 0.4f), 1.0f))
		->AddComponent(new MeshRenderer(Mesh("plane3.obj"), Material("bricks2")))
		->AddChild((new Entity(Vector3f(0, 0, 25)))
			->AddComponent(new MeshRenderer(Mesh("plane3.obj"), Material("bricks2")))
			->AddChild((new Entity())
				->AddComponent(new CameraComponent(Matrix4f().InitPerspective(ToRadians(70.0f), window.GetAspect(), 0.1f, 1000.0f)))
				->AddComponent(new FreeLook(window.GetCenter()))
				->AddComponent(new FreeMove(10.0f)))));
	
	AddToScene((new Entity(Vector3f(24,-12,5), Quaternion(Vector3f(0,1,0), ToRadians(30.0f))))
		->AddComponent(new MeshRenderer(Mesh("sphere.obj"), Material("bricks"))));
		
	AddToScene((new Entity(Vector3f(0,0,7), Quaternion(), 1.0f))
		->AddComponent(new MeshRenderer(Mesh("square"), Material("bricks2"))));
}
开发者ID:Spidercoder,项目名称:3DEngineCpp,代码行数:45,代码来源:main.cpp


示例9: Measure

Size2F SpriteTemplate::Measure(const FileId& data, const Size2F& limitSize /*= Size2F::Zero*/) const
{
	auto obj= RenderingObjectFactory::Instance().CreateFromTexture(data);
	if (obj.IsValid())
	{
		return obj.Mesh()->Size().To2D();
	}
	return limitSize;
}
开发者ID:fjz13,项目名称:Medusa,代码行数:9,代码来源:SpriteTemplate.cpp


示例10: Mesh

Model Model::ConvertAssimpToDarknec(Model model, aiScene* scene) {

	model.numMeshes_ = scene->mNumMeshes;
	for (unsigned int mesh = 0; mesh < scene->mNumMeshes; mesh++) {

		Mesh messh = Mesh();
		int vertCount = scene->mMeshes[mesh]->mNumVertices;
		int normCount = scene->mMeshes[mesh]->mNumVertices;
		int indiCount = scene->mMeshes[mesh]->mNumFaces * 3; //All imported models must be comprised of tris.
		int uvCount = scene->mMeshes[mesh]->mNumVertices;


		messh.numIndices_ = indiCount;
		messh.numNormals_ = normCount * 3;
		messh.numVertices_ = vertCount * 3;
		messh.numUVs_ = uvCount * 2;
		messh.hasNormals_ = scene->mMeshes[mesh]->HasNormals();
		messh.hasUVS_ = scene->mMeshes[mesh]->HasTextureCoords(0);

		for (unsigned int face = 0; face < scene->mMeshes[mesh]->mNumFaces; face++) {
			aiFace facce = scene->mMeshes[mesh]->mFaces[face];
			messh.indices_.push_back(facce.mIndices[0]);
			messh.indices_.push_back(facce.mIndices[1]);
			messh.indices_.push_back(facce.mIndices[2]);
		}


		for (int vertex = 0; vertex < vertCount; vertex++) {
			aiVector3D vector = scene->mMeshes[mesh]->mVertices[vertex];
			messh.vertices_.push_back(vector.x);
			messh.vertices_.push_back(vector.y);
			messh.vertices_.push_back(vector.z);
		}

		if (messh.hasNormals_) {
			for (int normal = 0; normal < normCount; normal++) {
				aiVector3D vector = scene->mMeshes[mesh]->mNormals[normal];
				messh.normals_.push_back(vector.x);
				messh.normals_.push_back(vector.y);
				messh.normals_.push_back(vector.z);
			}
		}

		if (messh.hasUVS_) {
			for (int uv = 0; uv < uvCount; uv++) {
				aiVector3D vector = scene->mMeshes[mesh]->mTextureCoords[0][uv];
				messh.UVs_.push_back(vector.x);
				messh.UVs_.push_back(1- vector.y);
			}
		}

		model.meshes_.push_back(messh);
	}

	return model;
}
开发者ID:Sparkst3r,项目名称:DarknecEngine,代码行数:56,代码来源:Model.cpp


示例11: Mesh

Mesh Generate::line(const vector<VectorF> &linePointsIn, TextureDescriptor texture, Color color,
                    float lineWidth)
{
    if(linePointsIn.size() < 2) // if less than 2 points then we can't have a line
    {
        return Mesh(new Mesh_t());
    }
    vector<VectorF> linePoints;
    linePoints.reserve(linePointsIn.size());
    linePoints.push_back(linePointsIn[0]);
    for(size_t i = 1; i < linePointsIn.size(); i++)
    {
        if(absSquared(linePointsIn[i] - linePoints.back()) >= eps * eps) // remove duplicates
            linePoints.push_back(linePointsIn[i]);
    }
    if(linePoints.size() < 2) // if less than 2 points then we can't have a line
    {
        return Mesh(new Mesh_t());
    }

    vector<Edge> edges;
    edges.reserve(linePoints.size());
    float distance = 0;
    edges.push_back(makeStartEdge(linePoints[0], linePoints[1], distance, lineWidth));
    distance += abs(linePoints[1] - linePoints[0]);
    for(size_t i = 2; i < linePoints.size(); i++)
    {
        edges.push_back(makeMiddleEdge(linePoints[i - 2], linePoints[i - 1], linePoints[i], distance, lineWidth));
        distance += abs(linePoints[i - 1] - linePoints[i]);
    }
    edges.push_back(makeEndEdge(linePoints[linePoints.size() - 2], linePoints[linePoints.size() - 1], distance, lineWidth));
    Mesh retval = nullptr;
    for(size_t i = 1; i < edges.size(); i++)
    {
        TextureDescriptor currentTexture = texture.subTexture(edges[i - 1].distance / distance, edges[i].distance / distance, 0, 1);
        Mesh mesh = Generate::quadrilateral(currentTexture, edges[i - 1].p2, color, edges[i].p2, color, edges[i].p1, color, edges[i - 1].p1, color);
        if(retval == nullptr)
            retval = mesh;
        else
            retval->add(mesh);
    }
    return retval;
}
开发者ID:Tetheta,项目名称:sprouts,代码行数:43,代码来源:generate.cpp


示例12: InternalMessage

      void TestDetector::detectMovingObject()
      {
        InternalMessage("Model","Model::TestDetector::detectMovingObject entering") ;

        /*!
          We create a ship with a detector and a second object to detect.
        */
        std::auto_ptr<Kernel::Model> model(new Kernel::Model("TestDetector::detectMovingObject")) ;
        model->init() ;

        Kernel::Object* system = model->createObject() ;

        Kernel::Object* ship = system->createObject() ;
        ship->addTrait(new Positioned()) ;
        ship->addTrait(new Oriented()) ;
        ship->addTrait(new Mobile()) ;
        ship->addTrait(new Solid(Mesh("test_ship.mesh"))) ;
        ship->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship->addTrait(new Computer()) ;
        ship->addTrait(new Detector()) ;
        Detector::connect(ship,ship) ;

        Kernel::Object* ship2 = system->createObject() ;
        ship2->addTrait(new Positioned(Position::Meter(0,0,500))) ;
        ship2->addTrait(new Massive(Mass::Kilogram(1000))) ;
        ship2->addTrait(new Oriented()) ;
        ship2->addTrait(new Mobile()) ;
        ship2->addTrait(new Solid(Mesh("test_ship.mesh"))) ;

        // the second ship has been detected.
        std::set<Kernel::Object*> detected(ship->getTrait<Computer>()->getDetectedObjects()) ;
        CPPUNIT_ASSERT(!detected.empty()) ;
        CPPUNIT_ASSERT(detected.find(ship2) != detected.end()) ;

        ship2->getTrait<Positioned>()->setPosition(Position::Meter(0,100,0)) ;

        // the second ship has been detected.
        detected = ship->getTrait<Computer>()->getDetectedObjects() ;
        CPPUNIT_ASSERT(!detected.empty()) ;
        CPPUNIT_ASSERT(detected.find(ship2) != detected.end()) ;

        InternalMessage("Model","Model::TestDetector::detectMovingObject leaving") ;
      }
开发者ID:BackupTheBerlios,项目名称:projet-univers-svn,代码行数:43,代码来源:test_detector.cpp


示例13: Mesh

void MeshBuilder::apply(Mesh& mesh) const {
	if (!mesh.is_initialized()) {
		mesh = Mesh(vertex_decl, index_type, DRAW_TRIANGLES);
	} else {
		COLD_DEBUG_ASSERT(mesh.get_vertex_declaration() == vertex_decl);
		COLD_DEBUG_ASSERT(mesh.get_index_type() == index_type);
	}
	mesh.set_vertices(vertices.get_pointer(), vertices.get_count());
	mesh.set_indices(indices.get_pointer(), indices.get_count());
}
开发者ID:bqqbarbhg,项目名称:cold,代码行数:10,代码来源:mesh_builder.cpp


示例14: m_plane

RenderingEngine::RenderingEngine(const Window& window) :
	m_plane(Mesh("plane.obj")),
	m_window(&window),
	m_tempTarget(window.GetWidth(), window.GetHeight(), 0, GL_TEXTURE_2D, GL_NEAREST, GL_RGBA, GL_RGBA, false, GL_COLOR_ATTACHMENT0),
	m_planeMaterial("renderingEngine_filterPlane", m_tempTarget, 1, 8),
	m_defaultShader("forward-ambient"),
	m_shadowMapShader("shadowMapGenerator"),
	m_nullFilter("filter-null"),
	m_gausBlurFilter("filter-gausBlur7x1"),
	m_fxaaFilter("filter-fxaa"),
	m_altCameraTransform(Vector3f(0,0,0), Quaternion(Vector3f(0,1,0),ToRadians(180.0f))),
	m_altCamera(Matrix4f().InitIdentity(), &m_altCameraTransform)
{
	SetSamplerSlot("diffuse",   0);
	SetSamplerSlot("normalMap", 1);
	SetSamplerSlot("dispMap",   2);
	SetSamplerSlot("shadowMap", 3);
	SetSamplerSlot("roughMap",	4);
	
	SetSamplerSlot("filterTexture", 0);
	
	SetVector3f("ambient", Vector3f(0.2f, 0.2f, 0.2f));
	
	SetFloat("fxaaSpanMax", 8.0f);
	SetFloat("fxaaReduceMin", 1.0f/128.0f);
	SetFloat("fxaaReduceMul", 1.0f/8.0f);
	SetFloat("fxaaAspectDistortion", 150.0f);

	SetTexture("displayTexture", Texture(m_window->GetWidth(), m_window->GetHeight(), 0, GL_TEXTURE_2D, GL_LINEAR, GL_RGBA, GL_RGBA, true, GL_COLOR_ATTACHMENT0));

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

	glFrontFace(GL_CW);
	glCullFace(GL_BACK);
	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	//glEnable(GL_DEPTH_CLAMP);
	//glEnable(GL_MULTISAMPLE);
	//glEnable(GL_FRAMEBUFFER_SRGB);
	                  
	//m_planeMaterial("renderingEngine_filterPlane", m_tempTarget, 1, 8);
	m_planeTransform.SetScale(1.0f);
	m_planeTransform.Rotate(Quaternion(Vector3f(1,0,0), ToRadians(90.0f)));
	m_planeTransform.Rotate(Quaternion(Vector3f(0,0,1), ToRadians(180.0f)));
	
	for(int i = 0; i < NUM_SHADOW_MAPS; i++)
	{
		int shadowMapSize = 1 << (i + 1);
		m_shadowMaps[i] = Texture(shadowMapSize, shadowMapSize, 0, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0);
		m_shadowMapTempTargets[i] = Texture(shadowMapSize, shadowMapSize, 0, GL_TEXTURE_2D, GL_LINEAR, GL_RG32F, GL_RGBA, true, GL_COLOR_ATTACHMENT0);
	}
	
	m_lightMatrix = Matrix4f().InitScale(Vector3f(0,0,0));	
}
开发者ID:ClockTeam,项目名称:ClockworkEngine,代码行数:54,代码来源:renderingEngine.cpp


示例15: RETURN_NULL_IF_NULL

Sprite* NodeFactory::CreateSpriteFromAtlasRegion(StringRef regionName, const FileIdRef& atlasFileId, TextureAtlasFileFormat fileFormat /*= TextureAtlasFileFormat::Spine*/, uint atlasPageCount /*= 1*/)
{
	auto renderingObject = RenderingObjectFactory::Instance().CreateFromTextureAtlasRegion(regionName, atlasFileId, fileFormat, atlasPageCount);
	RETURN_NULL_IF_NULL(renderingObject);

	Sprite* sprite = new Sprite();
	sprite->SetRenderingObject(renderingObject);
	sprite->SetSize(renderingObject.Mesh()->Size());
	sprite->Initialize();
	return sprite;
}
开发者ID:JamesLinus,项目名称:Medusa,代码行数:11,代码来源:NodeFactory.cpp


示例16: Mesh

Mesh Model::processMesh(aiMesh* mesh, const aiScene* scene)
{
	vector<Vertex> vertices;
	vector<GLuint> indices;
	vector<Texture> textures;
	
	// Process vertex positions, normals and texture coordinates
	for(GLuint i = 0; i < mesh->mNumVertices; i++) {
		Vertex vertex;
		glm::vec3 vector;
		vector.x = mesh->mVertices[i].x;
		vector.y = mesh->mVertices[i].z;
		vector.z = mesh->mVertices[i].y;
		//printVec("vertex ", vector);
		
		vertex.position = vector;
		
		vector.x = mesh->mNormals[i].x;
		vector.y = mesh->mNormals[i].z;
		vector.z = mesh->mNormals[i].y;
		
		vertex.normal = vector;
		
		 // Does the mesh contain texture coordinates?
		if(mesh->mTextureCoords[0]) {
			glm::vec2 vec;
			vec.x = mesh->mTextureCoords[0][i].x;
			vec.y = mesh->mTextureCoords[0][i].y;
			vertex.textureCoords = vec;
		}
		else
			vertex.textureCoords = glm::vec2(0.0f, 0.0f);
		
		vertices.push_back(vertex);
	}
	// Process indices
	for(GLuint i = 0; i < mesh->mNumFaces; i++)
	{
		aiFace face = mesh->mFaces[i];
		for(GLuint j = 0; j < face.mNumIndices; j++)
			indices.push_back(face.mIndices[j]);
	}
	
	// Process material
	if(mesh->mMaterialIndex >= 0) {
		aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];
		vector<Texture> diffuseMaps = this->loadMaterialTextures(material, aiTextureType_DIFFUSE, "texture_diffuse");
		textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
		vector<Texture> specularMaps = this->loadMaterialTextures(material, aiTextureType_SPECULAR, "texture_specular");
		textures.insert(textures.end(), specularMaps.begin(), specularMaps.end());
	}
	
	return Mesh(vertices, indices, textures);
}
开发者ID:isaiahb,项目名称:Game-Engine,代码行数:54,代码来源:Model.cpp


示例17: vec3

Mesh Model::ProcessMesh(aiMesh* mesh, const aiScene* scene)
{
	// Data to fill
	std::vector<MeshVertex> vertices;
	std::vector<uint> indices;
	std::vector<MeshTexture> textures;

	if (mesh->mMaterialIndex >= 0)
	{
		aiMaterial* mat = scene->mMaterials[mesh->mMaterialIndex];

		if (textype.empty()) textype = determineTextureType(scene, mat);
	}

	// Walk through each of the mesh's vertices
	for (uint i = 0; i < mesh->mNumVertices; i++)
	{
		MeshVertex vertex;

		vertex.x = mesh->mVertices[i].x;
		vertex.y = mesh->mVertices[i].y;
		vertex.z = mesh->mVertices[i].z;

		vertex.normal = vec3(mesh->mNormals[i].x, mesh->mNormals[i].y, mesh->mNormals[i].z);



		if (mesh->mTextureCoords[0])
		{
			vertex.texcoord.x = (float)mesh->mTextureCoords[0][i].x;
			vertex.texcoord.y = (float)mesh->mTextureCoords[0][i].y;
		}

		vertices.push_back(vertex);
	}

	for(uint i = 0; i < mesh->mNumFaces; i++)
	{
		aiFace face = mesh->mFaces[i];

		for (uint j = 0; j < face.mNumIndices; j++)
			indices.push_back(face.mIndices[j]);
	}

	if (mesh->mMaterialIndex >= 0)
	{
		aiMaterial* material = scene->mMaterials[mesh->mMaterialIndex];

		std::vector<MeshTexture> diffuseMaps = this->loadMaterialTextures(material, aiTextureType_DIFFUSE, "texture_diffuse", scene);
		textures.insert(textures.end(), diffuseMaps.begin(), diffuseMaps.end());
	}

	return Mesh(vertices, indices, textures);
}
开发者ID:JacobHensley,项目名称:GLEW-Graphics,代码行数:54,代码来源:Model.cpp


示例18: Mesh

SceneNode::SceneNode(glm::vec3 dispxyzIN, float rotyIN, glm::vec3 scalexyzIN, ShapeGen::ShapeType shapeTypeIn, int matIndIN, bool inheritsColorIN)
{
  dispxyz = dispxyzIN;
  roty = rotyIN;
  scalexyz = scalexyzIN;
  shapeType = shapeTypeIn;
  matInd = matIndIN;
  inheritsColor = inheritsColorIN;

  meshContents = Mesh();
}
开发者ID:djmally,项目名称:lakitu-oculus,代码行数:11,代码来源:SceneNode.cpp


示例19: loadMesh

void Mesh::loadMesh(const std::string & modelName, std::vector<Mesh> & meshData, aiNode * node,
					const aiScene * scene) {
	for (unsigned i = 0; i < node->mNumMeshes; i++) {
		auto mesh = scene->mMeshes[node->mMeshes[i]];
		meshData.emplace_back(Mesh(modelName, mesh, scene));
	}

	for (unsigned i = 0; i < node->mNumChildren; i++) {
		loadMesh(modelName, meshData, node->mChildren[i], scene);
	}
}
开发者ID:Yelnats321,项目名称:AIShootyCooly,代码行数:11,代码来源:Mesh.cpp


示例20: Mesh

eae6320::Graphics::GameObject::GameObject(char* const i_path_mesh, char* const i_path_material)
{
	m_mesh = Mesh(i_path_mesh);
	m_material = Material(i_path_material);

	m_position = Math::cVector();
	m_orientation = Math::cQuaternion();
	m_velocity = Math::cVector(0, 0, 0);
	m_collider.sExtends = Math::cVector(0, 0, 0);

	m_alpha = 1.0;
}
开发者ID:viswanath700,项目名称:MyGameEngine,代码行数:12,代码来源:GameObject.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Message函数代码示例发布时间:2022-05-30
下一篇:
C++ MergeFrom函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap