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


C++ aiMaterial::GetTexture方法代码示例

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


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

示例1: convert_aimaterial

	void bc_mesh_loader::convert_aimaterial(core::bc_content_loading_context& p_context, const aiMaterial& p_aimaterial, game::bc_render_material_description& p_material)
	{
		auto* l_content_manager = core::bc_get_service< core::bc_content_manager >();

		aiColor3D l_diffuse;
		bcFLOAT l_alpha = 1;
		bcFLOAT l_specular_intensity = 1;
		bcFLOAT l_specular_power = 1;

		p_aimaterial.Get(AI_MATKEY_COLOR_DIFFUSE, l_diffuse);
		p_aimaterial.Get(AI_MATKEY_SHININESS_STRENGTH, l_specular_intensity);
		p_aimaterial.Get(AI_MATKEY_SHININESS, l_specular_power);
		p_aimaterial.Get(AI_MATKEY_OPACITY, l_alpha);

		p_material.m_diffuse = core::bc_vector4f(l_diffuse.r, l_diffuse.g, l_diffuse.b, l_alpha);
		p_material.m_specular_intensity = l_specular_intensity;
		p_material.m_specular_power = l_specular_power;

		aiString l_aistr;
		const core::bc_path l_file_path = core::bc_path(p_context.m_file_path.c_str()).set_filename(bcL(""));

		if (p_aimaterial.GetTexture(aiTextureType_DIFFUSE, 0, &l_aistr) == aiReturn_SUCCESS)
		{
			p_material.m_diffuse_map = l_content_manager->load< graphic::bc_texture2d_content >
			(
				p_context.get_allocator_alloc_type(),
				core::bc_path(l_file_path).set_filename(core::bc_to_exclusive_wstring(l_aistr.C_Str()).c_str()).get_path().c_str(),
				core::bc_content_loader_parameter(p_context.m_parameter)
			);
		}
		if (p_aimaterial.GetTexture(aiTextureType_NORMALS, 0, &l_aistr) == aiReturn_SUCCESS)
		{
			p_material.m_normal_map = l_content_manager->load< graphic::bc_texture2d_content >
			(
				p_context.get_allocator_alloc_type(),
				core::bc_path(l_file_path).set_filename(core::bc_to_exclusive_wstring(l_aistr.C_Str()).c_str()).get_path().c_str(),
				core::bc_content_loader_parameter(p_context.m_parameter)
			);
		}
		if (p_aimaterial.GetTexture(aiTextureType_SPECULAR, 0, &l_aistr) == aiReturn_SUCCESS)
		{
			p_material.m_specular_map = l_content_manager->load< graphic::bc_texture2d_content >
			(
				p_context.get_allocator_alloc_type(),
				core::bc_path(l_file_path).set_filename(core::bc_to_exclusive_wstring(l_aistr.C_Str()).c_str()).get_path().c_str(),
				core::bc_content_loader_parameter(p_context.m_parameter)
			);
		}
	}
开发者ID:MohammadRB,项目名称:BlackCat-Engine,代码行数:49,代码来源:bcMeshLoader.cpp

示例2: move

	shared_ptr<ModelMaterial> ModelMaterialProcessor::LoadModelMaterial(Model& model, aiMaterial& material)
	{
		InitializeTextureTypeMappings();
		ModelMaterialData modelMaterialData;

		aiString name;
		material.Get(AI_MATKEY_NAME, name);
		modelMaterialData.Name = name.C_Str();

		for (TextureType textureType = (TextureType)0; textureType < TextureType::End; textureType = (TextureType)(static_cast<int>(textureType) + 1))
		{
			aiTextureType mappedTextureType = (aiTextureType)sTextureTypeMappings[textureType];

			UINT textureCount = material.GetTextureCount(mappedTextureType);
			if (textureCount > 0)
			{
				vector<string>* textures = new vector<string>();
				modelMaterialData.Textures.insert(pair<TextureType, vector<string>*>(textureType, textures));

				textures->reserve(textureCount);
				for (UINT textureIndex = 0; textureIndex < textureCount; textureIndex++)
				{
					aiString path;
					if (material.GetTexture(mappedTextureType, textureIndex, &path) == AI_SUCCESS)
					{
						textures->push_back(path.C_Str());
					}
				}
			}
		}

		return make_shared<ModelMaterial>(model, move(modelMaterialData));
	}
开发者ID:btrowbridge,项目名称:ComputerGraphicsAssignments,代码行数:33,代码来源:ModelMaterialProcessor.cpp

示例3:

