Scripted Camera Plug-ins

Scripted camera plug-ins can be written in MAXScript. At present, you can write either extending camera plug-ins that extend the 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'.

Event Handlers

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 the render aperture.

This handler is optional.

The 'val' parameter contains the new render aperture value. This typically gets called when you select a new aperture 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:

The value being passed into handler is the aperture width. You can get the remaining values using the 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 must cache the old Aperture Width value and test the incoming value against the cached value before proceeding.

EXAMPLE

plugin Camera CamTest
name:"CamTest"
classID:#(0x47db14ff, 0x4e9b5f90)
category:"Standard"
extends:FreeCamera
( 
  on renderApertureChanged val do 
    format "renderApertureChanged: %\n" val 
  tool create ( 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.

NOTE:For performance reasons, it is critical to 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:

EXAMPLE

plugin Camera CamTest_DisplayMesh
name:"CamTest"
classID:#(0x6ca13d13, 0x12afbfd4)
category:"Standard"
extends:FreeCamera
(
  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)
    meshObj.mesh
  )--end on getDisplayMesh
  tool create
  (
    on mousePoint click do (nodeTM.translation = gridPoint;#stop )
  )--end tool
)--end plugin
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.

See Also