PDA

Просмотр полной версии : MaxScript (MXS)


TEST

JiSt
21.07.2014, 15:34
Порой трудно найти в инете какой либо необходимый алгоритм, функцию или полнофункциональный максскрипт.
Предлагаю размещать здесь подобные найденные и свои разработки,а так же ссылки на коды других форумов...
Замечу, что русские буквы нежелательно использовать в максскрипт даже в каментах
поэтому здесь только как пояснение или пояснение перед кодом.
начну.


-- пользуясь классами удобно
-- Выделить:
-- сплайны
select (for i in $* where superclassof i == shape collect i)
-- геометрию
select (for i in $* where superclassof i == GeometryClass collect i)
-- геометрию (не кости)
select (for i in $* where superclassof i == GeometryClass and classof i != BoneGeometry and classof i != Biped_Object collect i)
-- кости
select (for i in $* where classof i == BoneGeometry or classof i == Biped_Object collect i)
-- хелперы
select (for i in $* where superclassof i == helper collect i)
-- лампочки
select (for i in $* where superclassof i == light collect i)
-- камеры
select (for i in $* where superclassof i == camera collect i)

JiSt
27.07.2014, 12:48
Округление:


fn roundeNX n x = (((n as integer)/x)*x)

fn round a = if abs(floor(a) - a)>.5 then floor(a)+1.0 else floor(a)

fn xround x = (
fx = floor x
cx = ceil x
return if 0.5 * (fx + cx) > x then fx else cx
)

fn round_to val n =
(
      local mult = 10.0 ^ n
            (floor ((val * mult) + 0.5)) / mult
)
-- example
-- round_to 3.625 2 -> 3.63
-- round_to 3.6254521 4 -> 3.6255


Максимум,Минимум:


fn minimum a b = ( if a <b then a else b)

fn maximum a b = ( if a <b then b else a)

fn maximum_3 a b c = (if (maximum a b)<c then c else if (maximum b c)<a then a else b)

fn minimum_3 a b c = (if (minimum a b)>c then c else if (minimum b c)>a then a else b)

fn minimumArr Arr =(
a=Arr[Arr.count-1]
for i=Arr.count-1 to 1 by -1 do
(
if a>Arr[i+1] then a=Arr[i+1]
)
return a
)

fn maximumArr Arr =(
a=Arr[Arr.count-1]
for i=Arr.count-1 to 1 by -1 do
(
if a<Arr[i+1] then a=Arr[i+1]
)
return a
)


Среднее арифметическое:


fn midariphm a b = ((a+b)/2)

fn midariphm3x a b c = ((a+b+c)/3)

fn midAriphmArr Arr = (
a=0
for i=1 to Arr.count do(a+=Arr[i])
b=a/Arr.count
return b
)


Поворот камеры расположенной в точке F в направлении точки L. (F и L являются point3):


fn rotatecam F L=(
m_r=L-F
worldUpVector = [0,0,1] --(inverse(obj2.transform)).row3
rightVector = normalize (cross worldUpVector m_r)
upVector = normalize ( cross rightVector m_r)
cam_rotate=matrix3 rightVector upVector m_r L
return cam_rotate)

JiSt
07.01.2015, 16:55
С Новым 2015 годом! и
С Рождеством Христовым!
А ещё родился скрипт генератор карты высот из моделей в 3дс макс с версии 9 и выше :-)
Достаточно выделить одну или несколько мешей и нажать go...
Предварительные параметры интуитивно понятны ;)

Скачать: http://worlds.activeworlds.ru/twoinone/downloads/maxscripts/heightmap_saturn_render_v1_05.7z

http://worlds.activeworlds.ru/twoinone/downloads/maxscripts/heightmap_saturn_render_v1_05.png

Приятного изучения Maxscript! :-)

Яна
13.01.2015, 17:38
Вот эти вот.... с интуитивным понятием мне точно нужны. Столько хороших форм, которых мне точно не хватает в мирах. Я тоже хочу такую прогу! )))

