Community
DWF
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Reading Textures

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
462 Views, 4 Replies

Reading Textures

Hi all,

I was trying to import textured objects for the past couple of days. The texture is external, so I thought overwriting W3D_Image's default opcode handler is the way to go, but the GetName method of the default opcode handler (which btw returns 'Texture 1') was all I thought might be useful. The TKE_Texture's default opcode handler doesn't seem to be doing more either. I was wondering where the actual pointer to texture data resides. How should I access the texture if there is no sucj pointer? Any ideas would be greatly appreciated.
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

I searched the documents and the web since my last post and somehow I've got the impression maybe this TK_Color might prove to be of some use. Anyway, I'm still looking for your new ideas...
Thanks in advance
Message 3 of 5
Anonymous
in reply to: Anonymous

Hi,

Sample code from my loader :

DWFToolkit::DWFResourceContainer::ResourceIterator* piRes = pSect->findResourcesByRole( DWFXML::kzRole_Texture );
while( piRes && piRes->valid() ) {
DWFToolkit::DWFGraphicResource* pTxtr = dynamic_cast(piRes->get());
if( pTxtr ) {
DWFCore::DWFInputStream* pTxtrStrm = pTxtr->getInputStream();
int iSizeReq = (int) pTxtrStrm->available();
if( iSizeReq > 0 ) {
char *pImgeData = (char *) malloc(iSizeReq);
pTxtrStrm->read( pImgeData, iSizeReq );

CJPEGPtr apImge = new CJPEG(pImgeData, iSizeReq, true);
apImge->setWrapS(e3d::CImge::eWrapMode::wmREPEAT);
apImge->setWrapT(e3d::CImge::eWrapMode::wmREPEAT);
apImge->setMagFltr(e3d::CImge::eFltrMode::fltrLINEAR);
apImge->setMinFltr(e3d::CImge::eFltrMode::fltrLINEAR);
std::wstring wsName = (const wchar_t *) pTxtr->title();
m_mapTxtrs[wsName] = apImge;
free(pImgeData);
}
}

piRes->next();
}

the wsName value will be the same name as the TK_Color ie :

m_diffuse.m_name contains the same name. However, I also found out you can have the name of the colour followed by text values describing a colour as well for example :

ORANGESKIN (r=50 g=40 b=10) So I had to extract the two parts seperatly to get the correct end result (A real pain )

Hope this helps

Cheers
jason
Message 4 of 5
Anonymous
in reply to: Anonymous

Hi,

Yes, that actually helped a lot. Your code cleared my doubt as to whether I should extract the texture myself and forget about overwriting an opcode handler. There is no such thing like a ready-to-use texture pointer. I had to do the same and manually extract info for objects' names.

Thank you for investing the time and answering my question.
Message 5 of 5
geotavros
in reply to: Anonymous

Textures seems to be compressed in png or jpeg in DWF. What did you use to decompress them? 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost

 

”Tips

 

”Services