비상업용 Plugin이나 Script, Demo 파일을 다운받으실 수 있습니다. JOYCG에서 배포하는 비상업적 자료도 다운받으실 수 있습니다.

NOTICE [정렬]Align to Surface 2.0 ClaverTech_AlignToSurface
1313 Views,   0 Replies,   Lastest reply : 2016. 08. 10 18:14:56  
 
SKY  2016/08/10 18:14:56

ClaverTech_AlignToSurface 2.0

via. Scriptspot

 

물체의 축을 기준으로 대상물체 표면에 배치하는 Script입니다.

ClaverTech카테고리에서 찾을 수 있고 단축키를 지정해서 사용하면 쉽게 물체를 다른 물체 표면에 정렬할 수 있어요. .

 

Description: This MouseTool is made to help place a node onto the surface of some geometry based upon mouse click location. it will place the node by its pivot point and orient its local z axis to the normal of the intersection. (Additional: Added a new Ability to click and drag to rotate around the Nodes Local Z axis)  Hope its helpful to someone besides me. Heres the code... Enjoy

 

 

macroScript AlignToSurface

        category:"ClaverTech"

        toolTip:"AlignToSurface"

(

           

tool AlignToSurfaceTool

            (

                        local somethin=undefined

                        local OrgPos=undefined

                        local OrgRot=undefined

                        local target_mesh=undefined

                        local StartDragging=0

                        local posy=undefined

                        local roty=undefined

                        local OrgViewY=undefined

                       

                        fn g_filter o =

                        (

                                    if o!=somethin then

                                    (

                                    superclassof o == Geometryclass

                                    )

                                    else

                                    (

                                                false

                                    )

                        )

                                    fn ResetStuff str=

                        (

                                    somethin.pos = OrgPos

                                    somethin.dir = OrgRot

                        )

                        fn DoMyStuff str=

                        (

                                    local myRay=mapScreenToWorldRay viewPoint   -- make a ray from active viewport

                                    local tempRay=intersectRay target_mesh myRay --see if the ray hits the picked object

                                                                        if tempRay!=undefined then --if we actually hit the picked object set to surface

                                                                        (

                                                                                    somethin.pos = tempRay.pos

                                                                                    somethin.dir = tempRay.dir

                                                                        )

                                                                        else -- otherwise make it reset

                                                                        (

                                                                                    ResetStuff now

                                                                        )

                                                                        str --functions need to return somethin right

                        )

                       

                        on start do

                        (

                                   

                                    --if something is selected

                                    if $!=undefined then

                                    (

                                                somethin=$

                                                OrgPos=somethin.pos  --save original position

                                                OrgRot=somethin.dir --save original rotation

                                                target_mesh = pickObject message:"Pick Target Surface" forceListenerFocus:false filter:g_filter

                                    )

                                    else -- if nothing is selected

                                    (

                                                messageBox "Start this tool with an object selected"

                                                #stop

                                    )

                        )

                        on mouseAbort clicker do 

                        (                       --reset position and rotation

                                    ResetStuff now

                        )

                        on mousePoint clickno do

                        (

                                    if (clickno == 1 and target_mesh!=undefined)then

                                    (

                                                DoMyStuff now -- function calls dont seem to work without a parameter

                                    )

                                    else

                                    (

                                                #stop --bail

                                    )

                        )

                        on freeMove do

                        (

                                    if target_mesh!=undefined then

                                    (

                                    DoMyStuff now --this way it actually shows it is workin

                                    )

                                    else

                                    (

                                                #stop --bail

                                    )

                        )

                        on mouseMove clickno do

                        (

                                    if StartDragging==0 then

                                    (

                                                posy = somethin.pos -- dont ask why i need this

                                                roty = somethin.rotation -- dont ask why i need this

                                                OrgViewY=viewPoint.y -- store click loc for later

                                                StartDragging=1 -- make sure this dont happen again

                                    )

                                    somethin.rotation = roty -- dont ask why setting rotation moves the object

                                    somethin.pos = posy -- but now we got to move it back... theres got to be a better way

                                    local tempRot = eulerangles 0 0 0   -- make a blank euler

                                    tempRot.z=((viewPoint.y-OrgViewY)/2) -- make it only rotate more or less by initial screen click loc

                                    in coordsys local rotate somethin tempRot -- and finally rotate locally

                                    --somethin.pos = posy

                        )

            )

 

            startTool AlignToSurfaceTool

)

IP. 211.193.251.XXX
Forum Guide
도움이 된 댓글을 'Correct Answer'로 채택해 주세요.

게시물 작성전에 검색기능을 이용해 보세요.

가장 최근에 작성하거나 최신 댓글이 달린 순서대로 보여집니다.

불필요한 비공개 설정은 피해주세요.
회원간의 정보 공유를 지향합니다.

좋은 게시글에는 댓글로 감사한 마음을 표현해 보세요.
My Posts
Tags

Program   modeling   rendermask   Etc   3dsmax   camera   mask   spline   script   Utils   plugin   vray   Plugins   mentalray   Scripts  

Top Participants
정소미
ljmwww
kjgsgi
terran762000
idobj
COPYRIGHT ⓒ 2012 JOYCG SINCE 2006. ALL RIGHTS RESERVED.   facebook
Term of Use   |   Online Privacy Policy   |   JOYCG News   |   Contact Us
상호 : 조이씨지 | 사업자등록번호 : 214-09-17670 | 통신판매업 신고번호 : 제2009-서울서초-1428호 | 대표자 : 안재문, 권미진