PDA

View Full Version : 3ds max scripting


straightforward
06-18-2007, 09:58 PM
Hi guys,

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.

Thanks
Regards,

dlanier
06-19-2007, 06:55 AM
Hi,

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...
)

straightforward
06-19-2007, 12:51 PM
dlanier,

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.

Regards,

Carlos

Ian Jones
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.

dlanier
06-19-2007, 01:24 PM
Here is a beggining :

-- Developed by David Lanier 3D, plug-ins and shaders development company
--http://www.dl3d.com

--The object should be selected
if selection.count == 1 then
(
activecam = getActiveCamera()
if (activecam != undfined)then
(
in coordsys world (dist = distance ($.pos) (activecam.pos) )
print dist
if subobjectlevel == 4 then
(
oldmode = getRefCoordSys()

setRefCoordSys #local
scale $ [dist, dist, dist]
--reset previous mode
setRefCoordSys oldmode

)
else
(
messagebox ("Please set the polygon selection level")
)
)
else
(
messagebox ("no active camera node create a camera and set it as the current view")
)
)
else
(
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.
Regards,

scrimski
06-19-2007, 01:45 PM
Use parameter wiring or the reaction manager.

straightforward
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!

Regards

CGTalk Moderation
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.