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


C++ BitmapTex::GetUVGen方法代码示例

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


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

示例1: createAndAssignTexture

	//------------------------------
	void MaterialCreator::createAndAssignTexture( Mtl* material, 
												  const COLLADAFW::EffectCommon& effectCommon, 
												  const COLLADAFW::ColorOrTexture& (COLLADAFW::EffectCommon::*f)() const, 
												  int slot,
												  unsigned char mapChannel)
	{
		const COLLADAFW::ColorOrTexture& colorOrTexture = (effectCommon.*f)();
		if ( colorOrTexture.isTexture() )
		{
			BitmapTex* texture = createTexture( effectCommon, colorOrTexture.getTexture() );
			texture->GetUVGen()->SetMapChannel( mapChannel );

			assignTextureToMaterial(material, slot, texture);
		}
	}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:16,代码来源:COLLADAMaxMaterialCreator.cpp

示例2: SetEnvironmentMap

void UtilTest::SetEnvironmentMap()
{
    // Make a bitmap texture map.
    BitmapTex *map = NewDefaultBitmapTex();

    // Get the UVGen
    StdUVGen *uvGen = map->GetUVGen();

    // Set up the coords. to be screen environment.
    uvGen->SetCoordMapping(UVMAP_SCREEN_ENV);

    // Set the bitmap file.
    map->SetMapName(_T("A_MAX.TGA"));

    // Make this the new environment map.
    ip->SetEnvironmentMap(map);
}
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:17,代码来源:utiltest.cpp

