Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Paramblock's TAB-parameter

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
622 Views, 3 Replies

Paramblock's TAB-parameter

Anonymous
Not applicable

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?

0 Likes

Paramblock's TAB-parameter

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?

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

@denisT.MaxDoctor, I cast you here, oh guru 😄

0 Likes

@denisT.MaxDoctor, I cast you here, oh guru 😄

Message 3 of 4
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Accepted solution

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.

0 Likes

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.

Message 4 of 4
Anonymous
in reply to: Anonymous

Anonymous
Not applicable

Upd2: Yep, it is.

Offtop: while I sought solution, found answers on CGTalk of denisT.MaxDoctor 😄

0 Likes

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.

Post to forums  

Autodesk Design & Make Report