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


C++ TexturePtr::reset方法代码示例

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


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

示例1: disc

TexturePtr DrawContext::disc(u16 radius)
{
  TexturePtr result;
  
  string path = discPath(radius);
  if(!Application::instance()->resourceManager->hasTexture(path))
  {
    BitmapPtr bitmap(new Bitmap(2*radius, 2*radius, GL_RGBA));
    bitmap->disc(radius-.5, radius-.5, radius+.5);
    bitmap->premultiplyAlpha();
    result.reset(new Texture(bitmap));
    Application::instance()->resourceManager->texture(path, result);
  }
  else
  {
    result = Application::instance()->resourceManager->texture(path);
  }
  
  return result;
}
开发者ID:jomanto,项目名称:le2,代码行数:20,代码来源:DrawContext.cpp

示例2: setupScene

	void setupScene()
	{
		m_window->getViewports().front()->setRenderQueueIdMask(~RenderQueueId_OffscreenTransparentObjects);

		LightPtr light(new Light);
		light->setDirection(glm::normalize(glm::vec3(1.5, -1, -0.5)));
		light->setPosition(glm::vec3(0, 0.5, 0) + light->getDirection() * -10.0f);
		m_visSystem->addLight(light);

		// Volume
		std::vector<std::string> gridNames;
		gridNames.push_back(m_config.densityGridName);

		if (!m_config.temperatureGridName.empty())
		{
			gridNames.push_back(m_config.temperatureGridName);
		}

		std::vector<openvdb::GridBase::Ptr> baseGrids = loadGridsFromFile(m_config.vdbVilename, gridNames);

		openvdb::FloatGrid::Ptr densityGrid = openvdb::gridPtrCast<openvdb::FloatGrid>(baseGrids[0]);

		openvdb::FloatGrid::Ptr temperatureGrid;
		if (!m_config.temperatureGridName.empty())
		{
			temperatureGrid = openvdb::gridPtrCast<openvdb::FloatGrid>(baseGrids[1]);

			// Rescale temperature field to between 0 and 1
			{
				float minValue = 99999999999999;
				float maxValue = -99999999999999;
				for (openvdb::FloatGrid::ValueOnCIter iter = temperatureGrid->cbeginValueOn(); iter.test(); ++iter) {
					float value = *iter;
					minValue = std::min(minValue, value);
					maxValue = std::max(maxValue, value);
				}

				float scale = 1.0 / (maxValue - minValue);

				for (openvdb::FloatGrid::ValueOnIter iter = temperatureGrid->beginValueOn(); iter.test(); ++iter) {
					float value = *iter;
					value = (value - minValue) * scale;
					iter.setValue(value);
				}
			}

			// Ensure both grids have the same hierarchy
			{
				openvdb::FloatGrid::Ptr resultGrid = openvdb::FloatGrid::create();
				resultGrid->tree().combine2(densityGrid->tree(), temperatureGrid->tree(), CopyBIntoA());
				temperatureGrid->tree().combine(densityGrid->tree(), CopyBIntoA());

				densityGrid = resultGrid; 
			}
		}

		std::vector<GridPtr> grids;
		GridTextureRolesMap gridTextureRoles;

		grids.push_back(GridPtr(new VdbGrid<openvdb::FloatGrid>(densityGrid, 1)));
		gridTextureRoles[GridTextureRole_Diffuse] = grids.back();

		if (m_config.generateNormals)
		{
			Vec3UByteGrid::Ptr normalGrid = createNormalGrid(*densityGrid);
			grids.push_back(GridPtr(new VdbGrid<Vec3UByteGrid>(normalGrid, 3)));
			gridTextureRoles[GridTextureRole_Normal] = grids.back();
		}

		if (temperatureGrid)
		{
			grids.push_back(GridPtr(new VdbGrid<openvdb::FloatGrid>(temperatureGrid, 1)));
			gridTextureRoles[GridTextureRole_Temperature] = grids.back();
		}

		openvdb::CoordBBox bbox;
		densityGrid->constTree().evalLeafBoundingBox(bbox);

		float scale = 1.0f / (float)bbox.extents().asVec3s().length();

		glm::vec3 center = toVec3(bbox.getCenter() * scale);
		std::ostringstream ss;
		ss << "Grid extents: " << bbox.extents().x() << ", " << bbox.extents().y() << ", " << bbox.extents().z();
		defaultLogger()->logLine(ss.str());

		int renderQueueId;
		if (m_config.renderToLowResTarget)
		{
			renderQueueId = RenderQueueId_OffscreenTransparentObjects;
		}
		else
		{
			renderQueueId = getDefaultRenderQueueId();
		}

		RenderableVolumeConfig config;
		config.grids = grids;
		config.materialFactory.reset(new SparseVolumeMaterialFactoryI(gridTextureRoles, m_config.transparent, m_config.opacityMultiplier));
		config.scale = scale;
		config.batchBoxes = !m_config.transparent; // don't batch if we have transparency so we can sort
//.........这里部分代码省略.........
开发者ID:fohr,项目名称:Graphtane,代码行数:101,代码来源:Main.cpp

示例3: CreateMeshContainer


//.........这里部分代码省略.........
				texFileName = filename.erase( index );
				PathAppend( path,texFileName.c_str() );
				texFileName = path;
				PathRemoveFileSpec( path );
			}
			else
			{
				texFileName = filename;
				PathAppend( path,texFileName.c_str() );
				texFileName = path;
				PathRemoveFileSpec( path );
			}

			tstring ext = PathFindExtension( texFileName.c_str() );

			if( ext == _T(".sph" ) || ext == _T(".spa") )
			{
				sphereFileName = texFileName;
				texFileName = _T("");
			}
		}

		if( !texFileName.empty() )
		{
			TexturePtr pTex = ResourceManager::GetInstance().GetResource<Texture>( texFileName );
			if( !pTex )
			{
				pTex = TexturePtr(new Texture);
				if( pTex->CreateFromFile( texFileName ) )
				{
					ResourceManager::GetInstance().AddResource( texFileName,pTex );
				}
				else
				{
					pTex.reset();
				}
			}

			if( pTex )
			{
				pMaterial->textureDiffuse = pTex;
			}
		}

		if( !sphereFileName.empty() )
		{
			TexturePtr pTex = ResourceManager::GetInstance().GetResource<Texture>( sphereFileName );
			if( !pTex )
			{
				pTex = TexturePtr(new Texture);
				if( pTex->CreateFromFile( sphereFileName ) )
				{
					ResourceManager::GetInstance().AddResource( sphereFileName,pTex );
				}
				else
				{
					pTex.reset();
				}
			}

			if( pTex )
			{
				pMaterial->textureSphere = pTex;
			}

			tstring ext = PathFindExtension( sphereFileName.c_str() );
			if( ext == _T(".sph" ) )
			{
				pMaterial->spheremap = eSPHEREMAP_MUL;
			}
			else if( ext == _T(".spa") )
			{
				pMaterial->spheremap = eSPHEREMAP_ADD;
			}
		}
	}

