Modding, Mission Design, and Coding > The Modding Workshop
Useful scripts for 3ds Max
zookeeper:
Fixed two bugs in setup-turret-vecs.
EDIT: Sigh. The fvec bug wasn't a bug at all, I just thought so because the ship I was converting was facing backwards.
Reprobator:
Lincks are deleted, can you repost them please?
Scooby_Doo:
--- Quote from: Reprobator on February 26, 2011, 08:32:38 am ---Lincks are deleted, can you repost them please?
--- End quote ---
Agreed. I'm looking for the vector one
zookeeper:
Oops, sorry. :ick: They're back now. Feel free to host them permanently somewhere and post a link here.
Scooby_Doo:
How about this:
setup_turret_vecs.txt
--- Code: ----- This script helps in setting up fvec/uvec values for turrets.
-- However, for angled turrets it'll only work as long as the turret
-- retains its rotation; if you've reseted xform on an angled turret
-- already, then its own rotation information has been lost and the
-- script no longer works right.
--
-- Instructions: select the turrets you wish to setup, run the script
-- and adjust the sliders until the fvec (green) points along the
-- direction of the barrels and uvec (blue) points directly upwards,
-- then hit "Apply".
--
-- IMPORTANT NOTE:
--
-- It's unlikely that you can setup all turrets at once; most likely
-- you'll have to do them in groups. The script uses the turret's
-- existing rotation as a starting point, and if the selection contains
-- turrets which have been rotated in different ways then the script
-- will "suggest" different kinds of fvecs/uvecs for them, in which
-- case you will simply have to setup them separately.
turrets = for turret in selection where ((matchPattern turret.name pattern:"*turret*") and (not matchPattern turret.name pattern:"*turret*-arm*") and (not matchPattern turret.name pattern:"*turret*-destroyed*")) collect turret
rollout turretVecSetup "FS2O Turret fvec/uvec setup" (
slider scale_helpers "Scale helpers" orient:#vertical type:#float range:[0,5,1] height:100
slider rot_x "Rotate X" orient:#horizontal type:#integer ticks:2 range:[0,3,0] width:100
slider rot_y "Rotate Y" orient:#horizontal type:#integer ticks:2 range:[0,3,0] width:100
slider rot_z "Rotate Z" orient:#horizontal type:#integer ticks:2 range:[0,3,0] width:100
button apply_btn "Apply"
button exit_btn "Exit"
fn update_helpers = (
for turret in turrets do (
fvec_helper = getnodebyname(turret.name + "_fvec_helper")
uvec_helper = getnodebyname(turret.name + "_uvec_helper")
uvec_helper.rotation = turret.rotation
in coordsys turret (
rotate uvec_helper (eulerangles (rot_x.value * 90) (rot_y.value * 90) (rot_z.value * 90))
)
uvec_helper.pos = turret.pos
in coordsys uvec_helper (
fvec_helper.rotation = uvec_helper.rotation
rotate fvec_helper (eulerangles 0 -90 0)
)
)
)
fn clean_up = (
for turret in turrets do (
fvec_helper = getnodebyname(turret.name + "_fvec_helper")
uvec_helper = getnodebyname(turret.name + "_uvec_helper")
if fvec_helper != undefined then delete fvec_helper
if uvec_helper != undefined then delete uvec_helper
)
)
on turretVecSetup open do (
for turret in turrets do (
fvec_helper = cylinder name:(turret.name + "_fvec_helper") radius:1 height:20 wirecolor:(color 0 255 0)
uvec_helper = cone name:(turret.name + "_uvec_helper") radius1:3 radius2:0 height:10 wirecolor:(color 0 0 255)
uvec_helper.rotation = turret.rotation
in coordsys turret (
fvec_helper.pos = [0,0,0]
uvec_helper.pos = [0,0,0]
)
)
update_helpers()
)
on turretVecSetup close do (
clean_up()
)
on scale_helpers changed val do (
for turret in turrets do (
fvec_helper = getnodebyname(turret.name + "_fvec_helper")
uvec_helper = getnodebyname(turret.name + "_uvec_helper")
in coordsys local (
ResetScale fvec_helper
ResetScale uvec_helper
fvec_helper.objectoffsetscale = [scale_helpers.value,scale_helpers.value,scale_helpers.value]
uvec_helper.objectoffsetscale = [scale_helpers.value,scale_helpers.value,scale_helpers.value]
)
)
)
on rot_x changed val do (
update_helpers()
)
on rot_y changed val do (
update_helpers()
)
on rot_z changed val do (
update_helpers()
)
on apply_btn pressed do (
overwrote_props = false
for turret in turrets do (
props = getUserPropBuffer turret
fvec_helper = getnodebyname(turret.name + "_fvec_helper")
uvec_helper = getnodebyname(turret.name + "_uvec_helper")
in coordsys uvec_helper (
fvec_helper.pos = [-10,0,0]
uvec_helper.pos = [0,0,10]
)
fvec = normalize -(turret.pos - fvec_helper.pos)
uvec = normalize -(turret.pos - uvec_helper.pos)
fvec.x = (formattedPrint fvec.x format:"2.3f") as float
fvec.y = (formattedPrint fvec.y format:"2.3f") as float
fvec.z = (formattedPrint fvec.z format:"2.3f") as float
uvec.x = (formattedPrint uvec.x format:"2.3f") as float
uvec.y = (formattedPrint uvec.y format:"2.3f") as float
uvec.z = (formattedPrint uvec.z format:"2.3f") as float
fvec_prop = "$fvec: " + fvec.x as string + "," + fvec.z as string + "," + fvec.y as string
uvec_prop = "$uvec: " + uvec.x as string + "," + uvec.z as string + "," + uvec.y as string
if (matchPattern props pattern:"*?vec*") then (
props = ""
overwrote_props = true
print (turret.name + " already had an fvec, uvec or both set, all old subobject properties overwritten!")
)
props += "\r\n" + fvec_prop + "\r\n" + uvec_prop + "\r\n"
setUserPropBuffer turret props
delete fvec_helper
delete uvec_helper
)
if overwrote_props then (
rollout props_overwritten_note "Subobject properties overwritten" (
label note1_lbl "All previous subobject properties of turrets which already had fvec/uvec set were overwritten."
label note2_lbl "Look in the maxscript listener to see a list of those turrets."
label note3_lbl "Undo is available."
button ok_btn "Ok"
on ok_btn pressed do (
destroyDialog props_overwritten_note
)
)
createDialog props_overwritten_note width:600 height:100
)
)
on exit_btn pressed do (
clean_up()
destroyDialog turretVecSetup
)
)
createDialog turretVecSetup
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version