Scripted camera plug-ins can be written in MAXScript. At present, you can write either extending camera plug-ins that extend existing MAX cameras or temporary camera plug-ins that can be used to host create tools for a custom camera system.
The plug-in superclass for cameras is 'camera'.
on renderApertureChanged val do ....
This event handler is available to scripted cameras and gives access to the CameraObject::renderApertureChanged callbacks made by the rendering dialog to a camera when the user adjusts parameters that affect render aperture.
This handler is optional.
The 'val' parameter contains the new render aperture value. This typically gets called when you select a new apeture in the Output Size dropdown in the render dialog or adjust a spinner when in Custom mode.
There are several cases where this handler is called:
In the Render Scene dialog, if Image Aspect is unlocked and you change Width, Height, or Pixel Aspect
In the Render Scene dialog, if you click on one of the output size preset buttons
the Render Scene dialog, if Image Aspect is locked and you change
Width, Height, or Pixel Aspect, or if you change Aperture Width,
and then click on either Render or Close
The value being passed into handler is the aperture width. You can get the remaining values via: renderWidth, renderHeight, and RenderPixelAspect global variables. However, what you get for these values are typically the old value, with the exception of the Aperture Width value. The call to the handler is coming from a "InvalidateCameras" method, which is called right before setting the new values. No broadcasts are made after the new values are set, and if safe frames are not turned on in any viewport, none of the viewports are redrawn.
It is recommended that if a scripted camera uses this handler, it should cache the old Aperture Width value and test the incoming value against the cached value before proceeding.
plugin Camera CamTest
( on renderApertureChanged val do format "renderApertureChanged: %\n" val
( on mousePoint click do #stop
The following handler was added in 3ds Max 7:
on getDisplayMesh do ....
This event handler is available to scripted cameras and helpers and lets the developer replace the viewport display mesh of the delegate with a custom display mesh.
This handler is optional.
reasons, it is
regenerate the returned mesh as
little as possible. The handler is called often - for display, bounds
testing, and hit testing.
The example below shows how to update the mesh in the handler only when the mesh has actually changed:
plugin Camera CamTest_DisplayMesh
local lastR1, lastR2, meshObj
parameters pblock rollout:params
radius1 type:#float animatable:true ui:r1_amount default:40.0
radius2 type:#float animatable:true ui:r2_amount default:20.0
rollout params "CamTest Parameters"
Spinner r1_amount "Radius 1:" range:[0, 1e9, 40]
Spinner r2_amount "Radius 2:" range:[0, 1e9, 20]
on getDisplayMesh do
if (meshObj == undefined) do
meshObj = createInstance torus radius1:radius1 radius2:radius2 mapCoords:false
lastR1 = radius1; lastR2 = radius2
if radius1 != lastR1 do (meshObj.radius1 = radius1; lastR1 = radius1)
if radius2 != lastR2 do (meshObj.radius2 = radius2; lastR2 = radius2)
)--end on getDisplayMesh
on mousePoint click do (nodeTM.translation = gridPoint;#stop )
on useWireColor do ....
This optional event handler lets the developer specify whether to use the node's wire color when drawing the object in the viewport, or use the ui color for the object type (Camera Object for Cameras). If this handler returns true, the node's wire color is used, otherwise the ui color for the object type is used. If the event handler is not specified, the wire color is used. This handler is only applicable when a getDisplayMesh handler is supplied. Available in 3ds Max 8 and higher.
Scripted Plug-in Events