how to get texture file names path?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 21/09/2008 at 23:55, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform: Windows ;
Language(s) : C++ ;---------
I want to get full path of texture but follow code fn.GetString() can't get full path.
this is my snippet code:
void getTextureFileName(string& strOutFileName)
{
string g_sBaseDir;
BaseContainer ctr = GetActiveDocument()->GetAllTextures();
BrowseContainer bc(&ctr);
LONG id;
GeData *dat;
while (bc.GetNext(&id, &dat))
{
Filename fn = dat->GetFilename();
String strFilePath;
String strFileName( fn.GetString());
strFilePath = strFileName;
LONG iLen = strFilePath.GetCStringLen(St8bit)+1;
char* pName = bNew CHAR[iLen];
memset(pName,0, sizeof(CHAR)*iLen);
strFilePath.GetCString( pName,iLen, St8bit);
string strOutName(pName);
bDelete(pName);
pName = NULL;
strOutFileName += strOutName ;
strOutFileName += "|";
}
} -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/09/2008 at 00:30, xxxxxxxx wrote:
Will..not..work.
//Material* mat;
BaseChannel* bchan = mat->GetChannel(CHANNEL_COLOR);
BaseContainer bdata = bchan->GetData();
Filename fn = bdata.GetFilename(BASECHANNEL_SUGGESTEDFOLDER)+Filename(bdata.GetString(BASECHANNEL_TEXTURE));The texture image is stored in two places as you see - path and file specifiers.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/09/2008 at 01:42, xxxxxxxx wrote:
//Material* mat;
BaseChannel* bchan = mat->GetChannel(CHANNEL_COLOR);
BaseContainer bdata = bchan->GetData();
Filename fn = bdata.GetFilename(BASECHANNEL_SUGGESTEDFOLDER)+Filename(bdata.GetString(BASECHANNEL_TEXTURE));
the code Will get nothing. why? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/09/2008 at 15:19, xxxxxxxx wrote:
That is only an example. There is more than CHANNEL_COLOR - like CHANNEL_BUMP, CHANNEL_DISPLACEMENT, CHANNEL_DIFFUSION, etc. etc. etc. And this only can get at the channel texture map not at shaders or deeper in (like fusion layers).
I'm pretty sure that it does indeed work since I use it in my own code. Here are some links:
http://www.plugincafe.com/forum/display_topic_threads.asp?ForumID=4&TopicID;=3212&PagePosition;=29
http://www.plugincafe.com/forum/display_topic_threads.asp?ForumID=4&TopicID;=2775&PagePosition;=61
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/09/2008 at 02:37, xxxxxxxx wrote:
thanks robert,my problem was resolved, this is my snippet code:
void getTextureFileName(string& strOutFileName)
{
string g_sBaseDir;
BaseMaterial* mat = GetActiveDocument()->GetFirstMaterial();while(mat)
{
BaseChannel* pChannel = mat->GetChannel(CHANNEL_COLOR);
if (pChannel)
{
Filename path = pChannel->GetData().GetFilename(BASECHANNEL_SUGGESTEDFOLDER);
if(!path.Content()) path = GetActiveDocument()->GetDocumentPath();
Filename file = pChannel->GetData().GetString(BASECHANNEL_TEXTURE);
if ( file.GetString().GetCStringLen(St8bit)< 0 || file.GetString().GetCStringLen(St8bit) == 0)
{
mat = mat->GetNext();
continue;
}
path = path+file;String strTexturePath( path.GetString());
LONG iPathLen = strTexturePath.GetCStringLen(St8bit)+1;
char* pTextureName = bNew CHAR[iPathLen];
memset(pTextureName,0, sizeof(CHAR)*iPathLen);strTexturePath.GetCString( pTextureName,iPathLen, St8bit);
string strOutTexturePath(pTextureName);bDelete(pTextureName);
pTextureName = NULL;
DBG_LOG("strOutTexturePath=%s",strOutTexturePath.c_str());
if ( strOutTexturePath.length() > 0 )
{if (strOutTexturePath.find(':') != string::npos)
{strOutFileName += strOutTexturePath.c_str();
}
else
{Filename filedir = ::GeGetStartupPath();
String strFilePathDir( filedir.GetString());
LONG iPathLen = strFilePathDir.GetCStringLen(St8bit)+1;
char* pDirName = bNew CHAR[iPathLen];
memset(pDirName,0, sizeof(CHAR)*iPathLen);strFilePathDir.GetCString( pDirName,iPathLen, St8bit);
string strOutDirName(pDirName);bDelete(pDirName);
pDirName = NULL;
g_sBaseDir = strOutDirName;strOutFileName += g_sBaseDir.c_str();
strOutFileName += "\";int Version = GetC4DVersion();
if ( Version < 10000)
{
strOutFileName += "tex\";
}
strOutFileName += strOutTexturePath.c_str();
}strOutFileName += "|";
//MessageDialog( strOutFileName.c_str() );}
}
mat = mat->GetNext();}
if ( strOutFileName.length() > 0)
{
strOutFileName = strOutFileName.substr(0, strOutFileName.rfind('|'));}
}