First version of model deformation (completed by Ray)

Source: Internet
Author: User

-- Target_mesh = pickobject message: "Pick target surface:" filter: g_filter rubberband: selection. Center rubberbandcolor: Green --- this method is better. No more display;
-- This approach is implemented, and the following processes,
-- I want to learn from the Alignment Method and learn from the effect of this operation. The last time is the alignment of the object, this time is the alignment of the point.
--- Now I know the idea: (it may be necessary to change the process .)
--- 1. Convert the created surface to poly
--- 2. Select him to pick up another object,
--- 3. during the collection process, the coordinates of the collected points are controlled in six directions, the ray focus is found, and the coordinates of the points are set in sequence. At the same time, there is a data control to control the distance to the ing surface,

----- The following is the vertex collection function, which sets the vertex position for the following.
Global mode_become_deformed_vertexs_array = #()
 
FN collect_poly_vertexs input_poly =
(
--- It is explained that when I use this function, the selected object must be one, so there is no extra rate here.
--- The main purpose is to collect vertex coordinate information.
--- It is estimated that there is no option here, Because I added the error reporting mechanism before applying these functions.
Try (convertoffinput_poly editable_poly) catch (

MessageBox is not operated properly and does not follow the process. \ N returns. "Title:" written by gaitian"
Return false
)
----- Calculate the number of vertices.
Vertexs_count = polyop. getnumverts input_poly
--- Number of vertices collect vertex coordinates cyclically
--- Generally, no vertex state exists. To prevent an error reporting mechanism, this function is learned from the flying wolf. This is the pipe surface. Yes, the Large arc cannot be used here.
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

----- I want to modify the following function to specify the point for programming,

FN find_intersection_virects pick_mesh verts_pos = --- verts_pos selects each vertex of the patch .,
(
Try (
-- The same conditional numbers and computation are faster than strings, so strings are not needed.
--- Changed to Automatic loop processing. I only considered 6 items to be rubbed in a loop.
Local OOP
Local compare_array = #()
For I in 1 to 6 do
(
Oop = case

(

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

(I = 2): [0, 0, 1]

(I = 3): [-1, 0]

(I = 4): [1, 0, 0]

(I = 5): [0,-1, 0]

(I = 6): [0, 1]

-- Default: Reference $ foo
)
-- Print OOP

Local testray = Ray verts_pos OOP
Local nodemaxz

Case oop
(------ Z axis
([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 axis
([-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 = fig-0.0001 * ABS nodemaxz
)
------- Y axis
([0,-1, 0]): (nodemaxz = pick_mesh.max.y
Testray. Pos. Y = nodemaxz + 0.0001 * ABS nodemaxz
)
([0, 0]): (nodemaxz = pick_mesh.min.y
Testray. Pos. Y = fig-0.0001 * ABS nodemaxz
)
)

--- When using rays, I found that my previous things were good, and there were always two focal points in the loop process. For example, if you determine that only the external axis has a focus,
------- I am doing this. When the negative direction of the Y axis is shining, I place the position of the ray in the max direction of the object, and Zhang will have a focus,
------- When the direction of radiation is the positive direction of the Y axis,
--)
-- Testray. Pos. z = nodemaxz + 0.0001 * ABS nodemaxz
If intersectray pick_mesh testray! = Undefined then ---- focus of rays and objects.
(
--- Because I first set the negative direction of the X axis, in fact, the two directions are that my colleagues have all the good options for comparison.
-- 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
)

)*/
--- In fact, there are two better ones. Use the column method.
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 ()

)
 
---- Events to be arranged.
FN g_filter o = superclassof o = geometryclass
 
--- Execute from top to bottom. Run this command first.
FN gt_become_deformed_pick_aligner =
(
Target_mesh = pickobject message: "Pick target surface:" filter: g_filter rubberband: selection. Center rubberbandcolor: Green --- this method is better. No more display;
If isvalidnode target_mesh then --- this is useful if the node is not deleted.
(
Undo "scripts" on
(
--- Run the function to collect Arrays
Mode_become_deformed_vertexs_array = #
Collect_poly_vertexs $
--- Convert global variables into internal variables, so it is easier to write variables.

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
(
---- It should be the coordinates of the set point to the new position.

Ray_pos_point = int_point.pos --- position of the int_point.pos Ray
Polyop. setvert $ I ray_pos_point
-- Print int_point.pos
)
) -- End I loop



) -- End undo
) -- End if
) ---- End FN gt_become_deformed_pick_aligner
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.