PDA

View Full Version : MaxScript: Instances and spline orientation


Gelero
04-29-2003, 03:22 PM
Hi guys! :wavey:

Can somebody help me? I’ve been trying to write some script here... and i m pretty newbie so I have a two doubt's !
:D

1. Making various copys of an object like a cameras or lights, how can I make then as instances ??
2. how can i create these objects, stored in a array for example, having your position oriented by one spline ?? I mean, I have a spline and I wanna to create N cameras, or N lights along the spline??

Sorry about my POOR english!



:hmm:
thank you thank you!

LFShade
04-29-2003, 04:15 PM
You use the instance() function to create instances of an object. It's a simple thing to store an array of such instances:

obj = sphere()
obj_array = #()
for i in 1 to 10 do obj_array[i] = instace obj


Look up pathInterp in the Maxscript help for an idea of how to place objects along a spline. I don't remember the exact use off the top of my head, but it shouldn't be too hard to figure out from the help description.

-RH

Gelero
04-29-2003, 05:13 PM
LFShade: thank you! the instance thing works fine!
:thumbsup:

Buuuuut pathInterp is hard to understand... at least for me, with my bad english! :shrug:

i mean, i have a 50 lights in an array and i want to set their position along a spline!


can you give a example?
:surprised

RJB
04-29-2003, 05:24 PM
Wouldn't the spacing tool do this?

Gelero
04-29-2003, 05:28 PM
Sorry, my stupid question but what is spacing tools ?

RJB
04-29-2003, 06:24 PM
The Spacing Tool is built into Max. It allows you to place instances of objects along a spline.

You can read about it in the help file.

Gelero
04-29-2003, 06:44 PM
But i want to create the objects oriented along a spline VIA SCRIPT..

Via spacing tool is very nice, thanks for that tipo by the way...

ohh and before you tell me to use spacing tool via script, thats what i want to know!
;)

:D

Gelero
04-30-2003, 12:30 PM
come on guys!
help me please!

:hmm: :hmm: :hmm:

magicm
04-30-2003, 01:01 PM
Here's a simple example to instance an object along a spline:


-- the path:
pth = $Line01

-- the object to instance along the spline:
obj = $Box01

-- number of copies to make:
copies = 10


for i = 0 to (copies-1) do
(
-- get percentage on spline
perc = (i as float / (copies-1))

-- get position on spline
pnt = interpCurve3D pth 1 perc

-- instance the object and position it on the spline
b = instance obj
b.position = pnt
)


good luck

Gelero
04-30-2003, 01:16 PM
WOW!!!! THANK YOU!!!! AAHAHAHAH
:buttrock: :buttrock: :buttrock: :buttrock:

:thumbsup:

Bobo
04-30-2003, 01:32 PM
Originally posted by Gelero
Hi guys! :wavey:

Can somebody help me? I’ve been trying to write some script here... and i m pretty newbie so I have a two doubt's !
:D

1. Making various copys of an object like a cameras or lights, how can I make then as instances ??
2. how can i create these objects, stored in a array for example, having your position oriented by one spline ?? I mean, I have a spline and I wanna to create N cameras, or N lights along the spline??

Sorry about my POOR english!



:hmm:
thank you thank you!



This is a funny hack:


fn filter_spline o = superclassof o == shape --filter only shapes
obj = pickobject() --pick the object to instance
spl = pickobject filter:filter_spline() --pick the spline to use as path
disableSceneRedraw() --disable viewport redraws for speed
old_pos = obj.pos.controller --get the original position controller
obj.pos.controller = path follow:true path:spl constantVel:true --assign a Path controller to follow
--animate the values below:
with animate on
(
at time 0f obj.pos.controller.percent = 0 --set the percentage on frame 0 to 0
at time 100f obj.pos.controller.percent = 100 --set the percentage on frame 100 to 100
)
--Loop through time with (Step+1)
for t = 0 to 100 by 11 do
(
at time t --at the current loop time
(
new_copy = instance obj --instance the object
new_copy.name = uniquename (obj.name+"_Instance") --rename it
new_copy.pos.controller = Bezier_Position() --assign Bezier_Position controller
new_copy.transform = obj.transform --copy the TMatrix to orient correctly
)
)
obj.pos.controller = old_pos --assign the original controller back to the source
enableSceneRedraw() --enable viewports
redrawViews() --redraw them

Gelero
04-30-2003, 02:13 PM
WOW2!!! :bounce: :bounce:

2 million thanks!!!

BOBO = M.S. Monster!
:eek: :eek: :eek: :eek:

CGTalk Moderation
01-15-2006, 12:00 AM
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.