home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Maximum 3D 3
/
m3d-p3.iso
/
3DS_MAX
/
3DSMAX.2_0
/
SCRIPTS
/
BACKDROP.MS
< prev
next >
Wrap
Text File
|
1997-10-19
|
5KB
|
154 lines
-- This creates a "Load Backdrops" utility in the utility panel
-- This script is dependent on files "mapdef.dat" and "place.dat"
-- which are provided in the same directory as this.
-- This is how you can run this script
-- 1) Execute this script and open the 'Load Backdrops' utility
-- 2) Click Maps File button and point to mapdef.dat
-- 3) Click placement file and point to place.dat
-- 4) Set the various options and click 'Load backdrops'
-- 5) Some objects are created in the scene
-- 6) Now render to see the backdrops
--Note: If you moved your treeart directory from scripts directory
-- then open mapdef.dat and edit the paths
-- backdrop loader utility
fn load_backdrops map_data placement_data offset_pos offset_scale =
(
-- first build the proforma backdrop cross mesh & add box uvwmap
local m = mesh vertices: #([10,0,0], [10,0,30], [-10,0,30], [-10,0,0], [0,-10,0],
[0,10,0], [0,10,30], [0,-10,30]) \
faces: #([1,2,3], [1,3,2], [1,3,4], [1,4,3], [5,7,8], [5,8,7], [5,6,7], [5,7,6]) \
materialIDs: #(1, 1, 1, 1, 2, 2, 2, 2)
addModifier m (uvwMap maptype:5) -- maptype is which radio button for now
-- open map file, set up array to hold materials
local f = openfile map_data
local mats = #(), n_mats = 0
-- loop till end-of-file reading texturemap filename strings,
-- build a standard material from them and stick it in the mat. array
while not eof f do
(
local tm = bitmaptexture filename:(readvalue f)
local tm_op = bitmaptexture filename:(readvalue f)
n_mats += 1; mats[n_mats] = standardmaterial diffusemap:tm opacitymap:tm_op selfillum:40
)
close f
-- open placement data file, set up array to hold created backdrop objects
f = openfile placement_data
local items = #()
while not eof f do
(
-- read in name, pos, scale, rotation about z and instance proforma mesh there
-- add it to backdrop item array
local name = readvalue f, pos = readvalue f + offset_pos,
scale = offset_scale * readvalue f, rot = quat (readvalue f) z_axis
local bd = instance m name:name scale:scale rotation:rot pos:pos \
material:mats[random 1 n_mats]
append items bd
)
close f
delete m -- drop propforma mesh
#(items, mats) -- return backdrops & materials
)
utility backdropper "Load Backdrops"
(
local maps_file, placement_file, backdrops, materials,
last_offset, last_scale
group "files"
(
label mf "Maps file:" align:#left
button mapfile_btn "none" width:110
label pf "Placement file:" align:#left
button placefile_btn "none" width:110
)
on mapfile_btn pressed do
(
maps_file = getopenfilename caption:"choose maps definition file"
if maps_file != undefined do mapfile_btn.text = filenamefrompath maps_file
)
on placefile_btn pressed do
(
placement_file = getopenfilename caption:"choose placement definition file"
if placement_file != undefined do placefile_btn.text = filenamefrompath placement_file
)
group "Adjustments"
(
spinner offsetx "Offset x:" range:[-1000, 1000, 0]
spinner offsety "Offset y:" range:[-1000, 1000, 0]
spinner offsetz "Offset z:" range:[-1000, 1000, 0]
spinner scalex "Scale x:" range:[-1000, 1000, 1]
spinner scaley "Scale y:" range:[-1000, 1000, 1]
spinner scalez "Scale z:" range:[-1000, 1000, 1]
)
button load "Load backdrops"
button shuffle "Shuffle materials"
button del "Delete backdrops"
on backdropper open do
(
backdrops = #(); materials = #()
last_offset = [0,0,0]; last_scale = [1,1,1]
)
on load pressed do
(
local results = load_backdrops maps_file placement_file \
[offsetx.value, offsety.value, offsetz.value] \
[scalex.value, scaley.value, scalez.value]
backdrops = results[1]
materials = results[2]
)
on shuffle pressed do
for b in backdrops do b.material = materials[random 1 materials.count]
on del pressed do
(
delete backdrops; backdrops = #(); materials = #()
)
on offsetx changed val do
(
move backdrops [val - last_offset.x, 0, 0]; last_offset.x = val
)
on offsety changed val do
(
move backdrops [0, val - last_offset.y, 0]; last_offset.y = val
)
on offsetz changed val do
(
move backdrops [0, 0, val - last_offset.z]; last_offset.z = val
)
on scalex changed val do
(
scale backdrops [val/last_scale.x, 1, 1]; last_scale.x = val
)
on scaley changed val do
(
scale backdrops [1, val/last_scale.y, 1]; last_scale.y = val
)
on scalez changed val do
(
scale backdrops [1, 1, val/last_scale.z]; last_scale.z = val
)
)