View Full Version : 3ds max scripting
06-18-2007, 09:58 PM
I was wondering if is there a way to scale a polygon based upon the distance from the cameras. I am working in a project and I need to know if this is possible.
06-19-2007, 06:55 AM
Yes this is feasible but probably only for custom cameras. This is fearly easy in Maxscript.
You get the camera position
--Pseudo code (not tested)
in coordsys world
dist = distance (myobject.pos) (currentcamera.pos)
--then scale your poly if selected using editable poly...
06-19-2007, 12:51 PM
Thank you so much for replying. I am in a very tight deadline and I have never worked with maxscript. I work in forensic animations so my boss wants for me to, somewhat create lights for the vehicles with this characteristics: When the vehicles are far from the cameras the headlights(halo) should look bigger as in real life and as the vehicle gets closer to the camera the headlights(halo) should get smaller to enclose the headlights of the vehicles. Now what he would like is some rig or script that once we set it up we should be able to use repeately with other vehicles and scenes, just adjusting some of the settings.
Thank you so much, it would really be a great help if some could point me up to a solution I could work on.
06-19-2007, 01:08 PM
Have you considered parameter wiring yet? There are some good tutorials out there that actually indicate how to control and objects size relative to another objects proximity. Look it up in the max help. Also search the max forums, this has been discussed quite a few times I believe.
06-19-2007, 01:24 PM
Here is a beggining :
-- Developed by David Lanier 3D, plug-ins and shaders development company
--The object should be selected
if selection.count == 1 then
activecam = getActiveCamera()
if (activecam != undfined)then
in coordsys world (dist = distance ($.pos) (activecam.pos) )
if subobjectlevel == 4 then
oldmode = getRefCoordSys()
scale $ [dist, dist, dist]
--reset previous mode
messagebox ("Please set the polygon selection level")
messagebox ("no active camera node create a camera and set it as the current view")
messagebox ("select 1 and only 1 object")
What's missing is the scaling only on the subselection, I wasn't able to find how to do that in a few minutes, but you have the main points.
You will probably need to set this as an expression so that it's done every frame.
06-19-2007, 01:45 PM
Use parameter wiring or the reaction manager.
06-19-2007, 04:07 PM
Thank you guys!
I had actually tried wireparameter and Reaction Manager and still trying, but I haven't being able to figured it out yet. I would use the David Lanier Sript but the only script I have knowledge of is Lingo and actionscript, I don't know a thing about maxscript. I have looked around the web but it happen to be that every link I find about the subject is broken!
Thanks again for your replies your are always so attend!
06-19-2007, 04:07 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.