MAXScript实例:画直线段

MAXScript实例:画直线段

 

function drawLineBetweenTwoPnts pointA pointB radius = ( ss = SplineShape pos:pointA ss.render_renderable = true ss.render_rectangular = false ss.render_useViewportSettings = true ss.render_thickness = radius addNewSpline ss addKnot ss 1 #corner #line PointA addKnot ss 1 #corner #line PointB updateShape ss ss ) -- usage: drawLineBetTwoPnts [0,0,0] [0,0,10] 1  

 

备注:

(1).  SplineShape创建空的样条形状

ss = SplineShape pos:[0, 0, 0] --$Editable_Spline:Shape06 @ [0.000000,0.000000,0.000000]

numKnots ss 1 -- Runtime error: shape spline index out of range: 1

 

(2). addNewSpline 在样条形状中加入新的样条曲线,返回在shape中的曲线索引号

ss = SplineShape pos:[0, 0, 0] -- $Editable_Spline:Shape07 @ [0.000000,0.000000,0.000000]

addNewSpline ss -- 1,说明是样条形状中的第一条样条曲线

numKnots ss 1 -- 0,说明第一条样条曲线的节点数为0

 

(3). numSplines 样条形状中样条曲线的条数

ss = SplineShape pos:[0, 0, 0] -- $Editable_Spline:Shape11 @ [0.000000,0.000000,0.000000]

addNewSpline ss -- 1

addNewSpline ss -- 2

addNewSpline ss -- 3

numKnots ss 3 -- 0

numSplines ss -- 3


(4). 画出两个mesh间的最短直线段;或者定住其中一个mesh的一点,找出该点到另外mesh的最短直线段

mindis=10000000;
vertex_count1 = $Sphere001.numverts
vertex_count2 = $Sphere002.numverts
id1 = 0
id2 = 0
for i = 1 to vertex_count1 do
(
--i = 1884
for j = 1 to vertex_count2 do
(
--j = 588
v1 = getVert $Sphere001 i
v2 = getVert $Sphere002 j
dis = Length(v1-v2)
if (dis < mindis) do
(
mindis = dis
id1 = i
id2 = j
)

) 
)

id1
id2

pos1 = getVert $Sphere001 id1
pos2 = getVert $Sphere002 id2
drawLineBetweenTwoPnts pos1 pos2 500




你可能感兴趣的:(function)