Notifications
Clear all
[Closed] Edge Spin
Feb 22, 2011 9:52 am
Hi
Please… which is the best way move p1 and p2 around axis z folowing mouse pos in screen?
I’m used a tool to do it, but cant finish it…
for test select edit poly sphere and start tool
when two points has been created on surface then a middle point (helper) will shown up
third click should spin edge like in picture…
(
local drawing_points = false, poly_obj
local irs = #(), markers = #(), mid_pos, mid_vect, hit1_dist
fn getScreenRayAtNode obj =
(
screenRay = mapScreenToWorldRay mouse.pos
finalRay = intersectRay obj screenRay
finalRay
)
fn isEditPoly obj = (classOf obj == editable_poly)
fn spinLine vp irs =
(
local mouse_pos = vp.pos
local mouse_vect = normalize (mouse_pos - mid_pos)
local new_vect = normalize (cross mid_vect mouse_vect)
local new_p1 = (mid_pos + new_vect * hit1_dist)
markers[1].pos= new_p1
--markers[2].pos=
)
tool pickPoints
(
on start do
(
poly_obj = selection[1]
if not isEditPoly poly_obj do #stop
poly_obj.xray = true
)
on mousePoint click do
(
local ir = getScreenRayAtNode poly_obj
if click > 1 do
(
--spin
if mid_pos != undefined then
(
local vp = (mapScreentoWorldRay ViewPoint)
point pos:vp.pos dir:vp.dir
spinLine vp irs
irs = #()
mid_pos = undefined
)
else
(
--create
if ir != undefined and irs.count < 2 do
(
irs += #(ir)
markers += #(point pos:ir.pos dir:ir.dir)
)
--create two points and middle point
if irs.count == 2 and mid_pos == undefined do
(
mid_pos = (irs[1].pos + irs[2].pos)/2
mid_vect = normalize (irs[1].dir + irs[2].dir)/2
hit1_dist = distance irs[1].pos mid_pos
point pos:mid_pos dir:mid_vect
)
)
--#stop
)
)
on mouseMove click do ()
)
startTool pickPoints
)
I hope is clear…so… I will be glad for any help