Community
Hi
I need change color on 3D geometry. I read this file by BStreamFileToolkit and i have inicialize TKE_Color_RGB handler, then in class TKColorRGBHandler i change color by SetRGB() method and i run write method. But write method return TK_Status = TK_Error. I thing, that i can not use write method directly in TKColorRGBHandler, but i need inicialize W3DStreamWriter but i don't know how. Please do you have some example for change of 3D geometry properties?
Thank you very much Milan
Here is my piece of code:
class TKColorRGBHandler : public TK_Color_RGB { public: TKColorRGBHandler() : TK_Color_RGB() {;} virtual ~TKColorRGBHandler() {;} TK_Status Execute( BStreamFileToolkit& rW3DParser ) { TK_Status eStatus = TK_Color_RGB::Execute( rW3DParser ); if (eStatus == TK_Normal) { if(this->GetGeometry() == TKO_Geo_Face) { this->SetRGB(0.85f, 0.0f, 0.0f); eStatus = this->Write(rW3DParser); //return TK_Error } } return eStatus; } }; void change GeometryColor(DFWSection* pSection) { pSection->readDescriptor(); // get the graphics stream DWFToolkit::DWFResourceContainer::ResourceIterator* piResources = pSection->findResourcesByRole( DWFXML::kzRole_Graphics3d ); if ((piResources == NULL) || (piResources->valid() == false)) { if (piResources) { DWFCORE_FREE_OBJECT( piResources ); } printf("Illegal EModel section - no graphics"); } DWFToolkit::DWFGraphicResource* pW3D = dynamic_cast<DWFGraphicResource*>(piResources->get()); DWFCORE_FREE_OBJECT( piResources ); // get the data stream DWFCore::DWFInputStream* pW3DStream = pW3D->getInputStream(); BStreamFileToolkit oW3DStreamParser; oW3DStreamParser.SetOpcodeHandler( TKE_Color_RGB, new TKColorRGBHandler ); oW3DStreamParser.OpenStream( *pW3DStream ); size_t nBytesRead = 0; char aBuffer[16384] = {0}; while (pW3DStream->available() > 0) { nBytesRead = pW3DStream->read( aBuffer, 16384 ); // use the parser to process the buffer if (oW3DStreamParser.ParseBuffer(aBuffer, nBytesRead, TK_Normal) == TK_Error) { printf("Error occured parsing buffer"); break; } } oW3DStreamParser.CloseStream(); DWFCORE_FREE_OBJECT( pW3DStream ); }