Starec
30.01.2015, 01:21
Тест файла

JiSt
03.03.2015, 20:07
http://i.imgur.com/8zcPA1p.png


knot_pos1=null;knot_pos2=null;knot_pos3=null;S_C=n ull;nk=null;dopknot=null;qq=null
undo "shape_mod" on
(
for i in selection where superClassof i == shape do
(
S_C = copy i; S_C.name = uniquename (i.name+"_mod")
convertToSplineShape S_C
for sp=1 to numSplines S_C do
(
for spv = 1 to numKnots S_C sp do
(
setKnotType S_C sp spv #corner
)
)
for sp=1 to (numSplines S_C) do
(
nk = numKnots S_C sp
if nk > 2 do
(
if isClosed S_C sp then qq=1 else qq=2
for spv = 1 to nk-qq do
(
knot_pos1=getknotpoint S_C sp spv
if (spv+1) < nk then
(
dopknot = spv+1
knot_pos2=getknotpoint S_C sp (spv+2)
)
else
(
dopknot = nk
knot_pos2=getknotpoint S_C sp 1
)
knot_pos3=((knot_pos1+knot_pos2)/2)
setKnotPoint S_C sp dopknot knot_pos3
updateShape S_C
)
)
)
)
)

JiSt
13.03.2015, 15:42
Если иерархия(напр. skeleton rigidmesh) найти root (все root) объекты:

root_bone = for i in $* where (classof i.baseobject == BoneGeometry or i.boneEnable == true) and i.parent == undefined collect i
вернёт array массив содержащий все найденные root объекты.

JiSt
28.04.2015, 23:56
Explore 3ds max system folder
http://i.imgur.com/aJ73mir.jpg

