Hi everyone!
I'm trying to receive submaterials and submaps of not standard materials and not standard maps (like VRay and Corona). For these purposes I used IParamblock2 of Mtl and BitmapTex respectively.
I'm checking type of parameter if it's TYPE_MTL
void VRnetReader::FindInMtl(Mtl *mat, list<BitmapTex*> &diffuseMaps, list<BitmapTex*> &bumpMaps) { if(mat == NULL) return; MaterialNum numerator(mat); IParamBlock2 * pblock = mat->GetParamBlock(ip->GetTime()); if(pblock == NULL) return; int pbCount = pblock->GetDesc()->count; for(int i = 0; i < pbCount; i++){ int id = pblock->GetDesc()->IndextoID(i); ParamType2 ptype = pblock->GetParameterType(id); if(ptype == ParamType2::TYPE_MTL){ Interval validity; Mtl *inMtl = pblock->GetMtl(id,ip->GetTime(),validity); if(inMtl != NULL) FindInMtl(inMtl,diffuseMaps,bumpMaps); } } BitmapTex *diffTM = NULL, *bumpTM = NULL; if(numerator.DIFFINDEX >= 0){ diffTM = (BitmapTex *) mat->GetSubTexmap(numerator.DIFFINDEX); } if(numerator.BUMPINDEX >= 0){ bumpTM = (BitmapTex *) mat->GetSubTexmap(numerator.BUMPINDEX); } if(diffTM != NULL){ diffuseMaps.push_back(diffTM); } if(bumpTM != NULL){ bumpMaps.push_back(bumpTM); } }
and if it's TYPE_TEXMAP / TYPE_BITMAP (receiving at least one texture if we have it at all):
PBBitmap *VRnetReader::GetBitmap(BitmapTex **texture) { IParamBlock2 *pb2 = (*texture)->GetParamBlock(ip->GetTime()); Interval val; if(pb2 == NULL) return NULL; int count = pb2->GetDesc()->Count(); ParamType2 ptype; for(int i = 0; i < count; i++){ ParamID id = pb2->IndextoID(i); ptype = pb2->GetParameterType(id); if(ptype == ParamType2::TYPE_TEXMAP){ BitmapTex *buffTex = (BitmapTex *) pb2->GetTexmap(id,ip->GetTime(),val); if(buffTex != NULL){ PBBitmap *buff = GetBitmap(&buffTex); if(buff != NULL){ *texture = buffTex; return buff; } } } if(ptype == ParamType2::TYPE_BITMAP){ PBBitmap *buff = pb2->GetBitmap(id,ip->GetTime(),val); if(buff != NULL) return buff; } } return NULL; }
But sometimes type of parameter is TYPE_MTL_TAB, TYPE_TEXMAP_TAB or TYPE_BITMAP_TAB. As much as I understood, it means that the object that we can receive is Tab<Mtl*>, Tab<Texmap*> or Tab<BitmapTex*> respectively.
Thing is, I haven't found how to extract this mentioned table.
Any ideas how to receive it?
Solved! Go to Solution.
Hi everyone!
I'm trying to receive submaterials and submaps of not standard materials and not standard maps (like VRay and Corona). For these purposes I used IParamblock2 of Mtl and BitmapTex respectively.
I'm checking type of parameter if it's TYPE_MTL
void VRnetReader::FindInMtl(Mtl *mat, list<BitmapTex*> &diffuseMaps, list<BitmapTex*> &bumpMaps) { if(mat == NULL) return; MaterialNum numerator(mat); IParamBlock2 * pblock = mat->GetParamBlock(ip->GetTime()); if(pblock == NULL) return; int pbCount = pblock->GetDesc()->count; for(int i = 0; i < pbCount; i++){ int id = pblock->GetDesc()->IndextoID(i); ParamType2 ptype = pblock->GetParameterType(id); if(ptype == ParamType2::TYPE_MTL){ Interval validity; Mtl *inMtl = pblock->GetMtl(id,ip->GetTime(),validity); if(inMtl != NULL) FindInMtl(inMtl,diffuseMaps,bumpMaps); } } BitmapTex *diffTM = NULL, *bumpTM = NULL; if(numerator.DIFFINDEX >= 0){ diffTM = (BitmapTex *) mat->GetSubTexmap(numerator.DIFFINDEX); } if(numerator.BUMPINDEX >= 0){ bumpTM = (BitmapTex *) mat->GetSubTexmap(numerator.BUMPINDEX); } if(diffTM != NULL){ diffuseMaps.push_back(diffTM); } if(bumpTM != NULL){ bumpMaps.push_back(bumpTM); } }
and if it's TYPE_TEXMAP / TYPE_BITMAP (receiving at least one texture if we have it at all):
PBBitmap *VRnetReader::GetBitmap(BitmapTex **texture) { IParamBlock2 *pb2 = (*texture)->GetParamBlock(ip->GetTime()); Interval val; if(pb2 == NULL) return NULL; int count = pb2->GetDesc()->Count(); ParamType2 ptype; for(int i = 0; i < count; i++){ ParamID id = pb2->IndextoID(i); ptype = pb2->GetParameterType(id); if(ptype == ParamType2::TYPE_TEXMAP){ BitmapTex *buffTex = (BitmapTex *) pb2->GetTexmap(id,ip->GetTime(),val); if(buffTex != NULL){ PBBitmap *buff = GetBitmap(&buffTex); if(buff != NULL){ *texture = buffTex; return buff; } } } if(ptype == ParamType2::TYPE_BITMAP){ PBBitmap *buff = pb2->GetBitmap(id,ip->GetTime(),val); if(buff != NULL) return buff; } } return NULL; }
But sometimes type of parameter is TYPE_MTL_TAB, TYPE_TEXMAP_TAB or TYPE_BITMAP_TAB. As much as I understood, it means that the object that we can receive is Tab<Mtl*>, Tab<Texmap*> or Tab<BitmapTex*> respectively.
Thing is, I haven't found how to extract this mentioned table.
Any ideas how to receive it?
Solved! Go to Solution.
@denisT.MaxDoctor, I cast you here, oh guru 😄
@denisT.MaxDoctor, I cast you here, oh guru 😄
Well, little UPD. IParamBlock2::GetMtl/GetTexmap/GetBitmap and respective GetValue has int tabIndex = 0 in parameters, my bad.
But, nevertheless, I'm not sure how to receive index of element in tab. Thus, the question is still actual.
Sad but true.
P.S. Possibly I should look at indices inside IParamBlock2::Count(ParamID) method. But it's not for sure, going to test it right now.
Upd: Nope, it's not.
Well, little UPD. IParamBlock2::GetMtl/GetTexmap/GetBitmap and respective GetValue has int tabIndex = 0 in parameters, my bad.
But, nevertheless, I'm not sure how to receive index of element in tab. Thus, the question is still actual.
Sad but true.
P.S. Possibly I should look at indices inside IParamBlock2::Count(ParamID) method. But it's not for sure, going to test it right now.
Upd: Nope, it's not.
Upd2: Yep, it is.
Offtop: while I sought solution, found answers on CGTalk of denisT.MaxDoctor 😄
Upd2: Yep, it is.
Offtop: while I sought solution, found answers on CGTalk of denisT.MaxDoctor 😄
Can't find what you're looking for? Ask the community or share your knowledge.