exit:
	if( m_pMaterialBuf )
	{
		m_pMaterialBuf->Release();
		m_pMaterialBuf = NULL;
	}
	if( m_pEffectInstancesBuf )
	{
		m_pEffectInstancesBuf->Release();
		m_pEffectInstancesBuf = NULL;
	}
	if( m_pAdjacencyBuf )
	{
		m_pAdjacencyBuf->Release();
		m_pAdjacencyBuf = NULL;
	}
	if( m_pD3DMesh )
	{
		m_pD3DMesh->Release();
		m_pD3DMesh = NULL;
	}
	return meshContainer;
}
开发者ID:ZeusAFK,项目名称:MikuMikuGameEngine,代码行数:101,代码来源:XFileLoader.cpp

示例4: Open


//.........这里部分代码省略.........
			TexturePtr pTex = ResourceManager::GetInstance().GetResource<Texture>( sphereFileName );
			if( !pTex )
			{
				pTex = TexturePtr(new Texture);
				pTex->CreateFromFile( sphereFileName );

				ResourceManager::GetInstance().AddResource( sphereFileName,pTex );
			}

			pMaterial->textureSphere = pTex;

			tstring ext = PathFindExtension( sphereFileName.c_str() );
			if( ext == _T(".sph" ) )
			{
				pMaterial->spheremap = eSPHEREMAP_MUL;
			}
			else if( ext == _T(".spa") )
			{
				pMaterial->spheremap = eSPHEREMAP_ADD;
			}
		}

		pMaterial->colorToon = D3DXCOLOR( 1.0f,1.0f,1.0f,1.0f );

		tstring toonTexName = _T("");
		tstring toonTexPath = _T("");

		if( 0<=pmdMat->toon_index && pmdMat->toon_index<10 )
		{
			// TODO:デフォルトのtoonファイルは固定パスか・・・
			toonTexName = to_tstring( pmd->toon_list.toon_file_name[pmdMat->toon_index] );
		}

		TexturePtr pTex;
		
		if( !toonTexName.empty() )
		{
			PathAppend( path,toonTexName.c_str() );
			toonTexPath = path;
			PathRemoveFileSpec( path );

			pTex = ResourceManager::GetInstance().GetResource<Texture>( toonTexPath );
			if( !pTex )
			{
				pTex = TexturePtr(new Texture);
				if( !pTex->CreateFromFile( toonTexPath ) )
				{
					pTex.reset();
				}
			}
		}

		if( !pTex )
		{
			pTex = graphics->GetDefaultToonTexture( pmdMat->toon_index );
			if( !pTex )
			{
				toonTexPath = _T("<FFFFFFFF>");

				pTex = ResourceManager::GetInstance().GetResource<Texture>( toonTexPath );
				if( !pTex )
				{
					pTex = TexturePtr(new Texture);
					if( !pTex->CreateDotColor( 0xFFFFFFFF ) )
					{
						pTex.reset();
					}
				}
			}
		}
		
		if( pTex )
		{
			pMaterial->textureToon = pTex;

			ResourceManager::GetInstance().AddResource( toonTexPath,pTex );

			IDirect3DTexture9Ptr pD3DTexture = pTex->GetTexture();

			D3DSURFACE_DESC desc;
			pD3DTexture->GetLevelDesc( 0,&desc );

			D3DLOCKED_RECT lockRect;
			pD3DTexture->LockRect(0, &lockRect, NULL, 0);

			int x = 0;
			int y = desc.Height-1;

			DWORD color;

			memcpy(&color,(BYTE*)lockRect.pBits + lockRect.Pitch*y + 4*x, sizeof(DWORD) );

			pD3DTexture->UnlockRect(0);

			pMaterial->colorToon = D3DXCOLOR( color );
		}
	}

	return PMDModelPtr( new PMDModel(pmd,pmd->material_list.material_count,pMaterials) );
}
开发者ID:ZeusAFK,项目名称:MikuMikuGameEngine,代码行数:101,代码来源:PMDFileLoader.cpp

