Render.ru

MDT

#1
Вот такой у меня вопросик:
Далаю плагин.
В MDT мне нужно сохранить материал со всей информацией о нём, но на материал составляется с помощью Mix'a, т.е. создаётся из нескольких текстур.
А вот как мне достать все связи для этог материала.

Кто может помочь - отзовитесь...
очень прошу!

Заранее спасибо!
 
#3
1. MDT - это мая!!!
2. У меня есть СДК!

Но я уже его перелопатил - всё так запутано!
Много что перепробовал.....
Может кто сможет помочь?

Да и кстати всем понятна моя задача?
 
#4
Вот я просмотрел связи материала вот так:
Код:
MObject		shader;
MStatus		status;
MObject     object;

int ret=DtExt_MtlGetShader(matNum, shader);
LogFile.WriteString("Get shader for material = %i", ret);
if (ret==1)
{
	MFnDependencyNode fnShader( shader, &status );
	MPlugArray array;
	fnShader.getConnections(array);
	LogFile.WriteString("count %s array=%i", fnShader.name().asChar(), array.length());
	LogFile.WriteString("List nodes:");
	for (int numNode=0;numNode<array.length();numNode++)
	{
		LogFile.WriteString("Next node:%s (%s) - %i %i %i %i", (char*)array[numNode].name(&status).asChar(), array[numNode].info().asChar(), array[numNode].numChildren(), array[numNode].numConnectedChildren() , array[numNode].numConnectedElements(), array[numNode].numElements());
	for (int j=0; j<array[numNode].numChildren();j++)
	{
		LogFile.WriteString("\tSub Next node:%s", array[numNode].child(j).name().asChar());
	}
}
}
Вот но только я понял что копаю не в ту сторону!
Я в общем ищу получется все связи материала и вот что он мне даёт:
имя_объекта.color.R
имя_объекта.color.G
имя_объекта.color.B
- это возвращает второй цикл
ну теперь и ясно что это не то....
мне нужно копать в сторону имя текстуры:
layeredexture1 - вот єто имя текстуры.
Эта текстура не просто текстура - а смешивающая, но как получить имя текстур, да и вообще информацию о ткстурах, которые она смешивает????
Но мне кажется можно сдлать это как-то кроме
listConnections layeredexture1;
Кто что предложит?
 
#5
Вот наконец решил я поставленную мною задачу:
Если кому интерестно можете посмотреть тут:
Код:
	int   matNum;
	
	StMaterial OutMaterial;
	
	for ( matNum = 0; matNum < OutModel.INFO.CountMaterials; matNum++ ) 
	{
		DtMtlGetNameByID( matNum, &OutMaterial.MaterialName);
		DtMtlGetAllClrbyID( matNum,0, 
			&OutMaterial.Ambient.Red ,&OutMaterial.Ambient.Green,&OutMaterial.Ambient.Blue,
			&OutMaterial.Diffuse.Red, &OutMaterial.Diffuse.Green,&OutMaterial.Diffuse.Blue,
			&OutMaterial.Specular.Red, &OutMaterial.Specular.Green,&OutMaterial.Specular.Blue,
			&OutMaterial.Emmision.Red, &OutMaterial.Emmision.Green,&OutMaterial.Emmision.Blue,
			&OutMaterial.Shiness, &OutMaterial.Transparency);
		DtTextureGetName( OutMaterial.MaterialName, &OutMaterial.TextureName);
		WriteChar(hFile,OutMaterial.MaterialName);
		int TextureType=MTL_TYPE_NONE;
		if ( OutMaterial.TextureName )
		{
			WriteChar(hFile,OutMaterial.TextureName);
			OutMaterial.TexturePath=NULL;
			DtTextureGetFileName( OutMaterial.MaterialName, &OutMaterial.TexturePath );
			char NewPath[1024];
			int TextureType=0;
			if (OutMaterial.TexturePath!=NULL&&OutMaterial.TexturePath[0]!=0)
			{
					TextureType=MTL_TYPE_NORMAL;
					write(hFile,&TextureType,sizeof(int));

					strcpy(NewPath,stPathDirectory);
					strcat(NewPath,"\\");
					strcat(NewPath,PathFindFileName(OutMaterial.TexturePath));
					CopyFile(ConvertToNormalPath(OutMaterial.TexturePath),NewPath,false);	
					WriteChar(hFile,PathFindFileName(OutMaterial.TexturePath));
			}
			else
			{
				TextureType=MTL_TYPE_LIGHTMAP;
				write(hFile,&TextureType,sizeof(int));

				MString command;
				command = "listConnections -d off -s on " + MString( OutMaterial.TextureName );
				MStatus status;
				MStringArray connections;
				MGlobal::executeCommand(command, connections);
				if ( status == MS::kSuccess ) 
				{			
					strcpy(OutMaterial.LightMapTextureName,  (char*)connections[0].asChar());
					MStringArray path;
					command = "getAttr "+MString(OutMaterial.LightMapTextureName)+".fileTextureName";
					MGlobal::executeCommand(command, path);
					strcpy(OutMaterial.LightMapTexturePath,  (char*)path[0].asChar());

					strcpy(NewPath,stPathDirectory);
					strcat(NewPath,"\\");
					strcat(NewPath,PathFindFileName(OutMaterial.LightMapTexturePath));
					CopyFile(ConvertToNormalPath(OutMaterial.LightMapTexturePath),NewPath,false);	
					WriteChar(hFile, PathFindFileName(OutMaterial.LightMapTextureName));
					WriteChar(hFile, PathFindFileName(OutMaterial.LightMapTexturePath));



					strcpy(OutMaterial.LightMapTextureName,  (char*)connections[1].asChar());
					command = "getAttr "+MString(OutMaterial.LightMapTextureName)+".fileTextureName";
					MGlobal::executeCommand(command, path);
					strcpy(OutMaterial.LightMapTexturePath,  (char*)path[0].asChar());

					strcpy(NewPath,stPathDirectory);
					strcat(NewPath,"\\");
					strcat(NewPath,PathFindFileName(OutMaterial.LightMapTexturePath));
					CopyFile(ConvertToNormalPath(OutMaterial.LightMapTexturePath),NewPath,false);	
					WriteChar(hFile, PathFindFileName(OutMaterial.LightMapTextureName));
					WriteChar(hFile, PathFindFileName(OutMaterial.LightMapTexturePath));

				}
			}

		}
		else
		{
			TextureType=MTL_TYPE_NONE;
			write(hFile,&TextureType,sizeof(int));
		}
		WriteColor(hFile,OutMaterial.Ambient);
		WriteColor(hFile,OutMaterial.Diffuse);
		WriteColor(hFile,OutMaterial.Specular);
		WriteColor(hFile,OutMaterial.Emmision);
		write(hFile,&OutMaterial.Shiness,sizeof(float));
		write(hFile,&OutMaterial.Transparency,sizeof(float));		
	}
Но вот теперь появилась другая проблема:
Вот тут:
http://www.render.ru/forum/read.php?f=35&i=647&t=647
 
Сверху