示例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))
					{
开发者ID:fernandojsg,项目名称:sgzsourcepack,代码行数:67,代码来源:BuildShaders.cpp

示例4: ConvertMaterial

//----------------------------------------------------------------------------
void SceneBuilder::ConvertMaterial (Mtl &mtl, MtlTree &mtlTree)
{
	// 光照属性
	PX2::Shine *shine = new0 PX2::Shine;
	Color color = mtl.GetAmbient();
	float alpha = 1.0f - mtl.GetXParency();
	shine->Ambient = PX2::Float4(color.r, color.g, color.b, 1.0f);
	color = mtl.GetDiffuse();
	shine->Diffuse = PX2::Float4(color.r, color.g, color.b, alpha);
	color = mtl.GetSpecular();
	float shininess = mtl.GetShininess()*2.0f;
	shine->Specular = PX2::Float4(color.r, color.g, color.b, shininess);

	const char *name = (const char*)mtl.GetName();
	shine->SetName(name);

	mtlTree.SetShine(shine);

	bool IsDirect9Shader = false;

	if (mtl.ClassID() == Class_ID(CMTL_CLASS_ID, 0)
		|| mtl.ClassID() == Class_ID(DMTL_CLASS_ID, 0))
	{
		StdMat2 *stdMat2 = (StdMat2*)(&mtl);
		Interval valid = FOREVER;
		stdMat2->Update(mTimeStart, valid);

		std::string strName(stdMat2->GetName());
		bool doubleSide = (stdMat2->GetTwoSided()==1);

		char strBitMapName[256];
		memset(strBitMapName, 0, 256*sizeof(char));
		std::string resourcePath;

		PX2::Shader::SamplerFilter filter = PX2::Shader::SF_LINEAR_LINEAR;
		PX2::Shader::SamplerCoordinate uvCoord = PX2::Shader::SC_REPEAT;
		PX2_UNUSED(uvCoord);

		if (stdMat2->MapEnabled(ID_DI))
		{
			BitmapTex *tex = (BitmapTex*)stdMat2->GetSubTexmap(ID_DI);

			BitmapInfo bI;
			const char *mapName = tex->GetMapName();
			TheManager->GetImageInfo(&bI, mapName);
			strcpy(strBitMapName, bI.Name());

			std::string fullName = std::string(strBitMapName);
			std::string::size_type sizeT = fullName.find_first_not_of(mSettings->SrcRootDir);
			resourcePath = std::string(strBitMapName).substr(sizeT);

			StdUVGen* uvGen = tex->GetUVGen();
			PX2_UNUSED(uvGen);
			int filType = tex->GetFilterType();
			switch (filType)
			{
				case FILTER_PYR:
					filter = PX2::Shader::SF_LINEAR_LINEAR;
					break;
				case FILTER_SAT:
					filter = PX2::Shader::SF_NEAREST;
					break;
				default:
					break;
			}
		}
		else
		{
			sprintf(strBitMapName, "%s/%s", mSettings->SrcRootDir, PX2_DEFAULT_TEXTURE);
			resourcePath = PX2_DEFAULT_TEXTURE;
		}

		PX2::Texture2D *tex2d = PX2::DynamicCast<PX2::Texture2D>(
			PX2::ResourceManager::GetSingleton().BlockLoad(strBitMapName));
		tex2d->SetResourcePath(resourcePath);

		if (tex2d)
		{
			PX2::Texture2DMaterial *tex2dMtl = new0 PX2::Texture2DMaterial(filter, 
				uvCoord, uvCoord);
			if (doubleSide)
			{
				tex2dMtl->GetCullProperty(0, 0)->Enabled = false;
			}

			PX2::MaterialInstance *instance = tex2dMtl->CreateInstance(tex2d);

			mtlTree.SetMaterialInstance(instance);
		}
		else
		{
			PX2::VertexColor4Material *vcMtl = new0 PX2::VertexColor4Material();
			PX2::MaterialInstance *instance = vcMtl->CreateInstance();
			mtlTree.SetMaterialInstance(instance);
		}
	}
	else if (mtl.ClassID() == Class_ID(MULTI_CLASS_ID, 0))
	{
	}
//.........这里部分代码省略.........
开发者ID:manyxu,项目名称:Phoenix3D_2.0,代码行数:101,代码来源:PX2SceneBuilderMtl.cpp

示例5: GetMtlAnim

bool SGP_MaxInterface::GetMtlAnim( StdMat* pStdMtl, ColorTrack& track, int nChannel )
{
	if( pStdMtl == NULL )
	{
		assert( false && "std mtl is NULL" );
		return false;
	}

	int nFrameCount = 0;
	TimeValue nStartTick = GetStartTick();
	TimeValue nEndTick = GetEndTick();
	int nTickPerFrame = GetTickPerFrame();



	track.bTiling = false;

	StdUVGen *uv = NULL;

	Texmap *tx = pStdMtl->GetSubTexmap(nChannel);
	if( tx )
	{
		if( tx->ClassID() == Class_ID( BMTEX_CLASS_ID, 0 ) )
		{
			BitmapTex *bmt = (BitmapTex*)tx;
			uv = bmt->GetUVGen();
			if( uv )
			{
				track.nUTile = (int)uv->GetUScl(0);
				track.nVTile = (int)uv->GetVScl(0);
				if( track.nUTile == 1 && track.nVTile == 1 )
					track.bTiling = false;
				else
					track.bTiling = true;
				track.nStartFrame = bmt->GetStartTime();
				track.fPlaybackRate = bmt->GetPlaybackRate();
				track.nLoopMode = bmt->GetEndCondition();

				if( uv->GetUAng( 0 ) != 0.0f ||
					uv->GetVAng( 0 ) != 0.0f )
				{
					track.fUSpeed = uv->GetUAng( 0 ) / piOver180;
					track.fVSpeed = uv->GetVAng( 0 ) / piOver180;
					track.bUVMoving = true;
				}
				else
					track.bUVMoving = false;
			}
		}
	}


	TimeValue t;
	for( t = nStartTick; t <= nEndTick; t += nTickPerFrame )
		nFrameCount++;


	track.ColorKeyFrame.resize( nFrameCount );

	t = nStartTick;
	for( int i = 0; i < nFrameCount; i++, t += nTickPerFrame )
	{
		SGP_ColorKey key;
		memset( &key, 0x00, sizeof( key ) );
		Color diffuse	= pStdMtl->GetDiffuse( t );
		Color ambient	= pStdMtl->GetAmbient( t );
		Color specular	= pStdMtl->GetSpecular( t );

		Color filter	= pStdMtl->GetFilter( t );
		float alpha		= pStdMtl->GetOpacity( t );
		float shinstr	= pStdMtl->GetShinStr(t);
		float selfillum = pStdMtl->GetSelfIllum( t );

		float uoffset	= 0;
		float voffset	= 0;
		if( uv )
		{
			uoffset	= uv->GetUOffs( t );
			voffset	= uv->GetVOffs( t );
		}
/*
		int	nTransparencyType = pStdMtl->GetTransparencyType();

		key.dwBlendMode = 0;
		switch( nTransparencyType )
		{
		case TRANSP_SUBTRACTIVE:
			key.dwBlendMode |= HR3D_MDX2_MODULATE;
			break;
		case TRANSP_ADDITIVE:
			key.dwBlendMode |= HR3D_MDX2_ADD;
			break;
		case TRANSP_FILTER:
			key.dwBlendMode |= HR3D_MDX2_MODULATE2X;
			break;
		default:
			break;
		};
*/
		key.dr = diffuse.r;
//.........这里部分代码省略.........
开发者ID:phoenixzz,项目名称:SGPEngine,代码行数:101,代码来源:SGP_MAX9Interface.cpp

示例6: LoadMaterials

void Import::LoadMaterials (dScene& scene, MaterialCache& materialCache)
{
    dScene::Iterator iter (scene);
    for (iter.Begin(); iter; iter ++) {
        dScene::dTreeNode* const materialNode = iter.GetNode();
        dNodeInfo* const info = scene.GetInfoFromNode(materialNode);
        if (info->IsType(dMaterialNodeInfo::GetRttiType())) {
            MaterialProxi material;
            material.m_mtl = NewDefaultStdMat();
            StdMat* const stdMtl = (StdMat*)material.m_mtl;

            dMaterialNodeInfo* const materialInfo = (dMaterialNodeInfo*) info;
            stdMtl->SetName(materialInfo->GetName());

            dVector ambient (materialInfo->GetAmbientColor());
            dVector difusse (materialInfo->GetDiffuseColor());
            dVector specular (materialInfo->GetSpecularColor());
            float shininess (materialInfo->GetShininess());
            //float shininessStr (materialInfo->GetShinStr());
            float transparency (materialInfo->GetOpacity());

            stdMtl->SetAmbient(*((Point3*)&ambient), 0);
            stdMtl->SetDiffuse(*((Point3*)&difusse), 0);
            stdMtl->SetSpecular(*((Point3*)&specular), 0);
            stdMtl->SetShinStr(shininess / 100.0f, 0);
            stdMtl->SetOpacity(transparency, 0);


            if (materialInfo->GetDiffuseTextId() != -1) {
                dScene::dTreeNode* textNode = scene.FindTextureByTextId(materialNode, materialInfo->GetDiffuseTextId());
                if (textNode) {
                    _ASSERTE (textNode);
                    //				BitmapTex* bmtex;
                    //				const TCHAR* txtName;

                    dTextureNodeInfo* textureInfo = (dTextureNodeInfo*) scene.GetInfoFromNode(textNode);
                    TCHAR txtNameBuffer[256];
                    sprintf (txtNameBuffer, "%s/%s", m_path, textureInfo->GetPathName());

                    const TCHAR* txtName = txtNameBuffer;
                    BitmapTex* bmtex = (BitmapTex*)NewDefaultBitmapTex();
                    bmtex->SetMapName((TCHAR*)txtName);

                    txtName = textureInfo->GetPathName();
                    bmtex->SetName (txtName);
                    bmtex->GetUVGen()->SetMapChannel(1);

                    stdMtl->SetSubTexmap(ID_DI, bmtex);
                    stdMtl->SetTexmapAmt(ID_DI, 1.0f, 0);
                    stdMtl->EnableMap(ID_DI, TRUE);

                    //					const char* materialOpanacity = segment.m_opacityTextureName;
                    //					if (materialOpanacity[0]) {
                    //						BitmapTex* bmtex;
                    //						const TCHAR* txtName;
                    //
                    //						txtName = segment.m_opacityPathName;
                    //						bmtex = (BitmapTex*)NewDefaultBitmapTex();
                    //						bmtex->SetMapName((TCHAR*)txtName);
                    //
                    //						txtName = materialName;
                    //						bmtex->SetName (txtName);
                    //						bmtex->GetUVGen()->SetMapChannel(2);
                    //
                    //						stdMtl->SetSubTexmap(ID_OP, bmtex);
                    //						stdMtl->SetTexmapAmt(ID_OP, 1.0f, 0);
                    //						stdMtl->EnableMap(ID_OP, TRUE);
                    //					}
                    //				materialCache.AddMaterial(material, segment.m_textureName);
                }
            }
            materialCache.AddMaterial(material, materialInfo->GetId());
        }
    }
}
开发者ID:Naddiseo,项目名称:Newton-Dynamics-fork,代码行数:75,代码来源:Import.cpp

示例7: DumpTexture

//----------------------------------------------------------------------------------
// dump material textures
void DumpTexture(m_material *pMat, IGameMaterial *pGMaxMat)
{
	std::vector<tex_channel>		bk_tex_channel;
	std::vector<unsigned int>		bk_tex_idx;
    std::vector<MatTextureInfo>		TexInfos;

	int texCount = pGMaxMat->GetNumberOfTextureMaps();

	for (int i = 0; i < texCount; ++i)
	{
		IGameTextureMap * pGMaxTex = pGMaxMat->GetIGameTextureMap(i);

		int tex_type = pGMaxTex->GetStdMapSlot();

		if (pGMaxTex->IsEntitySupported() && tex_type >= 0)	//its a bitmap texture
		{
			MatTextureInfo TexInfo;
			tex_channel tc;

			TexInfo.mat_id = pMat->id;

			m_texture * pTex = new m_texture;

			std::string pathname = pGMaxTex->GetBitmapFileName();

			int idx = (int)pathname.rfind('\\');
			if (idx == INDEX_NONE){
				idx = (int)pathname.rfind('/');
			}
			
			std::string filename = pathname.substr(idx + 1, INDEX_NONE);

			pTex->name = filename;

			// set the texture xform...
			IGameUVGen *pUVGen = pGMaxTex->GetIGameUVGen();
			GMatrix UVMat = pUVGen->GetUVTransform();
            TexInfo.tex_mat = pTex->tex_mat = (scalar*)UVMat.GetAddr(); // save mapping matrix

          	// get the uv channel to use...
			Texmap *pTMap = pGMaxTex->GetMaxTexmap();
			BitmapTex *pBTex = (BitmapTex*)pTMap;
			StdUVGen *pStdUVGen = pBTex->GetUVGen();

			if (pStdUVGen){
				tc.channel = pStdUVGen->GetMapChannel() - 1;
			}

			IParamBlock2 *pUVWCropParam = (IParamBlock2*)(pBTex->GetReference(1));

			if (pUVWCropParam)
			{
				 pUVWCropParam->GetValue(0, ExporterMAX::GetExporter()->GetStaticFrame(), TexInfo.uv_offset.x, FOREVER);
				 pUVWCropParam->GetValue(1, ExporterMAX::GetExporter()->GetStaticFrame(), TexInfo.uv_offset.y, FOREVER);
				 pUVWCropParam->GetValue(2, ExporterMAX::GetExporter()->GetStaticFrame(), TexInfo.uv_scale.x,  FOREVER);
				 pUVWCropParam->GetValue(3, ExporterMAX::GetExporter()->GetStaticFrame(), TexInfo.uv_scale.y,  FOREVER);
			}

			// set the type of texture...
			pTex->type = texture_type[tex_type];

 			// if we have a bump map, we create a normal map with the convention
 			// that the filename will be the same name as the bump map + "_normal" 
 			// appended to it.
  			if (pTex->type == m_texture::BUMP)
 			{
 				std::string normal_map = pTex->name;
 				std::string::size_type pos = normal_map.rfind(".");
 				normal_map.insert(pos, "_normal");
 
 				m_texture  *pTexNormal = new m_texture;
 				*pTexNormal = *pTex;
 
 				pTexNormal->name = normal_map;
 				pTexNormal->type = m_texture::NORMAL;
 
 				tc.pTex = pTexNormal;
 
 				bk_tex_channel.push_back(tc);	// add the new texture to the local TOC
 				TexInfos.push_back(TexInfo);
 			}

			 tc.pTex = pTex;
						 
			 bk_tex_channel.push_back(tc);	// add the new texture to the local TOC
			 TexInfos.push_back(TexInfo);
		}
	}

	// lets check if we don't have them already in our global TOC...
	for (size_t index = 0; index < bk_tex_channel.size(); ++index)
	{
		m_texture * pTex = bk_tex_channel[index].pTex;

		unsigned int idx = ExporterMAX::GetExporter()->FindTexture(pTex);
		
		if (idx == INDEX_NONE){	
			idx = ExporterMAX::GetExporter()->AddTexture(pTex); // add the new texture to the TOC
//.........这里部分代码省略.........
开发者ID:innovatelogic,项目名称:ilogic-vm,代码行数:101,代码来源:MaterialExporter.cpp


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