-- Maxscript(MXS)3ds max 9 above Explore 3ds max system folder by JiSt
if myexplore != null then DestroyDialog myexplore
(
local narr = #(#font,#Scene,#Export,#import,#help,#expression,# preview,#image,#Sound,#plugcfg, \
#maxstart,#vpost,#drivers,#autoback,#matlib,#scrip ts,#startupScripts,#defaults,#renderPresets,#ui, \
#maxroot,#renderoutput,#animations,#archives,#Phot ometric,#renderassets,#userScripts,#userMacros,#us erStartupScripts,#temp, \
#userIcons,#maxData,#downloads,#proxies,#assemblie s,#pageFile,#hardwareShadersCache)
local farr = #()
local ex = "explorer.exe "
rollout myexplore "Explore" width:176 height:688
(
GroupBox grp1 "Explore" pos:[8,8] width:160 height:672

button btn1 "font" pos:[16,24] width:144 height:16
button btn2 "Scene" pos:[16,40] width:144 height:16
button btn3 "Export" pos:[16,56] width:144 height:16
button btn4 "import" pos:[16,72] width:144 height:16
button btn5 "help" pos:[16,88] width:144 height:16
button btn6 "expression" pos:[16,104] width:144 height:16
button btn7 "preview" pos:[16,120] width:144 height:16
button btn8 "image" pos:[16,136] width:144 height:16
button btn9 "Sound" pos:[16,152] width:144 height:16
button btn10 "plugcfg" pos:[16,168] width:144 height:16

button btn11 "maxstart" pos:[16,184] width:144 height:16
button btn12 "vpost" pos:[16,200] width:144 height:16
button btn13 "drivers" pos:[16,216] width:144 height:16
button btn14 "autoback" pos:[16,232] width:144 height:16
button btn15 "matlib" pos:[16,248] width:144 height:16
button btn16 "scripts" pos:[16,264] width:144 height:16
button btn17 "startupScripts" pos:[16,280] width:144 height:16
button btn18 "defaults" pos:[16,296] width:144 height:16
button btn19 "renderPresets" pos:[16,312] width:144 height:16
button btn20 "ui" pos:[16,328] width:144 height:16

button btn21 "maxroot" pos:[16,344] width:144 height:16
button btn22 "renderoutput" pos:[16,360] width:144 height:16
button btn23 "animations" pos:[16,376] width:144 height:16
button btn24 "archives" pos:[16,392] width:144 height:16
button btn25 "Photometric" pos:[16,408] width:144 height:16
button btn26 "renderassets" pos:[16,424] width:144 height:16
button btn27 "userScripts" pos:[16,440] width:144 height:16
button btn28 "userMacros" pos:[16,456] width:144 height:16
button btn29 "userStartupScripts" pos:[16,472] width:144 height:16
button btn30 "temp" pos:[16,488] width:144 height:16

button btn31 "userIcons" pos:[16,504] width:144 height:16
button btn32 "maxData" pos:[16,520] width:144 height:16
button btn33 "downloads" pos:[16,536] width:144 height:16
button btn34 "proxies" pos:[16,552] width:144 height:16
button btn35 "assemblies" pos:[16,568] width:144 height:16
button btn36 "pageFile" pos:[16,584] width:144 height:16
button btn37 "hardwareShadersCache" pos:[16,600] width:144 height:16

button btn38 "Button" pos:[16,624] width:144 height:16
button btn39 "Button" pos:[16,640] width:144 height:16
button btn40 "Button" pos:[16,656] width:144 height:16

on myexplore open do (for q = 1 to narr.count do (farr[q] = GetDir narr[q]))

on btn1 pressed do DOSCommand (ex+farr[1])
on btn2 pressed do DOSCommand (ex+farr[2])
on btn3 pressed do DOSCommand (ex+farr[3])
on btn4 pressed do DOSCommand (ex+farr[4])
on btn5 pressed do DOSCommand (ex+farr[5])
on btn6 pressed do DOSCommand (ex+farr[6])
on btn7 pressed do DOSCommand (ex+farr[7])
on btn8 pressed do DOSCommand (ex+farr[8])
on btn9 pressed do DOSCommand (ex+farr[9])
on btn10 pressed do DOSCommand (ex+farr[10])
on btn11 pressed do DOSCommand (ex+farr[11])
on btn12 pressed do DOSCommand (ex+farr[12])
on btn13 pressed do DOSCommand (ex+farr[13])
on btn14 pressed do DOSCommand (ex+farr[14])
on btn15 pressed do DOSCommand (ex+farr[15])
on btn16 pressed do DOSCommand (ex+farr[16])
on btn17 pressed do DOSCommand (ex+farr[17])
on btn18 pressed do DOSCommand (ex+farr[18])
on btn19 pressed do DOSCommand (ex+farr[19])
on btn20 pressed do DOSCommand (ex+farr[20])
on btn21 pressed do DOSCommand (ex+farr[21])
on btn22 pressed do DOSCommand (ex+farr[22])
on btn23 pressed do DOSCommand (ex+farr[23])
on btn24 pressed do DOSCommand (ex+farr[24])
on btn25 pressed do DOSCommand (ex+farr[25])
on btn26 pressed do DOSCommand (ex+farr[26])
on btn27 pressed do DOSCommand (ex+farr[27])
on btn28 pressed do DOSCommand (ex+farr[28])
on btn29 pressed do DOSCommand (ex+farr[29])
on btn30 pressed do DOSCommand (ex+farr[30])
on btn31 pressed do DOSCommand (ex+farr[31])
on btn32 pressed do DOSCommand (ex+farr[32])
on btn33 pressed do DOSCommand (ex+farr[33])
on btn34 pressed do DOSCommand (ex+farr[34])
on btn35 pressed do DOSCommand (ex+farr[35])
on btn36 pressed do DOSCommand (ex+farr[36])
on btn37 pressed do DOSCommand (ex+farr[37])
on btn38 pressed do ()
on btn39 pressed do ()
on btn40 pressed do ()
)
createdialog myexplore
)

