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


C++ IMaterialVar::GetStringValue方法代码示例

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


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

示例1: LoadMaterialHeader

//-----------------------------------------------------------------------------
// Purpose: 
// Input  : material - 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CMaterial::LoadMaterialHeader( IMaterial *pMat )
{

	PreviewImageRetVal_t retVal;
	bool translucentBaseTexture;
	ImageFormat eImageFormat;
	int width, height;
	retVal = CPreviewImagePropertiesCache::GetPreviewImageProperties( pMat, &width, &height, &eImageFormat, &translucentBaseTexture);
	if (retVal == MATERIAL_PREVIEW_IMAGE_BAD)
		return false;

	m_pMaterial = pMat;
	m_pMaterial->IncrementReferenceCount();

	m_nWidth = width;
	m_nHeight = height;
	m_TranslucentBaseTexture = translucentBaseTexture; 

	// Find the keywords for this material from the vmt file.
	bool bFound;
	IMaterialVar *pVar = pMat->FindVar("%keywords", &bFound, false);
	if (bFound)
	{
		strcpy(m_szKeywords, pVar->GetStringValue());

		// Register the keywords
		g_Textures.RegisterTextureKeywords( this );
	}

	return(true);
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:36,代码来源:material.cpp

示例2: IsWater

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CMaterial::IsWater( void ) const
{
	bool bFound;
	IMaterialVar *pVar = m_pMaterial->FindVar( "$surfaceprop", &bFound, false );
	if ( bFound )
	{
		if ( !strcmp( "water", pVar->GetStringValue() ) )
			return true;
	}

	return false;
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:15,代码来源:material.cpp

示例3:

const char *GetMaterialVar( MaterialSystemMaterial_t materialHandle, const char *propertyName )
{
	IMaterial *material = ( IMaterial * )materialHandle;
	IMaterialVar *var;
	bool found;
	var = material->FindVar( propertyName, &found, false );
	if( found )
	{
		return var->GetStringValue();
	}
	else
	{
		return NULL;
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:15,代码来源:utilmatlib.cpp

示例4: LoadSrcVTFFiles

//-----------------------------------------------------------------------------
// Loads VTF files
//-----------------------------------------------------------------------------
static bool LoadSrcVTFFiles( IVTFTexture *pSrcVTFTextures[6], const char *pSkyboxMaterialBaseName,
							int *pUnionTextureFlags, bool bHDR )
{
	const char *facingName[6] = { "rt", "lf", "bk", "ft", "up", "dn" };
	int i;
	for( i = 0; i < 6; i++ )
	{
		char srcMaterialName[1024];
		sprintf( srcMaterialName, "%s%s", pSkyboxMaterialBaseName, facingName[i] );

		IMaterial *pSkyboxMaterial = g_pMaterialSystem->FindMaterial( srcMaterialName, "skybox" );
		IMaterialVar *pSkyTextureVar = pSkyboxMaterial->FindVar( bHDR ? "$hdrbasetexture" : "$basetexture", NULL );
		const char *vtfName = pSkyTextureVar->GetStringValue();
		char srcVTFFileName[MAX_PATH];
		Q_snprintf( srcVTFFileName, MAX_PATH, "materials/%s.vtf", vtfName );

		CUtlBuffer buf;
		if( !g_pFullFileSystem->ReadFile( srcVTFFileName, NULL, buf ) )
			return false;

		pSrcVTFTextures[i] = CreateVTFTexture();
		if (!pSrcVTFTextures[i]->Unserialize(buf))
		{
			Warning("*** Error unserializing skybox texture: %s\n", pSkyboxMaterialBaseName );
			return false;
		}

		*pUnionTextureFlags |= pSrcVTFTextures[i]->Flags();
		int flagsNoAlpha = pSrcVTFTextures[i]->Flags() & ~( TEXTUREFLAGS_EIGHTBITALPHA | TEXTUREFLAGS_ONEBITALPHA );
		int flagsFirstNoAlpha = pSrcVTFTextures[0]->Flags() & ~( TEXTUREFLAGS_EIGHTBITALPHA | TEXTUREFLAGS_ONEBITALPHA );
		if ( (pSrcVTFTextures[i]->Width() != pSrcVTFTextures[0]->Width()) ||
			 (pSrcVTFTextures[i]->Height() != pSrcVTFTextures[0]->Height()) ||
			 (flagsNoAlpha != flagsFirstNoAlpha) )
		{
			Warning("*** Error: Skybox vtf files for %s weren't compiled with the same size texture and/or same flags!\n", pSkyboxMaterialBaseName );
			return false;
		}
		if( bHDR )
		{
			pSrcVTFTextures[i]->ConvertImageFormat( IMAGE_FORMAT_RGB323232F, false );
			pSrcVTFTextures[i]->GenerateMipmaps();
			pSrcVTFTextures[i]->ConvertImageFormat( IMAGE_FORMAT_RGBA16161616F, false );
		}
	}

	return true;
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:50,代码来源:cubemap.cpp

示例5: Spawn

//------------------------------------------------------------------------------
// Purpose :
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CBreakableSurface::Spawn(void)
{
	BaseClass::Spawn();
	SetCollisionGroup( COLLISION_GROUP_BREAKABLE_GLASS ); 
	m_bIsBroken = false;

	if (m_nQuadError == QUAD_ERR_MULT_FACES)
	{
		Warning("Rejecting func_breakablesurf.  Has multiple faces that aren't NODRAW.\n");
		UTIL_Remove(this);
	}
	else if (m_nQuadError == QUAD_ERR_NOT_QUAD)
	{
		Warning("Rejecting func_breakablesurf.  Drawn face isn't a quad.\n");
		UTIL_Remove(this);
	}

	int materialCount = modelinfo->GetModelMaterialCount( const_cast<model_t*>(GetModel()) );
	if( materialCount != 1 )
	{
		Warning( "Encountered func_breakablesurf that has a material applied to more than one surface!\n" );
		UTIL_Remove(this);
	}

	// Get at the first material; even if there are more than one.
	IMaterial* pMaterial;
	modelinfo->GetModelMaterials( const_cast<model_t*>(GetModel()), 1, &pMaterial );

	// The material should point to a cracked version of itself
	bool foundVar;
	IMaterialVar* pCrackName = pMaterial->FindVar( "$crackmaterial", &foundVar, false );
	if (foundVar)
	{
		PrecacheMaterial( pCrackName->GetStringValue() );
	}

	// Init the Panel bit vector to all true. ( no panes are broken )
	int bitVecLength = MAX_NUM_PANELS * MAX_NUM_PANELS;
	
	for( int i=0;i<bitVecLength;i++ )
	{
		m_RawPanelBitVec.Set( i, true );
	}
}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:49,代码来源:func_breakablesurf.cpp

示例6: Reload

//-----------------------------------------------------------------------------
// Reloads owing to a material change
//-----------------------------------------------------------------------------
void CMaterial::Reload( bool bFullReload )
{
	// Don't bother if we're not loaded yet
	if (!m_bLoaded)
		return;

	FreeData();

	if ( m_pMaterial )
	{
		m_pMaterial->DecrementReferenceCount();
	}
	m_pMaterial = materials->FindMaterial(m_szFileName, TEXTURE_GROUP_OTHER);
	Assert( m_pMaterial );

	if ( bFullReload )
		m_pMaterial->Refresh();

	PreviewImageRetVal_t retVal;
	bool translucentBaseTexture;
	ImageFormat eImageFormat;
	int width, height;
	retVal = m_pMaterial->GetPreviewImageProperties(&width, &height, &eImageFormat, &translucentBaseTexture);
	if (retVal == MATERIAL_PREVIEW_IMAGE_BAD)
		return;

	m_nWidth = width;
	m_nHeight = height;
	m_TranslucentBaseTexture = translucentBaseTexture; 

	// Find the keywords for this material from the vmt file.
	bool bFound;
	IMaterialVar *pVar = m_pMaterial->FindVar("%keywords", &bFound, false);
	if (bFound)
	{
		strcpy(m_szKeywords, pVar->GetStringValue());

		// Register the keywords
		g_Textures.RegisterTextureKeywords( this );
	}
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:44,代码来源:material.cpp

示例7: LoadCamoPattern

void CCamoMaterialProxy::LoadCamoPattern( void )
{
#if 0
	// hack - need to figure out a name to attach that isn't too long.
	m_pCamoPatternImage = 
		( unsigned char * )datacache->FindByName( &m_camoImageDataCache, "camopattern" );
	
	if( m_pCamoPatternImage )
	{
		// is already in the cache.
		return m_pCamoPatternImage;
	}
#endif
	
	enum ImageFormat indexImageFormat;
	int indexImageSize;
#ifndef _XBOX
	float dummyGamma;
	if( !TGALoader::GetInfo( m_pCamoPatternTextureVar->GetStringValue(), 
		&m_CamoPatternWidth, &m_CamoPatternHeight, &indexImageFormat, &dummyGamma ) )
	{
		//Warning( "Can't get tga info for hl2/materials/models/combine_elite/camo7paletted.tga for camo material\n" );
		m_pCamoTextureVar = NULL;
		return;
	}
#else
	// xboxissue - no tga support, why implemented this way
	Assert( 0 );
	m_pCamoTextureVar = NULL;
	return;
#endif
	
	if( indexImageFormat != IMAGE_FORMAT_I8 )
	{
		//	Warning( "Camo material texture hl2/materials/models/combine_elite/camo7paletted.tga must be 8-bit greyscale\n" );
		m_pCamoTextureVar = NULL;
		return;
	}
	
	indexImageSize = ImageLoader::GetMemRequired( m_CamoPatternWidth, m_CamoPatternHeight, 1, indexImageFormat, false );
#if 0
	m_pCamoPatternImage = ( unsigned char * )
		datacache->Alloc( &m_camoImageDataCache, indexImageSize, "camopattern" );
#endif
	m_pCamoPatternImage = ( unsigned char * )new unsigned char[indexImageSize];
	if( !m_pCamoPatternImage )
	{
		m_pCamoTextureVar = NULL;
		return;
	}
	
#ifndef _XBOX
	if( !TGALoader::Load( m_pCamoPatternImage, m_pCamoPatternTextureVar->GetStringValue(),
		m_CamoPatternWidth, m_CamoPatternHeight, IMAGE_FORMAT_I8, dummyGamma, false ) )
	{
		//			Warning( "camo texture hl2/materials/models/combine_elite/camo7paletted.tga must be grey-scale" );
		m_pCamoTextureVar = NULL;
		return;
	}
#else
	// xboxissue - no tga support, why is the camo done this way?
	Assert( 0 );
#endif
	
	bool colorUsed[256];
	int colorRemap[256];
	// count the number of colors used in the image.
	int i;
	for( i = 0; i < 256; i++ )
	{
		colorUsed[i] = false;
	}
	for( i = 0; i < indexImageSize; i++ )
	{
		colorUsed[m_pCamoPatternImage[i]] = true;
	}
	m_CamoPatternNumColors = 0;
	for( i = 0; i < 256; i++ )
	{
		if( colorUsed[i] )
		{
			colorRemap[i] = m_CamoPatternNumColors;
			m_CamoPatternNumColors++;
		}
	}
	// remap the color to the beginning of the palette.
	for( i = 0; i < indexImageSize; i++ )
	{
		m_pCamoPatternImage[i] = colorRemap[m_pCamoPatternImage[i]];
		// hack
//		m_pCamoPatternImage[i] = 0;
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:93,代码来源:camomaterialproxy.cpp

示例8: LoadSrcVTFFiles

//-----------------------------------------------------------------------------
// Loads VTF files
//-----------------------------------------------------------------------------
static bool LoadSrcVTFFiles( IVTFTexture *pSrcVTFTextures[6], const char *pSkyboxMaterialBaseName,
							int *pUnionTextureFlags, bool bHDR )
{
	const char *facingName[6] = { "rt", "lf", "bk", "ft", "up", "dn" };
	int i;
	for( i = 0; i < 6; i++ )
	{
		char srcMaterialName[1024];
		sprintf( srcMaterialName, "%s%s", pSkyboxMaterialBaseName, facingName[i] );

		IMaterial *pSkyboxMaterial = g_pMaterialSystem->FindMaterial( srcMaterialName, "skybox" );
		//IMaterialVar *pSkyTextureVar = pSkyboxMaterial->FindVar( bHDR ? "$hdrbasetexture" : "$basetexture", NULL ); //, bHDR ? false : true );
		IMaterialVar *pSkyTextureVar = pSkyboxMaterial->FindVar( "$basetexture", NULL ); // Since we're setting it to black anyway, just use $basetexture for HDR
		const char *vtfName = pSkyTextureVar->GetStringValue();
		char srcVTFFileName[MAX_PATH];
		Q_snprintf( srcVTFFileName, MAX_PATH, "materials/%s.vtf", vtfName );

		CUtlBuffer buf;
		if ( !g_pFullFileSystem->ReadFile( srcVTFFileName, NULL, buf ) )
		{
			// Try looking for a compressed HDR texture
			if ( bHDR )
			{
				/* // FIXME: We need a way to uncompress this format!
				bool bHDRCompressed = true;

				pSkyTextureVar = pSkyboxMaterial->FindVar( "$hdrcompressedTexture", NULL );
				vtfName = pSkyTextureVar->GetStringValue();
				Q_snprintf( srcVTFFileName, MAX_PATH, "materials/%s.vtf", vtfName );

				if ( !g_pFullFileSystem->ReadFile( srcVTFFileName, NULL, buf ) )
				*/
				{
					return false;
				}
			}
			else
			{
				return false;
			}
		}

		pSrcVTFTextures[i] = CreateVTFTexture();
		if (!pSrcVTFTextures[i]->Unserialize(buf))
		{
			Warning("*** Error unserializing skybox texture: %s\n", pSkyboxMaterialBaseName );
			return false;
		}

		*pUnionTextureFlags |= pSrcVTFTextures[i]->Flags();
		int flagsNoAlpha = pSrcVTFTextures[i]->Flags() & ~( TEXTUREFLAGS_EIGHTBITALPHA | TEXTUREFLAGS_ONEBITALPHA );
		int flagsFirstNoAlpha = pSrcVTFTextures[0]->Flags() & ~( TEXTUREFLAGS_EIGHTBITALPHA | TEXTUREFLAGS_ONEBITALPHA );
		
		// NOTE: texture[0] is a side texture that could be 1/2 height, so allow this and also allow 4x4 faces
		if ( ( ( pSrcVTFTextures[i]->Width() != pSrcVTFTextures[0]->Width() ) && ( pSrcVTFTextures[i]->Width() != 4 ) ) ||
			 ( ( pSrcVTFTextures[i]->Height() != pSrcVTFTextures[0]->Height() ) && ( pSrcVTFTextures[i]->Height() != pSrcVTFTextures[0]->Height()*2 )  && ( pSrcVTFTextures[i]->Height() != 4 ) ) ||
			 ( flagsNoAlpha != flagsFirstNoAlpha ) )
		{
			Warning("*** Error: Skybox vtf files for %s weren't compiled with the same size texture and/or same flags!\n", pSkyboxMaterialBaseName );
			return false;
		}

		if ( bHDR )
		{
			pSrcVTFTextures[i]->ConvertImageFormat( IMAGE_FORMAT_RGB323232F, false );
			pSrcVTFTextures[i]->GenerateMipmaps();
			pSrcVTFTextures[i]->ConvertImageFormat( IMAGE_FORMAT_RGBA16161616F, false );
		}
	}

	return true;
}
开发者ID:Baer42,项目名称:source-sdk-2013,代码行数:75,代码来源:cubemap.cpp


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