根据鼠标事件,自动完成面片的创建, 在我的对齐流程上市第一步。

----第一部就是在模型的左右上下建模面片
----如选择物体的前方创建面片,就是
/*
 $.pivot.x=$.min.x+0.5*($.max.x-$.min.x);
$.pivot.y=$.min.y+0.5*($.max.y-$.min.y);
 $.pivot.z=$.min.z+0.5*($.max.z-$.min.z)
 */
 ----用下面的方法来创建片的创建位置。
 /*
 CenterPivot $
$.pivot.y=$.max.y+($.max.y-$.min.y)
*/
----用收集坐标的变量来进行收集活动。
----事件处理之后要的一个三维坐标。
-----这个最好不要对组操作。

-----y的正方向
-----做好了函数要改,现在都是正方向,不是很对,
-----我用鼠标创建了点 我只是想叫他在所在的轴向上向外移动出本身。
function sel_pivot_axis axis_string  =
(
 case of
 (
 (axis_string == "y+") :
  (
 --sel_pivot_y =$.pos

 sel_pivot_y=$.max.y+($.max.y-$.min.y)

 sel_pivot_y
 ----上面的方法是一个获得点坐标的方法,其实是从位置哪里找到数组。在自动修改。
  )
       
 ----y的负方向
     (axis_string == "y-") :
         (  
 --sel_pivot_y_ =$.pos
 sel_pivot_y_=$.min.y+($.min.y-$.max.y)
 sel_pivot_y_
   )
 ---- z 的正方向
      (axis_string =="z+"):
   (
 --sel_pivot_z= $.pos
 sel_pivot_z=$.max.z+($.max.z-$.min.z)
 sel_pivot_z
   )
 --------z负方向
    (axis_string =="z-"):
         (  
 --sel_pivot_z_= $.pos
 sel_pivot_z_= $.min.z+($.min.z-$.max.z)
 sel_pivot_z_
   )
 ----x 轴的正方向
  (axis_string=="x+"):
       (  
 --sel_pivot_x =$.pos
 sel_pivot_x=$.max.x+($.max.x-$.min.x)
 sel_pivot_x
    )
 ----x轴的负方向
    (axis_string=="x-"):
    (
 --sel_pivot_x_ =$.pos
 sel_pivot_x_=$.min.x+($.min.x-$.max.x)
 sel_pivot_x_
    )
 -----写完了想写成一个函数的形式,方便下来的调用,
   )----end case
 
 
)---end fn (收集片的坐标。)

----函数sel_pivot_axis 是出来两倍的函数,这个函数以后用在创建面片上,
-----我用鼠标创建了点 我只是想叫他在所在的轴向上向外移动出本身。
function sel_pivot_axis_fold axis_string  =
(
 case of
 (
 (axis_string == "y+") :
  (
 --sel_pivot_y =$.pos

 sel_pivot_y=$.max.y

 sel_pivot_y
 ----上面的方法是一个获得点坐标的方法,其实是从位置哪里找到数组。在自动修改。
  )
       
 ----y的负方向
     (axis_string == "y-") :
         (  
 --sel_pivot_y_ =$.pos
 sel_pivot_y_=$.min.y
 sel_pivot_y_
   )
 ---- z 的正方向
      (axis_string =="z+"):
   (
 --sel_pivot_z= $.pos
 sel_pivot_z=$.max.z
 sel_pivot_z
   )
 --------z负方向
    (axis_string =="z-"):
         (  
 --sel_pivot_z_= $.pos
 sel_pivot_z_= $.min.z
 sel_pivot_z_
   )
 ----x 轴的正方向
  (axis_string=="x+"):
       (  
 --sel_pivot_x =$.pos
 sel_pivot_x=$.max.x
 sel_pivot_x
    )
 ----x轴的负方向
    (axis_string=="x-"):
    (
 --sel_pivot_x_ =$.pos
 sel_pivot_x_=$.min.x
 sel_pivot_x_
    )
 -----写完了想写成一个函数的形式,方便下来的调用,
   )----end case
 
 
)---end fn (收集片的坐标。)

----下面应该是鼠标工具函数,这个很重要,这里还不能纯粹的用鼠标工具
---要用到屏幕射线。

