本文整理汇总了C++中BitmapTex::GetBitmap方法的典型用法代码示例。如果您正苦于以下问题:C++ BitmapTex::GetBitmap方法的具体用法?C++ BitmapTex::GetBitmap怎么用?C++ BitmapTex::GetBitmap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BitmapTex
的用法示例。
在下文中一共展示了BitmapTex::GetBitmap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BitmapDimensions
static void BitmapDimensions(int &width, int &height, Texmap * map)
{
// int h=dim; w=dim;
if(map == NULL){
//NH 05-Dec-05 This can happen when submaps are not assigned - in this case simply bail and let
//the parent texture deal with it.
// height = width = 0;
return;
}
if(map->ClassID() == GNORMAL_CLASS_ID)
{
Texmap * bmap;
map->GetParamBlock(0)->GetValue(2,0,bmap,FOREVER); // normal map
BitmapDimensions(width,height,bmap);
return;
}
else if(map->ClassID() == Class_ID(BMTEX_CLASS_ID, 0))
{
BitmapTex *pBT;
Bitmap *pTex;
pBT = static_cast<BitmapTex *>(map);
pTex = pBT->GetBitmap(0);
if (pTex)
{
width = getClosestPowerOf2(pTex->Width());
height = getClosestPowerOf2(pTex->Height());
}
return;
}
else{
}
}
示例2: IOException
P(GmMaterial) GmUtil::createGmMaterial( Mtl* material, Mtl* bakedmaterial )
{
require( material );
P(GmMaterial) s = new GmMaterial;
// get name
static int unnamedCount = 0;
if ( material->GetName().data() )
s->name = material->GetName().data();
else
s->name = "noname #"+String::valueOf( ++unnamedCount );
// Standard material (+Diffuse) (+ Reflection)
if ( material->ClassID() == Class_ID(DMTL_CLASS_ID,0) )
{
StdMat* stdmat = static_cast<StdMat*>(material);
StdMat* bakedmat = static_cast<StdMat*>(bakedmaterial);
// StdMat2?
StdMat2* stdmat2 = 0;
if ( stdmat->SupportsShaders() )
stdmat2 = static_cast<StdMat2*>( stdmat );
// uniform transparency
s->opacity = stdmat->GetOpacity(0);
// self illumination
s->selfIllum = stdmat->GetSelfIllum(0);
// two-sided material?
s->twosided = ( 0 != stdmat->GetTwoSided() );
// blending mode
s->blend = GmMaterial::BLEND_COPY;
if ( s->opacity < 1.f )
s->blend = GmMaterial::BLEND_MULTIPLY;
if ( stdmat->GetTransparencyType() == TRANSP_ADDITIVE )
s->blend = GmMaterial::BLEND_ADD;
// diffuse color
s->diffuseColor = toColorf( stdmat->GetDiffuse(0) );
// specular highlights
float shinStr = stdmat->GetShinStr(0);
s->specular = (shinStr > 0.f);
if ( s->specular )
{
float shininess = stdmat->GetShininess(0);
s->specularExponent = Math::pow( 2.f, shininess*10.f + 2.f );
s->specularColor = toColorf( stdmat->GetSpecular(0) ) * shinStr;
}
if ( bakedmat )
{
shinStr = bakedmat->GetShinStr(0);
s->specular = (shinStr > 0.f);
if ( s->specular )
{
float shininess = bakedmat->GetShininess(0);
s->specularExponent = Math::pow( 2.f, shininess*10.f + 2.f );
s->specularColor = toColorf( bakedmat->GetSpecular(0) ) * shinStr;
}
}
// diffuse texture layer
BitmapTex* tex = SceneExportUtil::getStdMatBitmapTex( stdmat, ID_DI );
if ( tex )
{
GmMaterial::TextureLayer& layer = s->diffuseLayer;
setLayerTex( layer, tex, s->name );
}
// opacity texture layer
tex = SceneExportUtil::getStdMatBitmapTex( stdmat, ID_OP );
if ( tex )
{
GmMaterial::TextureLayer& layer = s->opacityLayer;
setLayerTex( layer, tex, s->name );
// check alpha channel validity
Bitmap* bmp = tex->GetBitmap(0);
if ( bmp && !bmp->HasAlpha() )
Debug::printlnError( "Material \"{0}\" opacity map \"{1}\" must have image alpha channel.", s->name, tex->GetMapName() );
//throw IOException( Format("Material \"{0}\" opacity map \"{1}\" must have image alpha channel.", s->name, tex->GetMapName()) );
s->blend = GmMaterial::BLEND_MULTIPLY;
// check that opacity map is the same as diffuse map
if ( s->opacityLayer.filename != s->diffuseLayer.filename )
throw IOException( Format("Material \"{0}\" diffuse bitmap needs to be the same in opacity map.(diffuse map is \"{1}\" and opacity map is \"{2}\")", s->name, s->diffuseLayer.filename, s->opacityLayer.filename) );
if ( s->opacityLayer.coordset != s->diffuseLayer.coordset )
throw IOException( Format("Material \"{0}\" diffuse map texture coordinate set needs to be the same in opacity map.", s->name) );
if ( s->opacityLayer.env != s->diffuseLayer.env )
throw IOException( Format("Material \"{0}\" diffuse map texture coordinate generator needs to be the same in opacity map.", s->name) );
}
// reflection texture layer
tex = SceneExportUtil::getStdMatBitmapTex( stdmat, ID_RL );
if ( tex )
{
GmMaterial::TextureLayer& layer = s->reflectionLayer;
//.........这里部分代码省略.........
示例3: BuildShaders
//.........这里部分代码省略.........
{
if(i == 0)
{
LOG.Write("\n No diffuse. Skipping.");
break;
}
continue;
}
Texmap* pMaxTexmap = pStandardMtl->GetSubTexmap(nMap);
if(!pMaxTexmap)
{
if(i == 0)
{
LOG.Write("\n No diffuse. Skipping.");
break;
}
continue;
}
// Get texmaps
std::vector<std::string> vecTextures, vecPaths;
CShaderStandard::SLayerInfo layerInfo;
CShaderStandard::SBitmapInfo bitmapInfo;
if(pMaxTexmap->ClassID() == Class_ID(BMTEX_CLASS_ID, 0))
{
BitmapTex* pMaxBitmapTex = (BitmapTex*)pMaxTexmap;
Bitmap* pMaxBitmap = pMaxBitmapTex->GetBitmap(SECONDS_TO_TICKS(m_fStartTime));
StdUVGen* pMaxUVGen = pMaxBitmapTex->GetUVGen();
if(!pMaxBitmap)
{
if(i == 0)
{
LOG.Write("\n Invalid diffuse. Skipping.");
break;
}
continue;
}
assert(pMaxUVGen);
BitmapInfo bi = pMaxBitmap->Storage()->bi;
// bi.Name() returns the full path
// bi.Filename() returns just the filename
vecTextures.push_back(bi.Filename());
vecPaths. push_back(bi.Name());
LOG.Write("\n Bitmap %s", vecTextures[0].data());
// Check if diffuse texture has alpha channel
if(i == 0)
{
CBitmap bitmap;
CInputFile bitmapFile;
if(!bitmapFile.Open(bi.Name(), false))
示例4: GetStaticFrame
AWDTexture *
AWDExporter::ExportTexture(AWD *awd, awd_ncache *ncache,Texmap* tex, Class_ID cid, int subNo, AWDMaterial * mat ) {
AWDTexture *awd_tex;
const char* name;
int name_len;
bool hasAlpha = false;
MSTR path;
awd_uint8 * buf;
int buf_len;
if (!tex) return NULL;
if (tex->ClassID() != Class_ID(BMTEX_CLASS_ID, 0x00) ) return NULL;
// texture already exist in cache
awd_tex = (AWDTexture *)awd_ncache_get( ncache, tex );
if( awd_tex ) return awd_tex;
BitmapTex *bmptex = (BitmapTex*)tex;
MaxSDK::AssetManagement::AssetUser asset = bmptex->GetMap();
hasAlpha = bmptex->GetBitmap( GetStaticFrame() )->HasAlpha();
if( !asset.GetFullFilePath(path) ) {
fprintf( logfile, " export !asset.GetFullFilePath(path) : %i \n", asset.GetType() );
fflush( logfile );
//return NULL;
}
fprintf( logfile, " export : %s \n", path );
fflush( logfile );
AWD_tex_type textype = EXTERNAL;
if( GetIncludeMaps() &&
asset.GetType() == MaxSDK::AssetManagement::kBitmapAsset
) {
const char * dot;
dot = strrchr(path,'.');
if( !strcmp(dot, ".jpg")||
!strcmp(dot, ".JPG")||
!strcmp(dot, ".jpeg")||
!strcmp(dot, ".JPEG")
) {
textype = EMBEDDED_JPEG;
} else if (
!strcmp(dot, ".png")||
!strcmp(dot, ".PNG")
) {
textype = EMBEDDED_PNG;
}
if( textype == 0 ) {
fprintf( logfile, " export texture : %s \n", path );
fflush( logfile );
// try to extract data
Bitmap *bmp = bmptex->GetBitmap( GetStaticFrame() );
BitmapInfo bi;
MaxSDK::Util::Path *temppath;
bi.SetWidth( bmp->Width() );
bi.SetHeight( bmp->Height() );
if( hasAlpha ) {
bi.SetType( BMM_TRUE_32 );
bi.SetFlags( MAP_HAS_ALPHA );
path = "C:\\Users\\lepersp\\Desktop\\temp\\awdexporttempjpg.png";
textype = EMBEDDED_PNG;
} else {
bi.SetType( BMM_TRUE_24 );
path = "C:\\Users\\lepersp\\Desktop\\temp\\awdexporttempjpg.jpg";
textype = EMBEDDED_JPEG;
}
temppath = new MaxSDK::Util::Path( path );
bi.SetPath( *temppath );
bmp->OpenOutput( & bi );
bmp->Write( & bi );
bmp->Close(& bi);
}
//.........这里部分代码省略.........