[Closed] Change render output file without changing output parameters
This is my problem:
Assume in a scene the rendOutputFilename variable points to “C:\a.png”. When this output was configured, the user selected 48-bit png depth.
The scene was saved and max was restarted.
Meanwhile, the user of this machine has changed the default png output depth to 24-bit.
Then, the scene is loaded.
If you render as is, the png output depth is 48-bit.
Now, I would like to be able to change the output filename to “C:\b.png”, but I would still like to keep the depth at 48-bit, or whatever the original user had selected. Unfortunately, the parameters reset to whatever are the current defaults for the filetype.
Any way to just change the path without rebuilding the entire internal BitmapInfo object?
An SDK based solution is also acceptable.
I ended up using an SDK method.
class OutputRetargetCallback : public IEnumAuxAssetsCallback
{
public:
MSTR fromFile;
MSTR toFile;
OutputRetargetCallback(MSTR from, MSTR to)
{
fromFile = from;
toFile = to;
};
virtual void RecordAsset(const MaxSDK::AssetManagement::AssetUser &asset)
{
}
virtual void IEnumAuxAssetsCallback::DeclareAsset(IAssetAccessor &anAccessor)
{
if (anAccessor.IsInputAsset())
{
return;
}
MaxSDK::AssetManagement::AssetUser aUser = anAccessor.GetAsset();
MSTR fPath = aUser.GetFileName();
if (MatchPattern(fPath, fromFile, TRUE))
{
mputs(fPath);
MaxSDK::AssetManagement::IAssetManager* manager = MaxSDK::AssetManagement::IAssetManager::GetInstance();
MaxSDK::AssetManagement::AssetUser newAsset = manager->GetAsset(toFile, aUser.GetType());
anAccessor.SetAsset(newAsset);
}
}
virtual void IEnumAuxAssetsCallback::DeclareGroup(IAssetAccessor &anAccessor)
{
DeclareAsset(anAccessor);
}
virtual void IEnumAuxAssetsCallback::EndGroup()
{
}
};
def_visible_primitive(RetargetOutputPath, "RetargetOutputPath");
Value* RetargetOutputPath_cf(Value **arg_list, int count)
{
check_arg_count(RetargetOutputPath, 2, count);
MSTR fromFile = arg_list[0]->to_filename();
MSTR toFile = arg_list[1]->to_filename();
OutputRetargetCallback outputAssetsCallback(fromFile, toFile);
GetCOREInterface()->EnumAuxFiles(outputAssetsCallback, FILE_ENUM_ALL | FILE_ENUM_ACCESSOR_INTERFACE);
return &true_value;
}
this is really good!
but i have a question… what do you do if output file is originally undefined? as i understood any redefining output including undefined is resetting to default. isn’t it?
Yes, but then again without a reference of what the output parameters were at the time the scene was saved by the user, I have no way of recovering this information. I don’t believe it is even saved with the scene. Is it not so?
Or perhaps I did not understand your question?