示例5: setupScene

	void setupScene()
	{
		LightPtr light(new Light);
		light->setDirection(glm::normalize(glm::vec3(2, -1, -1)));
		m_visSystem->addLight(light);

		m_camera->getProjection()->setNearClipDistance(0.05);
		m_camera->getProjection()->setFarClipDistance(1000);

		// Create heightmap
		TexturePtr texture;
		{
			ImageTextureConfig config = ImageTextureConfig::createDefault();
			config.format = PixelFormat_R16;
			config.width = config.height = 512;
			
			boost::scoped_array<char16_t> buffer(new char16_t[config.width * config.height]);
			
			for (int y = 0; y < config.height; ++y)
			{
				for (int x = 0; x < config.width; ++x)
				{
					// interesting ripple pattern
					glm::vec2 r = glm::vec2((float)x / (float)config.width, (float)y / (float)config.height) * 2.0f - 1.0f;
					buffer[x + config.width * y] = 32768 + 32767 * std::sin(glm::length(r) * 30.0f);
				}
			}

			config.data = (unsigned char*)buffer.get();

			texture.reset(new Texture(config));
			texture->setTextureAddressMode(TextureAddressMode_Clamp);
		}

		// Create tessellated plane
		{
			ShaderProgramConfig config("c:\\projects\\Graphtane\\Shaders\\TessDisplacement\\TessDisplacement.vert", "c:\\projects\\Graphtane\\Shaders\\Common\\SimpleTextured.frag");
			config.shaderFilepaths[ShaderType_TessellationControl] = "c:\\projects\\Graphtane\\Shaders\\TessDisplacement\\TessDisplacement.tctrl";
			config.shaderFilepaths[ShaderType_TessellationEvaluation] = "c:\\projects\\Graphtane\\Shaders\\TessDisplacement\\TessDisplacement.teval";

			ShaderProgramPtr shader = ShaderProgram::createShaderProgram(config);
			TechniquePtr technique(new Technique(shader));
			technique->addTextureUnit(TextureUnit(texture, "heightSampler"));
			technique->addTextureUnit(TextureUnit(texture, "albedoSampler"));
			technique->addCustomShaderParameter(ShaderParameterPtr(new FloatShaderParameter("heightScale", 0.2f)));

			MaterialPtr material(new Material);
			material->setTechnique(technique);

			{
				RectangleConfig config = RectangleConfig::defaultWithSize(glm::vec2(10, 10));
				config.quads = true;
				config.segmentCountX = 32;
				config.segmentCountY = 32;
				config.orientation = glm::angleAxis(halfPi(), glm::vec3(-1, 0, 0));
				config.flipV = true;
				MeshPtr mesh = RectangleMeshFactory::createMesh(config);
				GeoPtr geo(new Geo(mesh, material));

				RenderableNodePtr node = RenderableNode::createWithSingleGeo(geo);
				node->setWireframeModeEnabled(true);
				m_visSystem->addRenderableNode(node);
			}
		}

		m_camera->setPosition(glm::vec3(0, 4, 6));
		m_cameraController->rotate(0, -0.3);
	}
开发者ID:jhurlbut,项目名称:Graphtane,代码行数:68,代码来源:Main.cpp


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