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


C++ ITextureSource::isKnownSourceImage方法代码示例

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


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

示例1: MYMAX

GUIChatConsole::GUIChatConsole(
		gui::IGUIEnvironment* env,
		gui::IGUIElement* parent,
		s32 id,
		ChatBackend* backend,
		Client* client,
		IMenuManager* menumgr
):
	IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
			core::rect<s32>(0,0,100,100)),
	m_chat_backend(backend),
	m_client(client),
	m_menumgr(menumgr),
	m_animate_time_old(porting::getTimeMs())
{
	// load background settings
	s32 console_alpha = g_settings->getS32("console_alpha");
	m_background_color.setAlpha(clamp_u8(console_alpha));

	// load the background texture depending on settings
	ITextureSource *tsrc = client->getTextureSource();
	if (tsrc->isKnownSourceImage("background_chat.jpg")) {
		m_background = tsrc->getTexture("background_chat.jpg");
		m_background_color.setRed(255);
		m_background_color.setGreen(255);
		m_background_color.setBlue(255);
	} else {
		v3f console_color = g_settings->getV3F("console_color");
		m_background_color.setRed(clamp_u8(myround(console_color.X)));
		m_background_color.setGreen(clamp_u8(myround(console_color.Y)));
		m_background_color.setBlue(clamp_u8(myround(console_color.Z)));
	}

	m_font = g_fontengine->getFont(FONT_SIZE_UNSPECIFIED, FM_Mono);

	if (!m_font) {
		errorstream << "GUIChatConsole: Unable to load mono font ";
	} else {
		core::dimension2d<u32> dim = m_font->getDimension(L"M");
		m_fontsize = v2u32(dim.Width, dim.Height);
		m_font->grab();
	}
	m_fontsize.X = MYMAX(m_fontsize.X, 1);
	m_fontsize.Y = MYMAX(m_fontsize.Y, 1);

	// set default cursor options
	setCursor(true, true, 2.0, 0.1);
}
开发者ID:EXio4,项目名称:minetest,代码行数:48,代码来源:guiChatConsole.cpp

示例2: animate

bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_ratio)
{
	bool enable_shaders = g_settings->getBool("enable_shaders");
	bool enable_bumpmapping = g_settings->getBool("enable_bumpmapping");
	bool enable_parallax_occlusion = g_settings->getBool("enable_parallax_occlusion");

	if(!m_has_animation)
	{
		m_animation_force_timer = 100000;
		return false;
	}

	m_animation_force_timer = myrand_range(5, 100);

	// Cracks
	if(crack != m_last_crack)
	{
		for(std::map<u32, std::string>::iterator
				i = m_crack_materials.begin();
				i != m_crack_materials.end(); i++)
		{
			scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first);
			std::string basename = i->second;

			// Create new texture name from original
			ITextureSource *tsrc = m_gamedef->getTextureSource();
			std::ostringstream os;
			os<<basename<<crack;
			u32 new_texture_id = 0;
			video::ITexture *new_texture =
				tsrc->getTexture(os.str(), &new_texture_id);
			buf->getMaterial().setTexture(0, new_texture);

			// If the current material is also animated,
			// update animation info
			std::map<u32, TileSpec>::iterator anim_iter =
				m_animation_tiles.find(i->first);
			if(anim_iter != m_animation_tiles.end()){
				TileSpec &tile = anim_iter->second;
				tile.texture = new_texture;
				tile.texture_id = new_texture_id;
				// force animation update
				m_animation_frames[i->first] = -1;
			}
		}

		m_last_crack = crack;
	}
	
	// Texture animation
	for(std::map<u32, TileSpec>::iterator
			i = m_animation_tiles.begin();
			i != m_animation_tiles.end(); i++)
	{
		const TileSpec &tile = i->second;
		// Figure out current frame
		int frameoffset = m_animation_frame_offsets[i->first];
		int frame = (int)(time * 1000 / tile.animation_frame_length_ms
				+ frameoffset) % tile.animation_frame_count;
		// If frame doesn't change, skip
		if(frame == m_animation_frames[i->first])
			continue;

		m_animation_frames[i->first] = frame;

		scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first);
		ITextureSource *tsrc = m_gamedef->getTextureSource();

		// Create new texture name from original
		std::ostringstream os(std::ios::binary);
		os<<tsrc->getTextureName(tile.texture_id);
		os<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
		// Set the texture
		buf->getMaterial().setTexture(0, tsrc->getTexture(os.str()));
		buf->getMaterial().setTexture(2, tsrc->getTexture("disable_img.png"));
		if (enable_shaders && (enable_bumpmapping || enable_parallax_occlusion))
			{
				std::string fname_base,fname_normal;
				fname_base = tsrc->getTextureName(tile.texture_id);
				unsigned pos;
				pos = fname_base.find(".");
				fname_normal = fname_base.substr (0, pos);
				fname_normal += "_normal.png";
				if (tsrc->isKnownSourceImage(fname_normal)){
					os.str("");
					os<<fname_normal<<"^[verticalframe:"<<(int)tile.animation_frame_count<<":"<<frame;
					buf->getMaterial().setTexture(1, tsrc->getTexture(os.str()));
					buf->getMaterial().setTexture(2, tsrc->getTexture("enable_img.png"));
				}
			}
	}

	// Day-night transition
	if(daynight_ratio != m_last_daynight_ratio)
	{
		for(std::map<u32, std::map<u32, std::pair<u8, u8> > >::iterator
				i = m_daynight_diffs.begin();
				i != m_daynight_diffs.end(); i++)
		{
			scene::IMeshBuffer *buf = m_mesh->getMeshBuffer(i->first);
//.........这里部分代码省略.........
开发者ID:andrew889,项目名称:minetest-1,代码行数:101,代码来源:mapblock_mesh.cpp

示例3: os


//.........这里部分代码省略.........
				finalColorBlend(vc, day, night, 1000);
				if(day != night)
					m_daynight_diffs[i][j] = std::make_pair(day, night);
				// Brighten topside (no shaders)
				if(p.vertices[j].Normal.Y > 0.5)
				{
					vc.setRed  (srgb_linear_multiply(vc.getRed(),   1.3, 255.0));
					vc.setGreen(srgb_linear_multiply(vc.getGreen(), 1.3, 255.0));
					vc.setBlue (srgb_linear_multiply(vc.getBlue(),  1.3, 255.0));
				}
			}
		}

		// Create material
		video::SMaterial material;
		material.setFlag(video::EMF_LIGHTING, false);
		material.setFlag(video::EMF_BACK_FACE_CULLING, true);
		material.setFlag(video::EMF_BILINEAR_FILTER, false);
		material.setFlag(video::EMF_FOG_ENABLE, true);
		//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
		//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE);
		//material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
		material.setTexture(0, p.tile.texture);

		if (enable_shaders) {
			ITextureSource *tsrc = data->m_gamedef->tsrc();
			material.setTexture(2, tsrc->getTexture("disable_img.png"));
			if (enable_bumpmapping || enable_parallax_occlusion) {
				std::string fname_base = tsrc->getTextureName(p.tile.texture_id);
				std::string normal_ext = "_normal.png";
				size_t pos = fname_base.find(".");
				std::string fname_normal = fname_base.substr(0, pos) + normal_ext;

				if (tsrc->isKnownSourceImage(fname_normal)) {
					// look for image extension and replace it 
					size_t i = 0;
					while ((i = fname_base.find(".", i)) != std::string::npos) {
						fname_base.replace(i, 4, normal_ext);
						i += normal_ext.length();
					}
					material.setTexture(1, tsrc->getTexture(fname_base));
					material.setTexture(2, tsrc->getTexture("enable_img.png"));
				}
			}
			p.tile.applyMaterialOptionsWithShaders(material,
				shadermat1, shadermat2, shadermat3, shadermat4, shadermat5);
		} else {
			p.tile.applyMaterialOptions(material);
		}
		// Create meshbuffer

		// This is a "Standard MeshBuffer",
		// it's a typedeffed CMeshBuffer<video::S3DVertex>
		scene::SMeshBuffer *buf = new scene::SMeshBuffer();
		// Set material
		buf->Material = material;
		// Add to mesh
		m_mesh->addMeshBuffer(buf);
		// Mesh grabbed it
		buf->drop();
		buf->append(&p.vertices[0], p.vertices.size(),
				&p.indices[0], p.indices.size());
	}

	m_camera_offset = camera_offset;
	
开发者ID:andrew889,项目名称:minetest-1,代码行数:66,代码来源:mapblock_mesh.cpp


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