zoukankan      html  css  js  c++  java
  • 射线类型做好。把平面映射到物体上,

    --  target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter  rubberBand:selection.center  rubberBandColor:green --- 这种拾取的方法更好。不用再显示;
    --这样的思路进行,下面的处理,
    --我要借鉴之前的对齐方式,对这次的效果进行借鉴。上次是对物体的对齐,这次是对点的对齐处理。
    ---现在我知道的思路是:(下来为了流程话可能要改。)
    ---1.把创建的面转成poly
    ---2.选择他去拾取另一个物体,
    ---3.在拾取的过程中,收集点的坐标对 6 个方向控制,找到射线焦点,依次设定点的坐标,同时也有一个数据控制,控制到映射表面的距离,

    ----- 下面是收集顶点函数,为了下面的设置顶点的位置。
     global mode_become_deformed_vertexs_array =#()
     
      fn collect_poly_vertexs input_poly  =
      (
       ---这里说明下,我在用这个函数的时候,选择的物体肯定是一个,所以这里就不多率了。
       ---主要的目的就是收集顶点坐标信息。
       ---这里面估计也不存在没有选择的情况,因为在应用这些函数的时候 前面我就加入了报错机制。
         try ( convertTo  input_poly  Editable_Poly )catch (
       
       messagebox "操作不当,没按流程操作。\n返回。" title:"盖天编写"
       return false
      )
      -----求顶点数量。
      vertexs_count = polyop.getNumVerts  input_poly
      ---顶点数量循环 收集顶点坐标
      ---一般不会出现没有顶点状态, 这里面为了防止 加一个报错机制,这个函数是从飞狼哪里学来的。 他的是管面的, 是的大的括弧这里不能用
       if vertexs_count==0 then  return false
        for  i in 1 to vertexs_count do
        (
         vertexs_pos =  polyop.getVert input_poly i
        
         append mode_become_deformed_vertexs_array  vertexs_pos
        )

      )----end fn collect_poly_vertexs


    -----下面这个函数我要改造下,编程指定点的,

     fn find_intersection_virects  pick_mesh verts_pos =   ---verts_pos 选择面片的每一个顶点。,
     (
      try(
      --同样的条件 数字及计算要比字符串快 所以能用数字 不用字符串。
      ---改写成自动的循环处理的, 我考虑的因为只有6 个 所有用循环擦看。
      local oop
             local  compare_array =#()  
      for i in 1 to 6 do
      (
     oop=case of

       (

       (i==1): [0,0,-1]

       (i ==2): [0,0,1]
        
       (i ==3):[-1,0,0]
        
       (i==4):[1,0,0]
        
       (i ==5):[0,-1,0]
        
       (i ==6):[0,1,0]

       --default: reference $foo
       )
      -- print oop

      local testRay = ray verts_pos  oop
      local nodeMaxZ
      
       case oop  of
       (  ------Z 轴
        ([0,0,-1]) :(nodeMaxZ = pick_mesh.max.z
         testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
         
         )
        ([0,0,1]) :(nodeMaxZ = pick_mesh.min.z
         testRay.pos.z = nodeMaxZ - 0.0001 * abs nodeMaxZ  
        )
        -------X轴 
        ([-1,0,0]) : (nodeMaxZ = pick_mesh.max.x
         testRay.pos.x = nodeMaxZ + 0.0001 * abs nodeMaxZ   
        )
        ([1,0,0]) : (nodeMaxZ = pick_mesh.min.x
        testRay.pos.x = nodeMaxZ - 0.0001 * abs nodeMaxZ   
        )
       ------- Y轴
              ([0,-1,0]) : (nodeMaxZ = pick_mesh.max.y
        testRay.pos.y = nodeMaxZ + 0.0001 * abs nodeMaxZ   
        )
        ([0,1,0]) : (nodeMaxZ = pick_mesh.min.y
        testRay.pos.y = nodeMaxZ - 0.0001 * abs nodeMaxZ   
        ) 
       )
       
           ---在此利用射线时,我发现我之前的东西不错, 循环的过程总为什么有两个焦点是这样的。 如判断现在只有在外轴上有焦点,
       -------我就这样做,当像y轴的负方向照射时,我把射线的位置放到,物体的max 方向,张就会有一个焦点,
       -------当我射线照射方向 是y轴的正方向时,
      --)
      --testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
        if  intersectRay pick_mesh testRay !=undefined then ----射线与物体求焦点。
        (
         ---因为我先做了x轴的负方向 其实两个方向是同事存在了 所有 好要进行比较了
        --return
           append  compare_array  (intersectRay pick_mesh testRay)
        
       --  exit
        
        )
        
           
       
      )/*
       for i in compare_array do
       (
       distance_d =   distance  $selection[1].pos  i.pos
      --print compare_array[1].pos
        distance_c=0
        if distance_d>= distance_c then
        (
          distance_c =distance_d
        )
       
       )*/
      ---其实就有两个我比较下好; 用列举法
       distance_d =   distance  $selection[1].pos  compare_array[1].pos
      try ( distance_c =   distance  $selection[1].pos  compare_array[2].pos )
      catch ( distance_c =distance_d+20)
        if amin distance_d  distance_c == distance_d then
        (
         return compare_array[1]
        )else
        (
         return compare_array[2]
        )
       ) catch ()
      
     )
     
     ----下来安排的事件。
      fn g_filter o = superclassof o == Geometryclass
     
      ---从上到下执行。先执行这里的这个。
      fn gt_become_deformed_pick_Aligner   =
      (
      target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter  rubberBand:selection.center  rubberBandColor:green --- 这种拾取的方法更好。不用再显示;
      if isValidNode target_mesh then ---这个好用, 是如果节点没有被删除。
      (
       undo "scripts" on
       (
        ---运行函数在收集数组
        mode_become_deformed_vertexs_array=#()--每次运行钱在定义嗲空组
        collect_poly_vertexs $
        ---把全局变量转成内部变量用,这样写作变量相对容易一些。
       
        vertexs_array =mode_become_deformed_vertexs_array
       
        for i in 1 to  vertexs_array.count do
        (
         int_point = find_intersection_virects  target_mesh vertexs_array[i]
       -- print  int_point as string
         if int_point != undefined and  int_point != ok then
       (
        ----应该是设置的点的坐标 到新的位置上去。
        
       ray_pos_point = int_point.pos ---int_point.pos 射线的位置
       polyop.setVert $  i  ray_pos_point
       -- print int_point.pos
      )
        )--end i loop
       
       
       
       )--end undo
      )--end if
     )----end fn  gt_become_deformed_pick_Aligner
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     

  • 相关阅读:
    怎样将文件夹打包为jar包或war包
    tomcat6.0安装
    jdk安装
    spring cloud深入学习(十一)-----服务网关zuul
    spring cloud深入学习(十)-----配置中心和消息总线(配置中心终结版)
    spring cloud深入学习(九)-----配置中心服务化和高可用
    spring cloud深入学习(八)-----配置中心svn示例和refresh
    spring cloud深入学习(七)-----配置中心git示例
    spring cloud深入学习(六)-----熔断监控Hystrix Dashboard和Turbine
    dubbo入门学习(一)-----分布式基础理论、架构发展以及rpc、dubbo核心概念
  • 原文地址:https://www.cnblogs.com/gaitian00/p/2038095.html
Copyright © 2011-2022 走看看