--1.当我点击屏幕对应的射线。交到物体有一个坐标,然后收集 坐标数。把其中的一个数换成我上面轴的函数对应的数。
--2.这样数字就会在一个平面上,利用平面数据,得出长宽,创建面片,转正mesh 显示所以线(应为三角具有稳定性。)

 --mouseray = mapScreenToWorldRay mouse.pos --这里应该是鼠标屏幕对应的射线
 --sectray = intersectRAY $ mouseray  --返回节点还是就是射线的焦点。)
---就是鼠标所指的 物体上的坐标,还有一条射线的方向。
---下面先创建一个鼠标工具,如果是需要什么函数,就在上面写啦。

---先写一个删除物体函数
global gt_become_deformed_Align_bush_pos  ,gt_bush_pos_ray ,gt_become_deformed_Align_sphere_s,gt_become_deformed_Align_s2,gt_become_deformed_Align_sel_seltion
fn deleting_marker_sp   =
 (
  if  isdeleted gt_become_deformed_Align_sphere_s == true or isdeleted gt_become_deformed_Align_s2 == true  then
  () else
  (
   delete gt_become_deformed_Align_sphere_s
   delete gt_become_deformed_Align_s2
  )
 )


fn mouse_tools_customize  axis_ leng_theg width_thge  =

 global gt_kooc_in_form  ---我用的函数内部传,全局
  global gt_count_zore =#()
  global gt_leng_theg=leng_theg ,gt_width_thge=width_thge
 
 
  gt_kooc_in_form = axis_
 tool drawing__   numPoints:3
 (
  on start do
  (
      ---提前创建球体。
         gt_become_deformed_Align_sphere_s =   sphere radius:2 segs:10  smooth:true colorBylayer:false wirecolor:red
   setSysCur #uscale 
  )---end start   
  ----- 当鼠标点击时,把 
 on mousepoint clickno do 
 (
   case clickno of
 (
   1:
  (
         mouseray = mapScreenToWorldRay mouse.pos
         try (sectray = intersectRAY $ mouseray)catch()
  if sectray==undefined then
  (  if  isdeleted gt_become_deformed_Align_sphere_s == false then
   delete gt_become_deformed_Align_sphere_s ---这里应该会是结束鼠标工具,但是又不能写因为 我要不断的点击尝试啊。
   --return false 
  )else
  (
   --- 在这里面球在创建活动,产看变量是否删除在 鼠标工具中用到了
   if  isdeleted gt_become_deformed_Align_sphere_s == true then
   (
   gt_become_deformed_Align_sphere_s =   sphere radius:10 segs:10  smooth:true colorBylayer:false wirecolor:red
   )
   --sel_pivot_axis_fold axis_string
   ---在用一个case
                --  ray_ra= sectray.pos
    -- ray_ra[2]=sel_pivot_axis_fold  axis_string
     --sphere_s.pos =ray_ra
    
   case gt_kooc_in_form  of
   (
    ("y+"):
    (
     ray_ra= sectray.pos
     ray_ra[2]=sel_pivot_axis_fold "y+"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    ("y-"):
    (
     ray_ra= sectray.pos
     ray_ra[2]=sel_pivot_axis_fold "y-"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    ("z+"):
    (
     ray_ra= sectray.pos
     ray_ra[3]=sel_pivot_axis_fold "z+"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    ("z-"):
    (
     ray_ra= sectray.pos
     ray_ra[3]=sel_pivot_axis_fold "z-"
     gt_become_deformed_Align_sphere_s.pos =ray_ra

     
    )----end ()
    ("x+"):
    (
     ray_ra= sectray.pos
     ray_ra[1]=sel_pivot_axis_fold "x+"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
     
    )----end ()
    ("x-"):
    (
     ray_ra= sectray.pos
     ray_ra[1]=sel_pivot_axis_fold "x-"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    
    default:()


   )---end case
   
   
  )
  ---因为鼠标工具在点击时每次都是2次 好像是第一个还是3次 所以这里面加入了强有利的报错机制。
  ---实现了点的坐标。
 )---end()
    2:()
  3:
  (
   gt_become_deformed_Align_sel_seltion = $  ---选择的物体做积累
   clearSelection() ----清除
   select gt_become_deformed_Align_sphere_s   ---选择我之前的球 
  -- maxOps.cloneNodes $ cloneType:#copy newnodes:&s2  ---做一个拷贝 这样出来是个数组
   gt_become_deformed_Align_s2 =copy $
   gt_become_deformed_Align_s2.wirecolor=red
   clearSelection()    --在清除
   select gt_become_deformed_Align_sel_seltion  ---在选择回之前选择的物体
   
         mouseray = mapScreenToWorldRay mouse.pos
         try (sectray_y = intersectRAY $ mouseray)catch()
   
       --  s2.pos=sectray_y.pos
   --sel_pivot_axis_fold axis_string
   ---在用一个case
                --  ray_ra= sectray.pos
    -- ray_ra[2]=sel_pivot_axis_fold  axis_string
     --sphere_s.pos =ray_ra
    
   case gt_kooc_in_form  of
   (
    ("y+"):
    (
     ray_ra= sectray_y.pos
     ray_ra[2]=sel_pivot_axis_fold "y+"
     gt_become_deformed_Align_s2.pos =ray_ra
     
    )----end ()
    ("y-"):
    (
     ray_ra= sectray_y.pos
     ray_ra[2]=sel_pivot_axis_fold "y-"
     gt_become_deformed_Align_s2.pos =ray_ra
     
    )----end ()
    ("z+"):
    (
     ray_ra= sectray_y.pos
     ray_ra[3]=sel_pivot_axis_fold "z+"
     gt_become_deformed_Align_s2.pos =ray_ra
     
    )----end ()
    ("z-"):
    (
     ray_ra= sectray_y.pos
     ray_ra[3]=sel_pivot_axis_fold "z-"
     gt_become_deformed_Align_s2.pos =ray_ra

     
    )----end ()
    ("x+"):
    (
     ray_ra= sectray_y.pos
     ray_ra[1]=sel_pivot_axis_fold "x+"
     gt_become_deformed_Align_s2.pos =ray_ra
     
     
    )----end ()
    ("x-"):
    (
     ray_ra= sectray_y.pos
     ray_ra[1]=sel_pivot_axis_fold "x-"
     gt_become_deformed_Align_s2.pos =ray_ra
     
    )----end ()
    
    default:()


   )---end case
   
   
  
  ---因为鼠标工具在点击时每次都是2次 好像是第一个还是3次 所以这里面加入了强有利的报错机制。
  ---实现了点的坐标。

  )
  ---想到这里我又感觉我上面的方向有点少,效果不是很理想。
  ---现在想想应该还好。我只是在每个轴上自己选择一下。
 )---end case

 )---叫创建的球到物体的外形的box上,这个也是我干干想的,  
 
 on mouseMove  a do
 (  ---1.当我自由移动时,标记自由的跟随。
  ---思路临时错误
  --2.单我点击第一下是(按下时创建第一个球体)
  --3.然后自由一定距离。我抬起鼠标在次创建,
  --4.然后是取消创建,完成相应的操作。


  /* 这个是错了的思想
  --做到现在要是出现想要的效果还是有些困难,原因是自己的思路考虑有点不对头。
  if ctrlKey==true then
  (
   while gt_bush_count ==1 do
   (
   
  sel_seltion = $  ---选择的物体做积累
  clearSelection() ----清除
   select sphere_s   ---选择我之前的球 
  maxOps.cloneNodes $ cloneType:#copy newnodes:&s2  ---做一个拷贝
  clearSelection()    --在清除
  select sel_seltion  ---在选择回之前选择的物体
   append gt_array_con_yu  s2 
   
  
         mouseray = mapScreenToWorldRay mouse.pos  
         try (sectray = intersectRAY $ mouseray)catch()  ---鼠标取焦点,
  if sectray==undefined then
  (  if  isdeleted s2 == false then
   delete s2 ---这里应该会是结束鼠标工具,但是又不能写因为 我要不断的点击尝试啊。
   --return false 
  )else
  (
   if s2!=undefined then
   (
   if  isdeleted s2 == true or  isdeleted s2 == ok  then
   (
     s2 =   sphere radius:10 segs:10  smooth:true colorBylayer:false wirecolor:red
   )----如果s2删掉了 在重新建立s2
   ray_ra= sectray.pos
   s2.pos =ray_ra
      )
  )
   if gt_array_con_yu.count>1 then
   (
    gt_bush_count=2
   )---end if (控制循环)
  
  
   )---end while
 )---end if ctrlkey
  */
  
 )---end mouseMove

 ----单自由移动估计要该一会 因为他设计到点击一次自由移动 还是点击多次自由移动,还是就是上来就自由移动
 on freeMove do
 (
  ---我想我自由移动是要一定复制的那个,如果移动第一个,我顶上的点就有了问题,所以这个很重要。
  
         mouseray = mapScreenToWorldRay mouse.pos
         try (sectray = intersectRAY $ mouseray)catch()
  if sectray==undefined then
  (  if  isdeleted gt_become_deformed_Align_sphere_s == false then
   delete gt_become_deformed_Align_sphere_s ---这里应该会是结束鼠标工具,但是又不能写因为 我要不断的点击尝试啊。
   --return false 
  )else
  (
   --- 在这里面球在创建活动,产看变量是否删除在 鼠标工具中用到了
   if  isdeleted gt_become_deformed_Align_sphere_s == true then
   (
   gt_become_deformed_Align_sphere_s =   sphere radius:10 segs:10  smooth:true colorBylayer:false wirecolor:red
   )
   --sel_pivot_axis_fold axis_string
   ---在用一个case
                --  ray_ra= sectray.pos
    -- ray_ra[2]=sel_pivot_axis_fold  axis_string
     --sphere_s.pos =ray_ra
    
   case gt_kooc_in_form  of
   (
    ("y+"):
    (
     ray_ra= sectray.pos
     ray_ra[2]=sel_pivot_axis_fold "y+"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    ("y-"):
    (
     ray_ra= sectray.pos
     ray_ra[2]=sel_pivot_axis_fold "y-"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    ("z+"):
    (
     ray_ra= sectray.pos
     ray_ra[3]=sel_pivot_axis_fold "z+"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    ("z-"):
    (
     ray_ra= sectray.pos
     ray_ra[3]=sel_pivot_axis_fold "z-"
     gt_become_deformed_Align_sphere_s.pos =ray_ra

     
    )----end ()
    ("x+"):
    (
     ray_ra= sectray.pos
     ray_ra[1]=sel_pivot_axis_fold "x+"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
     
    )----end ()
    ("x-"):
    (
     ray_ra= sectray.pos
     ray_ra[1]=sel_pivot_axis_fold "x-"
     gt_become_deformed_Align_sphere_s.pos =ray_ra
     
    )----end ()
    
    default:()


   )---end case
   
   
  )
  ---因为鼠标工具在点击时每次都是2次 好像是第一个还是3次 所以这里面加入了强有利的报错机制。
  ---实现了点的坐标。
  
 )---end FreeMove
   on  mouseAbort clickno do ---右键中断
   (
    deleting_marker_sp() 
   )

    on abort do
 (
  
 deleting_marker_sp() 
 )
    on stop do ---单鼠标次数执行玩后
 (-----这里做我要做的事件。
    ---- 1.收集两个坐标的坐标
 -----2. gt_kooc_in_form 等于不同的轴,画出不同的形状。
 -----3. 在坐标上使用2倍的坐标。 
 -----4. 最后删除完成创建。
        select gt_become_deformed_Align_sphere_s
  selectMore gt_become_deformed_Align_s2
    greate_plane_center  = selection.center --- 面的坐标
    greate_plane_one =gt_become_deformed_Align_sphere_s.pos 
    greate_plane_two =gt_become_deformed_Align_s2.pos
  
 ----选择不同的平面创建 
 --  fn plane_p = ( Plane length:211.796 width:406.306 pos:greate_plane_center )
  case  gt_kooc_in_form of
  (
   ("y+"):
   ( ---球长宽 做位置,在旋转就好。
    wid= abs (amax greate_plane_one[1] greate_plane_two[1])-(amin greate_plane_one[1] greate_plane_two[1])
    leng= abs (amax greate_plane_one[3] greate_plane_two[3])-(amin greate_plane_one[3] greate_plane_two[3])
    clearSelection()
    select gt_become_deformed_Align_sel_seltion ---- 选择原物体
    greate_plane_center.y =sel_pivot_axis "y+"
    plane_p = Plane length:leng  width:wid pos:greate_plane_center
    plane_p.lengthsegs = gt_leng_theg 
    plane_p.widthsegs  = gt_width_thge
    plane_p.rotation.controller[1].value=-90
    ---这里转成mesh ,我想了下这里不进行转接了。针对后面的操作我在进行转换。
    ---坐标最好用两倍的操作。

    deleting_marker_sp() 
    
   )---end()
   
   ("y-"):
   (
    wid= abs (amax greate_plane_one[1] greate_plane_two[1])-(amin greate_plane_one[1] greate_plane_two[1])
    leng= abs (amax greate_plane_one[3] greate_plane_two[3])-(amin greate_plane_one[3] greate_plane_two[3])
    clearSelection()
    select gt_become_deformed_Align_sel_seltion ---- 选择原物体
    greate_plane_center.y =sel_pivot_axis "y-"
    plane_p = Plane length:leng  width:wid pos:greate_plane_center
    plane_p.lengthsegs= gt_leng_theg 
    plane_p.widthsegs= gt_width_thge
    plane_p.rotation.controller[1].value=90
    ---这里转成mesh ,我想了下这里不进行转接了。针对后面的操作我在进行转换。
    ---坐标最好用两倍的操作。

    deleting_marker_sp() 
    
    
   )---end()
   ("z+"):
   (
    wid= abs (amax greate_plane_one[1] greate_plane_two[1])-(amin greate_plane_one[1] greate_plane_two[1])
    leng= abs (amax greate_plane_one[2] greate_plane_two[2])-(amin greate_plane_one[2] greate_plane_two[2])
    clearSelection()
    select gt_become_deformed_Align_sel_seltion ---- 选择原物体
    greate_plane_center.z =sel_pivot_axis "z+"
    plane_p = Plane length:leng  width:wid pos:greate_plane_center
    plane_p.lengthsegs= gt_leng_theg 
    plane_p.widthsegs= gt_width_thge
    plane_p.rotation.controller[1].value=0
    ---这里转成mesh ,我想了下这里不进行转接了。针对后面的操作我在进行转换。
    ---坐标最好用两倍的操作。

    deleting_marker_sp() 
    
   )---end()
   
   ("z-"):
   (
    wid= abs (amax greate_plane_one[1] greate_plane_two[1])-(amin greate_plane_one[1] greate_plane_two[1])
    leng= abs (amax greate_plane_one[2] greate_plane_two[2])-(amin greate_plane_one[2] greate_plane_two[2])
    clearSelection()
    select gt_become_deformed_Align_sel_seltion ---- 选择原物体
    greate_plane_center.z =sel_pivot_axis "z-"
    plane_p = Plane length:leng  width:wid pos:greate_plane_center
    plane_p.lengthsegs= gt_leng_theg 
    plane_p.widthsegs= gt_width_thge
    plane_p.rotation.controller[1].value=180
    ---这里转成mesh ,我想了下这里不进行转接了。针对后面的操作我在进行转换。
    ---坐标最好用两倍的操作。

    deleting_marker_sp()
    
   )---end()
   
   ("x+"):
   (
    wid= abs (amax greate_plane_one[2] greate_plane_two[2])-(amin greate_plane_one[2] greate_plane_two[2])
    leng= abs (amax greate_plane_one[3] greate_plane_two[3])-(amin greate_plane_one[3] greate_plane_two[3])
    clearSelection()
    select gt_become_deformed_Align_sel_seltion ---- 选择原物体
    greate_plane_center.x =sel_pivot_axis "x+"
    plane_p = Plane length:leng  width:wid pos:greate_plane_center
    plane_p.lengthsegs= gt_leng_theg 
    plane_p.widthsegs= gt_width_thge
    plane_p.rotation.controller[3].value=90
    plane_p.rotation.controller[1].value=90
    ---这里转成mesh ,我想了下这里不进行转接了。针对后面的操作我在进行转换。
    ---坐标最好用两倍的操作。

    deleting_marker_sp()
    
   )---end()
   
   ("x-"):
   (
    wid= abs (amax greate_plane_one[2] greate_plane_two[2])-(amin greate_plane_one[2] greate_plane_two[2])
    leng= abs (amax greate_plane_one[3] greate_plane_two[3])-(amin greate_plane_one[3] greate_plane_two[3])
    clearSelection()
    select gt_become_deformed_Align_sel_seltion ---- 选择原物体
    greate_plane_center.x =sel_pivot_axis "x-"
    plane_p = Plane length:leng  width:wid pos:greate_plane_center
    plane_p.lengthsegs= gt_leng_theg 
    plane_p.widthsegs= gt_width_thge
    plane_p.rotation.controller[3].value=90
    plane_p.rotation.controller[1].value=-90
    ---这里转成mesh ,我想了下这里不进行转接了。针对后面的操作我在进行转换。
    ---坐标最好用两倍的操作。

    deleting_marker_sp()
    
   )---end()
   
  )---end case
  
  
  
  
 
 )
  
 )
 ---下面是开始工具
 starttool drawing__
 
)----end mouse_tools_customize

posted on 2011-05-05 09:29  盖天00  阅读(314)  评论(0编辑  收藏  举报

导航