美文网首页
3dmax 将面片模型投射到曲面

3dmax 将面片模型投射到曲面

作者: Rayson | 来源:发表于2023-09-26 09:43 被阅读0次

    方法:1
    1.创建曲面和地面,在符合对象里面找到conform

    创建
    2.移动到底部拾取地面

    image.png
    方法:2
    使用脚本吸附
    http://www.scriptspot.com/3ds-max/scripts/scripted-glue

    方法:3


    /*******************************************************************************************************
    <SCRIPTFILE>
    Created: 2008-12-29
    Last Updated: 2011-10-11
    Version: 3
    
    Author: Klaas Nienhuis, mail@klaasnienhuis.nl, www.klaasnienhuis.nl
    Version: 3ds max 2010
    
    Description:
        This script aligns shapes or poly's and vertices of shapes or poly'sto a mesh. It projects the vertices in the z-axis to the mesh
        If there's no mesh, the vertex isn't moved. Bezier handles are are projected on a virtual plane constructed by the normal
        of the intersected point on the plane. 
    Usage:
        Run the script. In the GUI, pick the mesh you want to project on. You can project the entire shape/poly or only the selected vertices
        You can also align the vertices to the ground-plane
    
    Features:
    
    Wishlist:
    Changelog:
        2009-07-30:     Heavily edited the script
        It will align vertices to a mesh-object and it's normals. It will take a mesh-object by picking one in the viewport. Preferrably a patch with smooth surfaces.
        The quality of the align depends on the density of the vertices, but both the vertex as well as the tangents will be aligned.
        You can also align to the groundplane.
        The script aligns selected vertices or entire shapes
        2011-10-11: made the script for public release and cleaned it up a lot.
    
    </SCRIPTFILE>
    *******************************************************************************************************/
    
    (
    global roll_AlignVertexToMesh
    try(destroyDialog roll_AlignVertexToMesh)catch()
        
    function fn_planeLineIntersect planePoint planeNormal linePoint lineVector = 
    (
        /*<FUNCTION>
        Description:
            calculates the intersection of a line with a plane. Both plane and line are described by
            a point and a vector
        Arguments:
            <point3> planePoint: a point on the plane
            <point3> planeNormal: The normal of the plane
            <point3> linePoint: a point on the line
            <point3> lineVector: the vector of the line
        Return:
            <point3> A position
        </FUNCTION>*/
        
        local lineVector=normalize lineVector
        local d1=dot (planePoint-linePoint) planeNormal
        local d2=dot lineVector planeNormal
        if abs(d2)<.0000000754 then ( if abs(d1)>.0000000754 then 0 else -1 )
            else ( linePoint + ( (d1/d2)*lineVector ) )
    )
    
    function fn_getAllKnots theSpline =
    (
        /*<FUNCTION>
        Description:
            Get all knots in a splineshape.
        Arguments:
            <splineShape> theSpline: A splineShape to get all the knots from.
        Return:
            <array> an array of bitarrays with the indices of all vertices
        </FUNCTION>*/
        
        local myKnots = #()
        --iterate over the splines in the splineshape
        for n = 1 to numsplines theSpline do
        (
            local arrIdx = (for i = 1 to numKnots theSpline n collect i) as bitArray --collect all vertex indices in a bitArray
            append myKnots arrIdx
        )
        myKnots 
    )
    
    function fn_getKnotSelection theSpline =
    (
        /*<FUNCTION>
        Description:
            get the selected vertices in a splineshape
        Arguments:
            <splineShape> theSpline: A splineShape to get all the knots from.
        Return:
            <array> an array of bitarrays with the indices of all vertices
        </FUNCTION>*/
        
        local myKnots = #()
        --iterate over the splines in the splineshape
        for n = 1 to numsplines theSpline do append myKnots ((getKnotSelection theSpline n) as bitArray) --append the bitarray with the selected vertices
        myKnots 
    )
    
    function fn_transformShapeVertexBitArray theVertexBitArray theSpline theAlignObject: useGroundPlane:false =
    (
        /*<FUNCTION>
        Description:
            move points and it's bezierhandles to a plane
        Arguments:
            <array> theVertexBitArray: an array of bitarrays describing the indices of the vertices which have to be moved
            <splineShape> theSpline: the spline which has to be transformed
            <meshObject> theAlignObject: the object used to transform the vertices to.
            <boolean> useGroundPlane: true: transform the vertices to z=0 false: use theAlignObject to project the vertices on
        Return:
            the input shape is edited
        </FUNCTION>*/
        
        for intIndexSpline = 1 to theVertexBitArray.count do --first iterate over the array. There's one array for every spline
        (
            for intIndexKnot in theVertexBitArray[intIndexSpline] do --secondly: iterate over every vertex
            (
                setKnotType theSpline intIndexSpline intIndexKnot #bezierCorner --makes the editing of the tangents easier
                
                --do the intersection
                local myKnot = getKnotPoint theSpline intIndexSpline intIndexKnot --get the vertex
                local knotRay = ray myKnot [0,0,-1] --project the knot downwards
                local myRay = undefined
                if useGroundPlane then
                (
                    myRay = ray [myKnot.x,myKnot.y,0.0] [0,0,1] --define the groundplane as transform mesh
                )else
                (
                    myRay = intersectRay theAlignObject knotRay --use the object as transform mesh
                )
                
                --move the vertices and tangents
                if myRay != undefined do
                (
                    --edit the vertex itself
                    setKnotPoint theSpline intIndexSpline intIndexKnot myRay.pos
                    --edit the in-tangent
                    local theInVec = getInVec theSpline intIndexSpline intIndexKnot
                    local newInVec = fn_planeLineIntersect myRay.pos myRay.dir theInVec [0,0,-1]
                    setInVec theSpline intIndexSpline intIndexKnot newInVec
                    --edit the out-tangent
                    local theOutVec = getoutVec theSpline intIndexSpline intIndexKnot
                    local newOutVec = fn_planeLineIntersect myRay.pos myRay.dir theOutVec [0,0,-1]
                    setoutVec theSpline intIndexSpline intIndexKnot newOutVec
                    
                    updateShape theSpline
                )
            )
        )
    )
    
    function fn_transformPolyVertexBitArray theVertexBitArray thePoly theAlignObject: useGroundPlane:false =
    (
        /*<FUNCTION>
        Description:
            move vertices to a plane
        Arguments:
            <array> theVertexBitArray: an array of bitarrays describing the indices of the vertices which have to be moved
            <polyObject> thePoly: the poly which has to be transformed
            <meshObject> theAlignObject: the object used to transform the vertices to. Use the special value "groundplane" to move the vertices to the groundplane
            <boolean> useGroundPlane: true: transform the vertices to z=0 false: use theAlignObject to project the vertices on
        Return:
            the input poly is edited
        </FUNCTION>*/
        
        for intIndexKnot in theVertexBitArray do --iterate over every vertex
        (
            --do the intersection
            local myKnot = polyop.getVert thePoly intIndexKnot--getKnotPoint theSpline intIndexSpline intIndexKnot --get the vertex
            local knotRay = ray myKnot [0,0,-1] --define a downwards ray
            local myRay = undefined
            if useGroundPlane then
            (
                myRay = ray [myKnot.x,myKnot.y,0.0] [0,0,1] --define the groundplane as transform mesh
            )else
            (
                myRay = intersectRay theAlignObject knotRay --use the object as transform mesh
            )
            
            --move the vertices
            if myRay != undefined do
            (
                --edit the vertex itself
                polyop.setVert thePoly #{intIndexKnot} myRay.pos node:thePoly
            )
        )
        
    )
    
    function event_prepAndAlign objectArray: baseMesh: useSelectedVertices:true useGroundPlane: =
    (
        /*<FUNCTION>
        Description:
            Prepares and aligns an array of objects to a basemesh.
        Arguments:
            <array> objectArray: An array of objects which need to be aligned
            <meshObject> baseMesh: the mesh to which the objects need to be aligned
            <boolean> useSelectedVertices: set it to true if you want to align selected vertices only
        Return:
            the objects or vertices are aligned
        </FUNCTION>*/
    
        if baseMesh != undefined then
        (
            for s in objectArray do --works on arrays of objects
            (
                case of --pick out the shapes and edtiable poly's
                (
                    (superClassof s.baseObject  == shape): 
                    (
                        local myKnots = if useSelectedVertices then fn_getKnotSelection s else fn_getAllKnots s
                        fn_transformShapeVertexBitArray myKnots s  theAlignObject:baseMesh useGroundPlane:useGroundPlane
                    )
                    (classof s.baseObject  == Editable_Poly): 
                    (
                        if NOT useSelectedVertices do polyop.setVertSelection s.baseObject #all
                        local myVertices = polyop.getVertSelection s.baseObject
                        fn_transformPolyVertexBitArray myVertices s  theAlignObject:baseMesh useGroundPlane:useGroundPlane
                    )
                    default: print "Only splineshapes and editable poly's are supported. Please convert your object!"
                )
            )
        )else print "No basemesh has been selected!"
        
    )
    
    
    rollout roll_AlignVertexToMesh "Align vertices to mesh by Klaas Nienhuis"
    (
        pickbutton btnPickMesh "Pick base mesh in viewport" width:190 across:2
        checkbox chkHome "Use home grid" checked:false offset:[54,3]
        
        group "Align "
        (
            label lbl1 "Works on shapes or editable poly's" align:#left offset:[10,0]
            button btnSelectedVertices "GO: selected vertices" width:120 across:2
            button btnEntireObject "GO: entire object" width:120 
        )
        
        on btnPickMesh picked theObject do
        (
            btnPickMesh.object = theObject
            btnPickMesh.caption = "Current mesh object: " + theObject.name
        )
        
        on chkHome changed arg do btnPickMesh.enabled = NOT arg
        on btnSelectedVertices pressed do event_prepAndAlign objectArray:selection baseMesh:btnPickMesh.object useSelectedVertices:true useGroundPlane:chkHome.checked
        on btnEntireObject pressed do event_prepAndAlign objectArray:selection baseMesh:btnPickMesh.object useSelectedVertices:false useGroundPlane:chkHome.checked
    
        )--end rollout
    
    createDialog roll_AlignVertexToMesh width:300 height:100
    )
    
    

    方法:4
    3dmax 曲线投影并移动到曲面 SiNi Software



    2.进入 sini sofrware script 界面选择曲线,选择曲线 点击拟合到模型
    注意模型面数不能太高,不然会命令失效


    相关文章

      网友评论

          本文标题:3dmax 将面片模型投射到曲面

          本文链接:https://www.haomeiwen.com/subject/wslcbdtx.html