Beispiel #1
0
//Method:  LoadTexture()
//Purpose: Retrieves an OpenGL texture identifier for the given image
//         filename. Loads the texture if necessary.
GLuint TextureManager::LoadTexture(const char *texname)
{
	//bail if no filename
	if (texname == NULL || strlen(texname) == 0) return 0;
	//return texture ID if we already have one
	GLuint texid = GetTexture(texname);
	if (texid != 0) return ((int)texid < 0 ? 0 : texid);
	//do a quick check to make sure it's a bitmap file
	FILE *file = fopen(texname, "r");
	if (!file) { AddTexture(texname, -1); return 0; }
	BYTE bm[2];
	fread(bm, 1, 2, file); //read two things of size one
	fclose(file);
	if (bm[0] != 'B' || bm[1] != 'M')
	{	AddTexture(texname, -1); return 0; }
	//load the texture from the file
//	AUX_RGBImageRec *teximage = auxDIBImageLoad(texname);
//	if (!teximage) { AddTexture(texname, -1); return 0; }
//	//bind the image to an OpenGL texture name
//	glGenTextures(1, &texid);
//	glBindTexture(GL_TEXTURE_2D, texid);
//	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
//	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
//	glTexImage2D(GL_TEXTURE_2D, 0, 3, teximage->sizeX, teximage->sizeY,
//		0, GL_RGB, GL_UNSIGNED_BYTE, teximage->data);
//	//delete the loaded texture, as it's no longer needed
//	if (teximage->data) free(teximage->data);
//	free(teximage);
//	//add the texture to the list, so we won't reload it from disk
//	AddTexture(texname, texid);
	return texid;
}
MOboolean moTextureManager::Init()
{
	if (m_pResourceManager){
		m_glmanager = m_pResourceManager->GetGLMan();
		m_fbmanager = m_pResourceManager->GetFBMan();
	} else return false;

	m_textures_array.Init(0, NULL);

	m_preview_texture_idx = AddTexture("preview_texture", 1024, 1024);
	//AddTexture("texture_clip1", 1024, 768);
	//AddTexture("texture_clip2", 1024, 768);
	//AddTexture("texture_clip3", 1024, 768);

	int m_id_default = AddTexture( "default", 256, 256);
	moTexture* DefaultTexture =  GetTexture(m_id_default);
    if (DefaultTexture) DefaultTexture->BuildFromFile(
        m_pResourceManager->GetDataMan()->GetAppPath() +
        moSlash +
        moText("..") +
        moSlash +
        moText("..") +
        moSlash +
        moText("art") +
        moSlash +
        moText("icons") +
        moSlash +
        moText("moldeologo.png")
    );

	return (m_glmanager && m_fbmanager);
}
void ResourceManager::CopyFrom( const ResourceManager& other ) {
	Clear();

	FontMap::const_iterator font_iter( other.m_fonts.begin() );
	FontMap::const_iterator font_iter_end( other.m_fonts.end() );

	for( ; font_iter != font_iter_end; ++font_iter ) {
		if( font_iter->second.second ) {
			const sf::Font* new_font( new sf::Font( *font_iter->second.first ) );
			AddFont( font_iter->first, *new_font, true );
		}
		else {
			AddFont( font_iter->first, *font_iter->second.first, false );
		}
	}

	TextureMap::const_iterator tex_iter( other.m_textures.begin() );
	TextureMap::const_iterator tex_iter_end( other.m_textures.end() );

	for( ; tex_iter != tex_iter_end; ++tex_iter ) {
		if( tex_iter->second.second ) {
			const sf::Texture* new_texture( new sf::Texture( *tex_iter->second.first ) );
			AddTexture( tex_iter->first, *new_texture, true );
		}
		else {
			AddTexture( tex_iter->first, *tex_iter->second.first, false );
		}
	}
}
Beispiel #4
0
void TextureManager::SetStandarMode()
{

	textureVector.clear();
	AddTexture(0, 0, STANDAR_TEXTURE_PATH, UNIFORM_NAME_TEXTURE_COLOR);
	AddTexture(1, 1, STANDAR_TEXTURE_NORMAL_PATH, UNIFORM_NAME_TEXTURE_NORMAL);
	AddTexture(2, 2, STANDAR_TEXTURE_SPECULAR_PATH, UNIFORM_NAME_TEXTURE_SPECULAR);
}
Beispiel #5
0
int32_t C4TextureMap::LoadTextures(C4Group &hGroup, C4Group* OverloadFile)
  {
  int32_t texnum=0;

#ifdef C4ENGINE

	// overload: load from other file
	if (OverloadFile) texnum+=LoadTextures(*OverloadFile);

  char texname[256+1];
	C4Surface *ctex;
  size_t binlen;
	// newgfx: load PNG-textures first
  hGroup.ResetSearch();
  while (hGroup.AccessNextEntry(C4CFN_PNGFiles,&binlen,texname))		
		{
		// check if it already exists in the map
    SReplaceChar(texname,'.',0);
		if (GetTexture(texname)) continue;
		SAppend(".png", texname);
		// load
    if (ctex=GroupReadSurfacePNG(hGroup))
      {
      SReplaceChar(texname,'.',0);
      if (AddTexture(texname,ctex)) texnum++;
      else delete ctex;
      }
		}
	// Load all bitmap files from group
	hGroup.ResetSearch();
	CSurface8 *ctex8;
	while (hGroup.AccessNextEntry(C4CFN_BitmapFiles,&binlen,texname))		
		{
		// check if it already exists in the map
		SReplaceChar(texname,'.',0);
		if (GetTexture(texname)) continue;
		SAppend(".bmp", texname);
		if (ctex8=GroupReadSurface8(hGroup))
			{
			ctex8->AllowColor(0,2,TRUE);
			SReplaceChar(texname,'.',0);
			if (AddTexture(texname,ctex8)) texnum++;
			else delete ctex;
			}
		}

#endif

	return texnum;
	}
