Maxscript "tool create" "mousePoint"

Автор
Сообщение
На сайте c 18.08.2008
Сообщений: 123
Maxscript "tool create" "mousePoint" "mouseMove"

Не получается создавать объект по аналогии с боксом чтоб типо тянешь мышью как бокс и создаёшь объект нужного размера!!

Может у когонить есть пример макс скрипта создание бокса по аналогии со стандартным?
На сайте c 23.07.2009
Сообщений: 1796
-
Quote:
Может у когонить есть пример макс скрипта создание бокса по аналогии со стандартным?

Нажми f11 macroscript - eneble , создай бокс не отпуская мышь и посмотри строку скрипта.
На сайте c 18.08.2008
Сообщений: 123
В том то и дело там просто вызываеться функция box() с параметрами

а мне нужно Скрипт процесса создания чтоли как то так ! Я вродм разобрался не совсем то что я хотел но уже ближе
Code:
plugin simpleObject upside name:"upside" classID:#(0x2862686d, 0x1133d957) category:"upside" ( parameters main rollout:params ( length type:#worldunits ui:splength default:500 width type:#worldunits ui:spwidth default:500 height type:#worldunits ui:spHeight default:500 ) rollout params "Parameters" ( spinner spWidth "Length: " range:[200,1600,500] spinner spLength "Width: " range:[200,800,500] spinner spHeight "Height: " range:[200,1800,500] ) on buildMesh do ( b = (createInstance box ) b.height = height b.length = length b.width = width setMesh mesh b.mesh gc() ) tool create ( on mousePoint click do case click of ( 1: nodeTM.translation = gridPoint 5: #stop ) on mouseMove click do case click of ( 2: length =(gridDist.x) 3: width = (gridDist.y) 4: height = (gridDist.z) ) ) )
На сайте c 18.08.2008
Сообщений: 123
Помогите кому не сложно перевести урок

http://3dats.com/custom_parametric_object_maxscript.asp  

Английский знаю оч очень плохо и трудно понимать что там написанно думаю это будет полезно не только мне!!

Оч прошу ) Пробовал превести гуглом такая хрень получаеться
На сайте c 18.08.2008
Сообщений: 123
Пока ждал помощи немного разобрался

Но возник вопрос как создать полигон из 4-х точек?
Code:
plugin simpleObject upside name:"upside" classID:#(0x2862686d, 0x1133d957) category:"upside" ( parameters main rollout:params ( length type:#worldunits ui:spLength default:0.0 width type:#worldunits ui:spWidth default:0.0 ) rollout params "Parameters" ( spinner spWidth "Length: " range:[-5000,5000,0] spinner spLength "Width: " range:[-5000,5000,0] ) on buildMesh do ( VertArray =#() VertArray[1] = [length,width,0] VertArray[2] = [0,width,0] VertArray[3] = [0,0,0] VertArray[4] = [length,0,0] m = SetMesh mesh vertices:VertArray ) tool create ( on mousePoint click do case click of ( 1: nodeTM.translation = gridPoint 2: #stop ) on mouseMove click do case click of ( 2:( length = gridDist.x; width = gridDist.y) ) ) )
На сайте c 18.08.2008
Сообщений: 123
Так и не получилось создать полигон решил скопировать его и plane()

Таким же образом сделал и box()

Результат конечно тот который нужен но всётки хотелось бы научиться в плагине создовать полигоны

пример с подобием плоскости и бокса)
Code:
plugin simpleObject upsideBox name:"upsideBox" classID:#(0x2862686d, 0x1133d957) category:"upsidePrimitives" ( parameters main rollout:params ( length type:#worldunits ui:spLength default:0.0 width type:#worldunits ui:spWidth default:0.0 height type:#worldunits ui:spHeight default:0.0 ) rollout params "Parameters" ( spinner spWidth "Length: " range:[-5000,5000,0] spinner spLength "Width: " range:[-5000,5000,0] spinner spHeight "height: " range:[-5000,5000,0] ) on buildMesh do ( d = (createInstance box lengthsegs:1 widthsegs:1 heightsegs:1 length:0 width:0 height:0 pos:[0,0,0]) m = copy d.mesh meshop.moveVert m #{1} [length,width,0] meshop.moveVert m #{2} [0,width,0] meshop.moveVert m #{3} [length,0,0] meshop.moveVert m #{4} [0,0,0] meshop.moveVert m #{5} [length,width,height] meshop.moveVert m #{6} [0,width,height] meshop.moveVert m #{7} [length,0,height] meshop.moveVert m #{8} [0,0,height] setMesh mesh m.mesh gc() ) tool create ( on mousePoint click do case click of ( 1: nodeTM.translation = gridPoint 3: #stop ) on mouseMove click do case click of ( 2:( length = gridDist.x; width = gridDist.y) 3: height = gridDist.z ) ) ) plugin simpleObject upsidePlane name:"upsidePlane" classID:#(0x3ab4d02b, 0x42a1525) category:"upsidePrimitives" ( parameters main rollout:params ( length type:#worldunits ui:spLength default:0.0 width type:#worldunits ui:spWidth default:0.0 ) rollout params "Parameters" ( spinner spWidth "Length: " range:[-5000,5000,0] spinner spLength "Width: " range:[-5000,5000,0] ) on buildMesh do ( d = (createInstance Plane lengthsegs:1 widthsegs:1 length:0 width:0 pos:[0,0,0]) m = copy d.mesh meshop.moveVert m #{1} [length,width,0] meshop.moveVert m #{2} [0,width,0] meshop.moveVert m #{3} [length,0,0] meshop.moveVert m #{4} [0,0,0] setMesh mesh m.mesh gc() ) tool create ( on mousePoint click do case click of ( 1: nodeTM.translation = gridPoint 2: #stop ) on mouseMove click do case click of ( 2:( length = gridDist.x; width = gridDist.y) ) ) )

