Camera modifier in 3ds Max 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Faced one problem. I wrote a scripted modifier that worked in all the latest versions of 3ds Max including 2023. But in 3ds Max 2024 (including update 1) on the physical camera, the program freezes when starting the render. Also, the modifier cannot be added to the cameras of third-party render engines, such as VRay or FStormRender, due to the fact that it is not in the list of modifiers.
The code is something like this:
plugin modifier CameraMod
name:"Camera Mod"
classid:#(0x673ca7f0, 0x46ef9c4b)
(
parameters main rollout:params
(
amount type:#float ui:spnAmount
)
rollout params "Parameters"
(
spinner spnAmount "Amount: "
)
)
It turned out that if the built-in modifier can be added to third-party cameras, then it works fine on the physical and does not cause a freeze.
The first thing that came to mind was to inherit from the modifier class that can be added to FStormCamera. The full list is here. I used CamPerspCorrect. But when adding "extends:CamPerspCorrect" or any other class, 3ds Max crashes when opening old scenes that contain a non-inherited modifier.
Here's what I did, but I'm not sure if it's the right solution:
- Renamed current class to CameraMod_Legacy and added "invisible:true".
- Made a new class, with the old name but a new classid, inherited from CamPerspCorrect.
- Made a conversion from legacy to a new modifier using #filePostOpen callback, but as an alternative it can be done in the legacy version in the load / postload event.
Whole code:
plugin modifier CameraMod_Legacy
name:"Camera Mod"
classid:#(0x673ca7f0, 0x46ef9c4b)
invisible:true
(
parameters main rollout:params
(
amount type:#float ui:spnAmount
)
rollout params "Parameters"
(
spinner spnAmount "Amount: "
)
)
plugin modifier CameraMod
name:"Camera Mod"
classid:#(0x673ca7f1, 0x46ef9c4b)
extends:CamPerspCorrect
replaceUI:true
(
parameters main rollout:params
(
amount type:#float ui:spnAmount
)
rollout params "Parameters"
(
spinner spnAmount "Amount: "
)
)
fn checkForLegacyCameraModInstances =
(
local legacyInstances = getClassInstances CameraMod_Legacy
for legacy in legacyInstances do
(
local new = CameraMod()
for p in getPropNames legacy where isProperty new p do
setProperty new p (getProperty legacy p)
replaceInstances legacy new
)
)
callbacks.addScript #filePostOpen "checkForLegacyCameraModInstances()"
Question:
Did I do everything right? Maybe instead of CamPerspCorrect, it's better to use another one, for example, EmptyModifier_Old (Attribute Holder (Old))?