Beispiel #6
0
//
//	*실질적인 TextureDialog의 작업을 수행함*
//
//  이곳에서 값을 변경후, 메인 프로시저에게 이벤트를 알림
//	메인 프로시저 에서 값을 Get해서 사용함....
//
BOOL CTextureDlg::TextureDlgProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam)
{
	switch(iMessage){
		case WM_INITDIALOG:

		return TRUE;
		case WM_COMMAND:
			switch(LOWORD(wParam)){
				case ID_ADDTEX:
					AddTexture(hDlg);
				break;
				case ID_DELTEX:
					
				break;

			}
			SendMessage( m_hMain , WM_COMMAND, wParam, lParam);
		return TRUE;

		case WM_HSCROLL:
			
		return TRUE;

		case WM_CLOSE:
			EndDialog(hDlg,0);
		return TRUE;
	}

	return FALSE;
}
Beispiel #7
0
bool Res::Init() {
	Shader* shader = nullptr;
	Texture* texture = nullptr;

	// block shader
	shader = new Shader();
	if (!shader->Init("res/block.vert", "res/block.frag")) return false;
	AddShader("block", shader);

	// simpler color shader
	shader = new Shader();
	if (!shader->Init("res/color.vert", "res/color.frag")) return false;
	AddShader("color", shader);


	std::vector<byte> buffer, image;
	LodePNG::loadFile(buffer, "res/blocks.png");
	LodePNG::Decoder decoder;
	decoder.decode(image, buffer);

	int dim = decoder.getWidth();

	texture = Texture::Create3DTexture(dim, dim, decoder.getHeight() / dim, image.data());
	AddTexture("blocks", texture);

	return true;
}
//-----------------------------------------------------------------------------
CPUTTexture *CPUTAssetLibrary::GetTexture(const std::string &name, bool nameIsFullPathAndFilename, bool loadAsSRGB )
{
    std::string finalName;

    if( name.at(0) == '%' )
    {
#ifndef CPUT_OS_WINDOWS
        finalName = mSystemDirectoryName + "Texture/" + name.substr(1);  // TODO: Instead of having the Shader/ directory hardcoded here it could be set like the normal material directory. But then there would need to be a bunch new variables like SetSystemMaterialDirectory
#else
        finalName = mSystemDirectoryName + "\\Texture\\" + name.substr(1);  // TODO: Instead of having the Shader/ directory hardcoded here it could be set like the normal material directory. But then there would need to be a bunch new variables like SetSystemMaterialDirectory
#endif
        CPUTFileSystem::ResolveAbsolutePathAndFilename(finalName, &finalName);
    } else if( name.at(0) == '$' )
    {
        finalName = name;
    } else
    {
        CPUTFileSystem::ResolveAbsolutePathAndFilename( nameIsFullPathAndFilename? name : (mTextureDirectoryName + name), &finalName);
    }
    // If we already have one by this name, then return it
    CPUTTexture *pTexture = FindTexture(finalName, true);
    if(NULL==pTexture)
    {
        CPUTTexture *pTex = CPUTTexture::Create( name, finalName, loadAsSRGB);
        if (pTex)
        {
        AddTexture(finalName, "", "", pTex);
        return pTex;
    }
        return NULL;
    }
    pTexture->AddRef();
    return pTexture;
}
Beispiel #9
0
Material::Material(const std::string& fileName)
{
	std::ifstream file;
    file.open(("./res/materials/" + fileName).c_str());

    std::string line;
	if(file.is_open())
    {
        while(file.good())
        {
			getline(file, line);
			std::vector<std::string> tokens = Util::Split(line, ' ');

			if(tokens.size() == 0)
				continue;

			if(tokens[0].compare("Texture") == 0)
				AddTexture(tokens[1], Texture::Get(tokens[2]));
			else if(tokens[0].compare("float") == 0)
				AddFloat(tokens[1], std::stof(tokens[2]));
			else if(tokens[0].compare("Vector3f") == 0)
				AddVector3f(tokens[1], Vector3f(std::stof(tokens[2]), std::stof(tokens[3]), std::stof(tokens[4])));
		}
    }
    else
    {
        Engine::GetDisplay()->Error("Unable to load material: " + fileName);
    }

	if(!HasInitialisedTextureUnits)
    {
        TextureUnits.insert(std::pair<std::string,int>(DiffuseTextureName, 0));
        HasInitialisedTextureUnits = true;
    }
}
int HoNewParticleResMgr::SearchingAddTexture(const char *directory)
{
	HANDLE hSrch;
    WIN32_FIND_DATA wfd;
    BOOL    bResult = TRUE;
    hSrch = FindFirstFile(directory, &wfd);
    char drive[200];
    char dir[200];
    //char newpath[256];
    //char fileFullName[256];
    hSrch = FindFirstFile(directory, &wfd);

    _splitpath(directory,drive,dir,NULL,NULL);
    while(bResult)
    {
		if(!(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
		{
			if(strlen(wfd.cFileName) > 3)
			{
				//wsprintf(fileFullName, "%s%s",dir, wfd.cFileName);
				//wsprintf(fileFullName, "%s%s","effect\\\\particle\\\\", wfd.cFileName);
				std::string texBuffer;
				texBuffer = wfd.cFileName;//fileFullName;
				MakeUpperCase(texBuffer);
				AddTexture(texBuffer.c_str());
			}

		}
		
		bResult = FindNextFile(hSrch, &wfd);
    }
    FindClose(hSrch);

	return TRUE;
}
Beispiel #11
0
void FTextureManager::Init()
{
	DeleteAll();
	// Init Build Tile data if it hasn't been done already
	//if (BuildTileFiles.Size() == 0) CountBuildTiles ();
	FTexture::InitGrayMap();

	// Texture 0 is a dummy texture used to indicate "no texture"
	AddTexture (new FDummyTexture);

	int wadcnt = Wads.GetNumWads();
	for(int i = 0; i< wadcnt; i++)
	{
		AddTexturesForWad(i);
	}

	// Add one marker so that the last WAD is easier to handle and treat
	// Build tiles as a completely separate block.
	//FirstTextureForFile.Push(Textures.Size());
	//InitBuildTiles ();
	//FirstTextureForFile.Push(Textures.Size());

	DefaultTexture = CheckForTexture ("-NOFLAT-", FTexture::TEX_Override, 0);

	//InitAnimated();
	InitAnimDefs();
	FixAnimations();
	InitSwitchList();
	InitPalettedVersions();
}
void 
CTextureAtlasCreatorContext::LoadTexture()
{
	CHAR8 strOpenName[512] = "";
	OPENFILENAMEA FileName;
	memset(&FileName, 0, sizeof(OPENFILENAMEA));
	FileName.lStructSize = sizeof(OPENFILENAMEA);
	FileName.hwndOwner = reinterpret_cast<HWND>(Ascension::Renderer().GetWindowHandle());
	FileName.hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL));
	FileName.lpstrFilter = NULL;
	FileName.lpstrCustomFilter = NULL;
	FileName.nMaxCustFilter = NULL;
	FileName.lpstrFilter = "PNG Files\0*.png*\0\0";
	FileName.nFilterIndex = 1;
	FileName.lpstrFile = strOpenName;
	FileName.nMaxFile = 512;
	FileName.lpstrFileTitle = NULL;
	FileName.lpstrTitle = "Open File";
	FileName.Flags = OFN_EXPLORER;

	if(TRUE == GetOpenFileNameA(&FileName))
	{
		AddTexture(strOpenName);
	}
}
Beispiel #13
0
void MGLTexture::LoadTexture(std::string fileName, std::string name, 
		MGLenum type, GLboolean alpha, GLboolean repeat, GLboolean linear) {
	GLuint tex = MGL::LoadTextureFromFile(fileName, alpha); // load tex
	MGL::SetTextureParameters(tex, repeat, linear); // apply attributes

	AddTexture(tex, name, type); // add
}
bool trpgTexTable::Read(trpgReadBuffer &buf)
{
    int32 numTex;
    trpgToken texTok;
    int32 len;

    try {
	buf.Get(numTex);
		
	for (int i=0;i<numTex;i++) {
	    buf.GetToken(texTok,len);
	    if (texTok != TRPGTEXTURE) throw 1;
	    buf.PushLimit(len);
	    trpgTexture tex;
	    bool status = tex.Read(buf);
	    //set the block for multi-archive archives (version>=2.3)
	    if((currentRow!=-1)&&(currentCol!=-1)) {
		trpgwAppAddress taddr;
		tex.GetImageAddr(taddr);
		taddr.col = currentCol;
		taddr.row = currentRow;
		tex.SetImageAddr(taddr);
	    }
	    AddTexture(tex);
	    buf.PopLimit();
	    if (!status) throw 1;
	}
    }
    catch (...) {
	return false;
    }

    return true;
}
Beispiel #15
0
unsigned int FBO::AddColorTexture()
{
	AddTexture(Texture::GetColorAttachmentTexture(m_scale),FBO_Texture_Attachment::COLOR);
	// the id is always the index in the color attachmentsments vector
	// -1 us needed as when the first is added the size = 1, but the index of the object is 0
	return m_colorAttachments.size()-1;
}
Beispiel #16
0
void Renderer::AddTextures(const TextureDescList & textures)
{
	for (TextureDescList::const_iterator it = textures.begin(); it != textures.end(); ++it)
	{
		AddTexture(*it);
	}
}
	const FAtlasedTextureSlot* AddSprite(UPaperSprite* Sprite)
	{
		const FVector2D SpriteSizeFloat = Sprite->GetSourceSize();
		const FIntPoint SpriteSize(FMath::TruncToInt(SpriteSizeFloat.X), FMath::TruncToInt(SpriteSizeFloat.Y));

		TArray<uint8> DummyBuffer;
		DummyBuffer.AddZeroed(SpriteSize.X * SpriteSize.Y * Stride);
		
		check(Sprite->GetSourceTexture());
		FTextureSource& SourceData = Sprite->GetSourceTexture()->Source;

		//@TODO: Handle different texture formats!
		if (SourceData.GetFormat() == TSF_BGRA8)
		{
			uint32 BytesPerPixel = SourceData.GetBytesPerPixel();
			uint8* OffsetSource = SourceData.LockMip(0) + (FMath::TruncToInt(Sprite->GetSourceUV().X) + FMath::TruncToInt(Sprite->GetSourceUV().Y) * SourceData.GetSizeX()) * BytesPerPixel;
			uint8* OffsetDest = DummyBuffer.GetData();

			CopyTextureData(OffsetSource, OffsetDest, SpriteSize.X, SpriteSize.Y, BytesPerPixel, SourceData.GetSizeX() * BytesPerPixel, SpriteSize.X * BytesPerPixel);

			SourceData.UnlockMip(0);
		}
		else
		{
			UE_LOG(LogPaper2DEditor, Error, TEXT("Sprite %s is not BGRA8, which isn't supported in atlases yet"), *(Sprite->GetPathName()));
		}

		const FAtlasedTextureSlot* Slot = AddTexture(SpriteSize.X, SpriteSize.Y, DummyBuffer);
		if (Slot != nullptr)
		{
			SpriteToSlotMap.Add(Sprite, Slot);
		}

		return Slot;
	}
Beispiel #18
0
void FTextureManager::SortTexturesByType(int start, int end)
{
	TArray<FTexture *> newtextures;

	// First unlink all newly added textures from the hash chain
	for (int i = 0; i < HASH_SIZE; i++)
	{
		while (HashFirst[i] >= start && HashFirst[i] != HASH_END)
		{
			HashFirst[i] = Textures[HashFirst[i]].HashNext;
		}
	}
	newtextures.Resize(end-start);
	for(int i=start; i<end; i++)
	{
		newtextures[i-start] = Textures[i].Texture;
	}
	Textures.Resize(start);
	Translation.Resize(start);

	static int texturetypes[] = {
		FTexture::TEX_Sprite, FTexture::TEX_Null, FTexture::TEX_FirstDefined, 
		FTexture::TEX_WallPatch, FTexture::TEX_Wall, FTexture::TEX_Flat, 
		FTexture::TEX_Override, FTexture::TEX_MiscPatch 
	};

	for(unsigned int i=0;i<countof(texturetypes);i++)
	{
		for(unsigned j = 0; j<newtextures.Size(); j++)
		{
			if (newtextures[j] != NULL && newtextures[j]->UseType == texturetypes[i])
			{
				AddTexture(newtextures[j]);
				newtextures[j] = NULL;
			}
		}
	}
	// This should never happen. All other UseTypes are only used outside
	for(unsigned j = 0; j<newtextures.Size(); j++)
	{
		if (newtextures[j] != NULL)
		{
			Printf("Texture %s has unknown type!\n", newtextures[j]->Name);
			AddTexture(newtextures[j]);
		}
	}
}
MOint moTextureManager::GetTextureMOId(moValue *value, MOboolean p_create_tex)
{
	MOint moid = GetTextureMOId( value->GetSubValue(0).Text(), false);
	if (-1 < moid) return moid;
	else
		if (p_create_tex) return AddTexture(value);
		else return -1;
}
MOint moTextureManager::GetTextureMOId(moParam *param, MOboolean p_create_tex)
{
	MOint moid = GetTextureMOId(param->GetValue().GetSubValue(0).Text(), false);
	if (-1 < moid) return moid;
	else
		if (p_create_tex) return AddTexture(param);
		else return -1;
}
void AnimaMappedValues::SetTexture(const AnimaString& propertyName, AnimaTextureGenerator* value)
{
	AnimaString pName = _uniqueName + propertyName;
	if (_texturesMap.find(pName) == _texturesMap.end())
		AddTexture(propertyName, value);
	else
		_texturesMap[pName] = value;
}
Beispiel #22
0
void FTextureManager::AddHiresTextures (int wadnum)
{
	int firsttx = Wads.GetFirstLump(wadnum);
	int lasttx = Wads.GetLastLump(wadnum);

	char name[9];
	TArray<FTextureID> tlist;

	if (firsttx == -1 || lasttx == -1)
	{
		return;
	}

	name[8] = 0;

	for (;firsttx <= lasttx; ++firsttx)
	{
		if (Wads.GetLumpNamespace(firsttx) == ns_hires)
		{
			Wads.GetLumpName (name, firsttx);

			if (Wads.CheckNumForName (name, ns_hires) == firsttx)
			{
				tlist.Clear();
				int amount = ListTextures(name, tlist);
				if (amount == 0)
				{
					// A texture with this name does not yet exist
					FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
					if (newtex != NULL)
					{
						newtex->UseType=FTexture::TEX_Override;
						AddTexture(newtex);
					}
				}
				else
				{
					for(unsigned int i = 0; i < tlist.Size(); i++)
					{
						FTexture * newtex = FTexture::CreateTexture (firsttx, FTexture::TEX_Any);
						if (newtex != NULL)
						{
							FTexture * oldtex = Textures[tlist[i].GetIndex()].Texture;

							// Replace the entire texture and adjust the scaling and offset factors.
							newtex->bWorldPanning = true;
							newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight());
							newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale);
							newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale);
							ReplaceTexture(tlist[i], newtex, true);
						}
					}
				}
				//StartScreen->Progress();
			}
		}
	}
}
Beispiel #23
0
void FTextureManager::ParseCameraTexture(FScanner &sc)
{
	const BITFIELD texflags = TEXMAN_Overridable | TEXMAN_TryAny | TEXMAN_ShortNameOnly;
	int width, height;
	int fitwidth, fitheight;
	FString picname;

	sc.MustGetString ();
	picname = sc.String;
	sc.MustGetNumber ();
	width = sc.Number;
	sc.MustGetNumber ();
	height = sc.Number;
	FTextureID picnum = CheckForTexture (picname, FTexture::TEX_Flat, texflags);
	FTexture *viewer = new FCanvasTexture (picname, width, height);
	if (picnum.Exists())
	{
		FTexture *oldtex = Texture(picnum);
		fitwidth = oldtex->GetScaledWidth ();
		fitheight = oldtex->GetScaledHeight ();
		viewer->UseType = oldtex->UseType;
		ReplaceTexture (picnum, viewer, true);
	}
	else
	{
		fitwidth = width;
		fitheight = height;
		// [GRB] No need for oldtex
		viewer->UseType = FTexture::TEX_Wall;
		AddTexture (viewer);
	}
	if (sc.GetString())
	{
		if (sc.Compare ("fit"))
		{
			sc.MustGetNumber ();
			fitwidth = sc.Number;
			sc.MustGetNumber ();
			fitheight = sc.Number;
		}
		else
		{
			sc.UnGet ();
		}
	}
	if (sc.GetString())
	{
		if (sc.Compare("WorldPanning"))
		{
			viewer->bWorldPanning = true;
		}
		else
		{
			sc.UnGet();
		}
	}
	viewer->SetScaledSize(fitwidth, fitheight);
}
Beispiel #24
0
void Section::initShaders()
{
	shaderID = LoadShaders("section.vert", "section.frag");
	matrixID = glGetUniformLocation(shaderID, "MVP");

	textureID1 = glGetUniformLocation(shaderID, "mainSampler");

	AddTexture("texture01.jpg", textureID1);
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pFile - 
//			fd - 
//			pGroup - 
//-----------------------------------------------------------------------------
void CTextureSystem::LoadGraphicsFileWAD3(GRAPHICSFILESTRUCT *pFile, int fd, CTextureGroup *pGroup)
{
	// read wad header
	wadinfo_t hdr;
	_lseek(fd, 0, SEEK_SET);
	_read(fd, (char*)&hdr, sizeof hdr);

	_lseek(fd, hdr.infotableofs, SEEK_SET);

	// allocate directory memory.
	WAD3lumpinfo_t *dir = new WAD3lumpinfo_t[hdr.numlumps];
		
	// read entries.
	_read(fd, dir, sizeof(WAD3lumpinfo_t) * hdr.numlumps);

	// load graphics!
	for (int i = 0; i < hdr.numlumps; i++)
	{
		if (dir[i].type == TYP_MIPTEX)
		{
			_lseek(fd, dir[i].filepos, SEEK_SET);

			CWADTexture *pNew = new CWADTexture;
			if (pNew != NULL)
			{
				if (pNew->Init(fd, pFile->id, FALSE, dir[i].name))
				{
					pNew->SetTextureFormat(pFile->format);

					//
					// Add the texture to master list of textures.
					//
					AddTexture(pNew);

					//
					// Add the texture's index to the given group and to the "All" group.
					//
					pGroup->AddTexture(pNew);
					if (pGroup != m_pActiveContext->pAllGroup)
					{
						m_pActiveContext->pAllGroup->AddTexture(pNew);
					}
				}
				else
				{
					delete pNew;
				}
			}
		}
	}

	// free memory
	delete[] dir;
}
Beispiel #26
0
Material::Material(Texture* diffuse, const Vector3f& color)
{
    AddTexture(DiffuseTextureName, diffuse);
    AddVector3f(ColorVector3fName, color);
    
    if(!HasInitialisedTextureUnits)
    {
        TextureUnits.insert(std::pair<std::string,int>(DiffuseTextureName, 0));
        HasInitialisedTextureUnits = true;
    }
}
int trpgTexTable::FindAddTexture(const trpgTexture &inTex)
{
    TextureMapType::iterator itr = textureMap.begin();
    for (  ; itr != textureMap.end( ); itr++) {
	trpgTexture tx = itr->second;
	if(tx == inTex) {
	    return itr->first;
	}
    }
    return AddTexture(inTex);
}
void AnimaMappedValues::SetTexture(const AnimaString& propertyName, AnimaTexture* value)
{
	AnimaString pName = _uniqueName + propertyName + ".valueGenerator";
	AnimaTextureGenerator* generator = (AnimaTextureGenerator*)_dataGeneratorManager->GetGenerator(pName);
	if (generator == nullptr)
		AddTexture(propertyName, value);
	else
	{
		generator->SetTexture(value);
	}
}
MOint moTextureManager::GetTextureMOId(moText p_name, MOboolean p_create_tex)
{
	moTexture* ptex;
	if (p_name.Trim() == moText("")) return -1;
	for (MOuint i = 0; i < m_textures_array.Count(); i++)
	{
		ptex = m_textures_array[i];
		if ((ptex != NULL) && (!stricmp(ptex->GetName(), p_name))) return i;
	}
	if (p_create_tex) return AddTexture(p_name);
	else return -1;
}
BranchXML::BranchXML( float fNear , float fFar ) : m_fNear( fNear )
	, m_fFar( fFar )
{
	//создать узел LOD
	m_BranchLOD = new osg::LOD;

	//создать LOD ствола
	CreateBranchLOD();

	//добавить текстуру
	AddTexture();
}