Hey guys I’m trying to make in max script a camera (from point of view) with light at 45 degrees from the target. The camera part is pretty easy. It’s the light being at 45 degrees from the target.
I’m also having problems naming the camera with a sequential number
macros.run "Lights and Cameras" "Camera_CreateFromView"
$Camera001.name= ("YY_Camera_Three_Point_001")
And for some reason, the script will only let me do this once. I don’t understand why though. What do i need to put in to make multiple cameras (if needed) -> these will have been deleted. If they are in camera mode they won’t be able to make another camera. (which is what I want) apparently with this macro.run though, the item will not let me ‘delete’ but instead
Instead the above code deletes it. Can any one explain why? Is it because I’m using a macro instead of something else? (I’m not complaining, i just wish to know why):?::?:
MAXScript Listener generated code is generally pretty crummy and probably isn’t up to the task in this case. I would suggest something along the lines of the following. The script below isn’t “macro-enabled”, so you’ll need to run the script in order to access its simple GUI. At present, the script merely handles the creation of the camera. Incomplete and rough as it is, hopefully this will get you going in a fruitful direction. Hopefully I’ve understood your project correctly. Let me know if you have any questions. :):
(
int_Num = 1 -- numberic suffix for camera name
--BUILD DIALOG UI: START
local dialog_main = newRolloutFloater "Camera Light Setup Creator" 150 75
rollout ro_main "main" width:140
(
button btn_create "Create Cam & Light" tootip: "Press this button to create a camera from the current viewport and an accompanying light setup." width:130 enabled:true
on btn_create pressed do
(
if ( viewport.getType() == #view_persp_user ) then -- if the current viewport is a perspective viewport
(
newCam = targetCamera name:("cam_" + (int_Num as string))
newCam.transform = inverse( getViewTM() ) -- apply view matrix to the new camera
int_Num += 1 -- increment camera name suffix for the next camera
)
else
(
messageBox "The active viewport must be of type: Perspective." title:"Active Viewport Type Error"
)
)
)
addrollout ro_main dialog_main
)
oh i see how it works! :wow: that’s cool. What i’d originally written was this (the buttons don’t really do much) -> and keep in mind i’m learning this without any teachers (other than you guys) so it’s a bit ghetto. :?:
/* Lighting System
Written by: Kylie Stafford
It has the ability to make a light rig of 3 point lighting with a camera,
and another light rig with a light globe every 25 degrees will be a light
pointed towards a dummy in the centre of the scene. If the dummy is moved the
lights move with the dummy. This rig can have the choice of half or full globe.
*/
if LiSys != undefined then closeRolloutFloater LiSys
(
rollout rlt_3pointLighting "3 Point Lighting"
(
group "Create Camera"
(
/*Have the user press Create Camera (basically just Ctrl_C) Delete Camera does just that*/
button btn_createCamera "Create Camera" width:128 height:40 across:2 align:#left
on btn_createCamera pressed do
(
macros.run "Lights and Cameras" "Camera_CreateFromView"
--namePrefix = "YY_Camera_"
$Camera001.name= ("YY_Camera_Three_Point_001")
/*function fn_createCamera= camera.curFOV Integer default: 1
function fn_showcone= camera.showCone Boolean default: false -- animatable, angle
Prefix_Name= "YY_Camera_"*/
messagebox "You are now in Camera View"
)
button btn_deleteCamera "Delete Camera" width:128 height:40 align:#right
on btn_deleteCamera pressed do
(
select #($YY_Camera_Three_Point_001)
actionMan.executeAction 0 "40020" -- Edit: Delete Objects
messagebox "You are now in Perspective View"
)
)
group "Create Scene"
(
/*Have the user press Create 3 Point Lighting from the position of the camera. Delete 3 Point Lighting does just that.*/
button btn_createThreePointLighting "Create 3 Point Lighting" width:128 height:40 across:2 align:#left
button btn_deleteLights "Delete 3 Point Lighting" width:128 height:40 align:#right
)
)
rollout rlt_GlobeLights "Globe Lights" width:162 height:82
(
group "Full Globe"
(
/*Have the user press Create 3 Point Lighting from the position of the camera. Delete 3 Point Lighting does just that.*/
button btn_createFullGlobe "Create Full Globe System" width:128 height:40 across:2 align:#left
button btn_deleteFullGlobe "Delete Full Globe System" width:128 height:40 align:#right
)
group"Half Globe"
(
/*Have the user press Create 3 Point Lighting from the position of the camera. Delete 3 Point Lighting does just that.*/
button btn_createHalfGlobe "Create Half Globe System" width:128 height:40 across:2 align:#left
button btn_deleteHalfGlobe "Delete Half Globe System" width:128 height:40 align:#right
)
)
LiSys = newRolloutFloater "Lighting System" 300 500.
addRollout rlt_3pointLighting LiSys
addRollout rlt_GlobeLights LiSys
)
I know it’s long, but I couldn’t figure out how to just give you the file. :?:
[QUOTE=Shadow;10176]
you mentioned a GUI… I’m a little confused.
[/QUOTE]
By “GUI”, I just mean the simple (single button) dialog that pops up when you run the script (MAXScript –> Run Script… or you can simply drag the script into Max’s viewport).
Also, it occurs to me that a “free” camera would be more appropriate since I didn’t supply any code to determine and set the location of a “target” camera’s target object.
newCam = freeCamera name:("cam_" + (int_Num as string))