bool assets::Material::loadFromDisk(const std::string& basePath, const aiMaterial& material, AssetManager& assetManager)
{
	for (const auto& pair: {
			std::make_pair(0u, aiTextureType_EMISSIVE),
			std::make_pair(1u, aiTextureType_AMBIENT),
			std::make_pair(2u, aiTextureType_DIFFUSE),
			std::make_pair(3u, aiTextureType_SPECULAR),
			std::make_pair(4u, aiTextureType_HEIGHT)})
	{
		aiString texturePath;

		material.GetTexture(pair.second, 0, &texturePath, nullptr, nullptr, nullptr, nullptr);

		const std::string fullPath = basePath + std::string(texturePath.C_Str());

		if (0 < texturePath.length)
			textures[pair.first] =
					assetManager.getOrCreate<Texture>(std::string(texturePath.C_Str()), fullPath.c_str());
	}

    aiColor3D emissive, ambient, diffuse, specular;
    float shininess;

    material.Get(AI_MATKEY_COLOR_EMISSIVE, emissive);
    material.Get(AI_MATKEY_COLOR_AMBIENT, ambient);
    material.Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
    material.Get(AI_MATKEY_COLOR_SPECULAR, specular);
    material.Get(AI_MATKEY_SHININESS, shininess);

    this->emission = glm::vec4(emissive.r, emissive.g, emissive.b, 1.0f);
    this->ambient = glm::vec4(ambient.r, ambient.g, ambient.b, 1.0f);
    this->diffuse = glm::vec4(diffuse.r, diffuse.g, diffuse.b, 1.0f);
    this->specular = glm::vec4(specular.r, specular.g, specular.b, 1.0f);
    this->shininess = shininess;

    if (textures[2] && textures[2]->surface)
        translucent = textures[2]->surface->format->BytesPerPixel == 4;

    return true;
}
开发者ID:vinther,项目名称:rmit-rendering,代码行数:40,代码来源:Material.cpp

示例4: chunk

// ------------------------------------------------------------------------------------------------
void Discreet3DSExporter::WriteTexture(const aiMaterial& mat, aiTextureType type, uint16_t chunk_flags)
{
    aiString path;
    aiTextureMapMode map_mode[2] = {
        aiTextureMapMode_Wrap, aiTextureMapMode_Wrap
    };
    double blend = 1.0f;
    if (mat.GetTexture(type, 0, &path, NULL, NULL, &blend, NULL, map_mode) != AI_SUCCESS || !path.length) {
        return;
    }

    // TODO: handle embedded textures properly
    if (path.data[0] == '*') {
        DefaultLogger::get()->error("Ignoring embedded texture for export: " + std::string(path.C_Str()));
        return;
    }

    ChunkWriter chunk(writer, chunk_flags);
    {
        ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAPFILE);
        WriteString(path);
    }

    WritePercentChunk(blend);

    {
        ChunkWriter chunk(writer, Discreet3DS::CHUNK_MAT_MAP_TILING);
        uint16_t val = 0; // WRAP
        if (map_mode[0] == aiTextureMapMode_Mirror) {
            val = 0x2;
        }
        else if (map_mode[0] == aiTextureMapMode_Decal) {
            val = 0x10;
        }
        writer.PutU2(val);
    }
    // TODO: export texture transformation (i.e. UV offset, scale, rotation)
}
开发者ID:3drepo,项目名称:assimp,代码行数:39,代码来源:3DSExporter.cpp

示例5: assimp_material_add_texture

void Model::assimp_material_add_texture(Material &material, aiMaterial &assimp_material, Model_Texture_Type type)
{
  int texIndex = 0;
  aiString path;
  aiTextureType assimp_type;

  switch (type) {
    case MODEL_TEXTURE_DIFFUSE:
      assimp_type = aiTextureType_DIFFUSE;
      break;
    case MODEL_TEXTURE_NORMAL:
      assimp_type = aiTextureType_NORMALS;
      break;
    case MODEL_TEXTURE_HEIGHT:
      assimp_type = aiTextureType_HEIGHT;
      break;
    case MODEL_TEXTURE_ALPHA:
      assimp_type = aiTextureType_OPACITY;
      break;
    case MODEL_TEXTURE_SPECULAR:
      assimp_type = aiTextureType_SPECULAR;
      break;
    default:
      break;
  }

  aiReturn texFound = assimp_material.GetTexture(assimp_type, texIndex, &path);

  if (texFound == AI_SUCCESS) {
    if (texIndex > 0) {
      std::cout << "Fragmic warning: more then one texture of this type for material" << std::endl;
      std::cout << "NOT CURRENTLY SUPPORTED!" << std::endl;
    }

    //std::cout << "\tTexture file: " << path.data << std::endl;
    std::unique_ptr<Texture> texturePtr(new Texture());
    Texture &texture = *texturePtr;
    texture.image_load(prefix + std::string(path.data));

    switch (type) {
      case MODEL_TEXTURE_DIFFUSE:
        material.diffuse = std::move(texturePtr);
        break;
      case MODEL_TEXTURE_NORMAL:
        material.normal = std::move(texturePtr);
        break;
      case MODEL_TEXTURE_HEIGHT:
        material.height = std::move(texturePtr);
        break;
      case MODEL_TEXTURE_ALPHA:
        material.alpha = std::move(texturePtr);
        break;
      case MODEL_TEXTURE_SPECULAR:
        material.specular = std::move(texturePtr);
        break;
      default:
        break;
    }

    texIndex++;
    texFound = assimp_material.GetTexture(assimp_type, texIndex, &path);
  }

}
开发者ID:Toeplitz,项目名称:poll,代码行数:64,代码来源:model.cpp


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