JiSt
29.04.2015, 21:30
http://worlds.activeworlds.ru/twoinone/downloads/maxscripts/DiffuseMapTool_v_2_0_7.7z
http://i.imgur.com/njB7kcy.jpg

JiSt
15.05.2017, 16:04
Два тела(точки). Расположить третью точку камеру на векторе этих точек,за пределами точек,повернув камеру на объекты.
http://i.imgur.com/yY3xX8L.gif
Нажатие Ctrl - следующий вариант. Можно и отключить закомент. последнюю строку.


number_demo = 10
pause_demo = 500
rnd_pos_min = [0.0,0.0,0.0]
rnd_pos_max = [70.0,70.0,70.0]
rnd_pos_saturn = random rnd_pos_min rnd_pos_max
rnd_pos_earth = random rnd_pos_min rnd_pos_max
min_distance = 15.0
coef=2.0
ca;ea;sa
app = dotNetclass "System.Windows.Forms.Application"
global escapeEnable = false

fn jstmr t = (
ts = timestamp()
te = ts+t
while (timestamp()) < te do (app.doEvents())
)

fn rotatecam2 f l = (
memsc = f.scale
mempos = f.pos
m_r = l.pos - f.pos
worldUpVector = [0,0,1]
rightVector = normalize ( cross worldUpVector m_r )
upVector = normalize ( cross rightVector m_r )
cam_rotate = matrix3 rightVector upVector m_r l.pos
memrot = cam_rotate.rotation
cam_rotate.scale = memsc
cam_rotate.rotation = memrot
cam_rotate.pos = mempos
return cam_rotate
)

fn antizavis=(
app.doEvents()
completeRedraw()
)

fn distance_points a b = (return sqrt (( a.x - b.x )^2 + ( a.y - b.y )^2 + ( a.z - b.z )^2))

clearlistener()
if getnodebyname "earth" == undefined or getnodebyname "saturn" == undefined or getnodebyname "camera" == undefined then
(
delete $*
ca = Freecamera fov:45 targetDistance:160 nearclip:1 farclip:1000 nearrange:0 farrange:1000 mpassEnabled:off mpassRenderPerPass:off transform:(matrix3 [1,0,0] [0,0,1] [0,-1,0] [0,0,0])
ca.name = "camera"
ea = Sphere radius:2 smooth:on segs:48 chop:0 slice:off sliceFrom:0 sliceTo:0 mapcoords:on recenter:off pos:[0,0,0]
ea.name = "earth"
sa = Sphere radius:8 smooth:on segs:48 chop:0 slice:off sliceFrom:0 sliceTo:0 mapcoords:on recenter:off pos:[0,0,0]
sa.name = "saturn"
ca.wirecolor = black; ea.wirecolor =(color 28 149 177); sa.wirecolor = (color 221 200 131)
)
select ca
for t = 1 to number_demo do
(
if keyboard.escPressed then exit
if viewport.numViews == 4 then
(
avport = viewport.activeViewport
viewport.activeViewport = 3
viewport.setType #view_camera
viewport.activeViewport = avport
)
rnd_pos_saturn = random rnd_pos_min rnd_pos_max
rnd_pos_earth = random rnd_pos_min rnd_pos_max
while distance_points rnd_pos_saturn rnd_pos_earth < min_distance do
(
if keyboard.escPressed then exit
rnd_pos_saturn = random rnd_pos_min rnd_pos_max
rnd_pos_earth = random rnd_pos_min rnd_pos_max
)
format "distance: %\n" (distance_points rnd_pos_saturn rnd_pos_earth)
sa.pos = rnd_pos_saturn
ea.pos = rnd_pos_earth
ca.pos = ea.pos + ( (ea.pos - sa.pos) * coef )
ca.transform = rotatecam2 ca ea
max tool zoomextents all; max tool zoomextents all; jstmr pause_demo; antizavis()
while not keyboard.controlPressed do (if keyboard.escPressed then exit; app.doEvents())
)

TAG.Hosting — Хостинг сайтов и Регистрация Доменов