PDA

View Full Version : Max Script for lighting control...


Obviouslytom
12-28-2010, 09:17 PM
I have been looking around and have not been able to find what I am looking to do, if its even possible.

For the projects we have here at work, we usually have multiple camera setup and attached to each camera is an omni light. Depending on what camera view we are in, we will turn on the attached omni and the other ones that are attached to cameras will get turned off.

So I am wondering if anyone knows of a script, or how to write one that depending on what camera view I am in, a specific omni light will turn on.

Example: If I am viewing Camera 1 and have Omni 1 that is attached to it turned on, when I go to Camera 2, I want to have Omni 1 turn off and Omni 2 turn on.

Is that possible?

lo
12-28-2010, 10:31 PM
sounds fairly easy, use a #viewportChange callback.

Obviouslytom
12-29-2010, 03:53 PM
sounds fairly easy, use a #viewportChange callback.

How would I set that up? I have never done it let alone ever heard of what you said to do

lo
12-29-2010, 04:21 PM
fn toggleLight theLight state =
(
if isProperty theLight #on do theLight.on=state
if isProperty theLight #enabled do theLight.enabled=state
)

fn updateLightingByCamera =
(
local theCam = getActiveCamera()
if theCam!=undefined do
(
local lightChildren = for c in theCam.children where isKindof c light collect c
if lightChildren.count>0 do
(
for l in lights do toggleLight l off
for l in lightChildren do toggleLight l on
)
)
)

callbacks.removeScripts id:#lightingByCamera
callbacks.addScript #viewportChange "updateLightingByCamera()" id:#lightingByCamera --persistent:true

Obviouslytom
12-29-2010, 05:16 PM
I will give that script a try later and see how it works out. Thanks for the help

CGTalk Moderation
12-29-2010, 05:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.