Выложил для примера может комуто будет полезно)
Репутация: 0
На сайте c 05.07.2013
Сообщений: 1

Да, уже много времени прошло, но я подумал, может ещё кому-нибудь пригодится?! =) Не знаю, о том шла речь или нет, но сейчас я пишу один скрипт и передо мной стояла похожая задача…  я видел аналогичный пример на странице справки Autodesk’a (пример с башней):http://docs.autodesk.com/3DSMAX/15/ENU/MAXScript-Help/index.html?url=files/GUID-C0BFFE27-BB59-4265-8F70-BFE8A636F7CB.htm,topicNumber=d30e642485   Но там, как и тут был приведен пример и использованием plugin’a… а мне нужно было сделать событие по кнопке в своем rollout’e …  вот что получилось у меня:

Code:  

if((PaintBox != undefined) and (PaintBox.isdisplayed)) do (destroyDialog PaintBox)  

rollout PaintBox "Vint26: Paint Box"

(

      spinner spnLength "Length:" width:120 height:16 range:[-5000,5000,0] type:#worldunits align:#left

      spinner spnWidth " Width: " width:120 height:16 range:[-5000,5000,0] type:#worldunits align:#left

      spinner spnHeight "Height: " width:120 height:16 range:[-5000,5000,0] type:#worldunits align:#left

      checkButton ckb_PaintBox "Paint Box" align:#center height:26

            tool create

            (

            on mousePoint click do

            (

                  case click of

                  (

                        1: (

                             in coordsys grid d = ( box pos:gridPoint Height:0 isSelected:on)

                             convertToPoly d

                             polyop.setVert $ #{1} gridPoint

                             polyop.setVert $ #{2} gridPoint

                             polyop.setVert $ #{3} gridPoint

                             polyop.setVert $ #{4} gridPoint

                             polyop.setVert $ #{5} gridPoint

                             polyop.setVert $ #{6} gridPoint

                             polyop.setVert $ #{7} gridPoint

                             polyop.setVert $ #{8} gridPoint

                        )

                        3: (

                             ckb_PaintBox.checked=off

                              #stop

                             )

                  ) --end case

            )-- on execute

            on mouseAbort click     do(ckb_PaintBox.checked=off)

                                    on mouseMove click do

                  (

                        case click of

                        (

                             2:(

                           polyop.setVert $ #{1} [((polyop.getVert $ 1).x),((polyop.getVert $ 1).y),((polyop.getVert $ 1).z)]

                           polyop.setVert $ #{2} [gridPoint.x,((polyop.getVert $ 2).y),((polyop.getVert $ 2).z)]

                           polyop.setVert $ #{3} [((polyop.getVert $ 3).x),gridPoint.y,((polyop.getVert $ 3).z)]

                           polyop.setVert $ #{4} [gridPoint.x,gridPoint.y,((polyop.getVert $ 4).z)]

                           polyop.setVert $ #{5} [((polyop.getVert $ 5).x),((polyop.getVert $ 5).y),((polyop.getVert $ 5).z)]

                           polyop.setVert $ #{6} [gridPoint.x,((polyop.getVert $ 6).y),((polyop.getVert $ 6).z)]

                           polyop.setVert $ #{7} [((polyop.getVert $ 7).x),gridPoint.y,((polyop.getVert $ 7).z)]

                           polyop.setVert $ #{8} [gridPoint.x,gridPoint.y,((polyop.getVert $ 8).z)]

                           gc()

                           update $

                           DistanceLength=((polyop.getVert $ 3).y)-((polyop.getVert $ 1).y)

                           spnLength.value=if DistanceLength<0 then (-DistanceLength) else (DistanceLength)

                           DistanceWidth=((polyop.getVert $ 2).x)-((polyop.getVert $ 1).x)

                           spnWidth.value=if DistanceWidth<0 then (-DistanceWidth) else (DistanceWidth)

                           )

                             3: (

                                   polyop.setVert $ #{5} [((polyop.getVert $ 1).x),((polyop.getVert $ 1).y),gridDist.z]

                                   polyop.setVert $ #{6} [((polyop.getVert $ 2).x),((polyop.getVert $ 2).y),gridDist.z]

                                   polyop.setVert $ #{7} [((polyop.getVert $ 3).x),((polyop.getVert $ 3).y),gridDist.z]

                                   polyop.setVert $ #{8} [((polyop.getVert $ 4).x),((polyop.getVert $ 4).y),gridDist.z]

                                   gc()

                                   update $

                                   spnHeight.value=gridDist.z

                             )

                        )--end case

                  )-- on execute

            )

           on ckb_PaintBox changed state do (startTool create)

)--end rollout

Createdialog PaintBox 140 100

Читают эту тему: