Я тут недавно впервые попробовал написать деформер. В общем как я понял, если в блоке Parameters присутствует параметр с именем Radius, то в модификаторе появляется манипулятор для управления этим радиусом, при условии что в максе нажата кнопка Select and Manipulate.
Вопрос: Можно ли как-то добавить ещё один манипулятор? Ведь имя Radius уже занято.
На всякий случай код.
/*
author: Bodyul Vladislav
email: bodulwlpc@gmail.com
*/
plugin simpleMod SwirlingMod
name:"Swirling"
classID:#(0x1dad978f, 0x4fd0f4ba)
version:1
(
parameters main rollout:params
(
RotX type:#float ui:RotX_spn default:180
RotY type:#float ui:RotY_spn default:0
RotZ type:#float ui:RotZ_spn default:0
radius type:#float ui:Radius_spn default:50
falloffVal type:#float ui:Falloff_spn default:1
)
rollout params "Parameters"
(
groupbox grp1 "Angle" pos:[8,8] width:146 height:85
spinner RotX_spn "X: " pos:[62,27] type:#float range:[-100000,100000,0] scale:0.5
spinner RotY_spn "Y: " pos:[62,48] type:#float range:[-100000,100000,0] scale:0.5
spinner RotZ_spn "Z: " pos:[62,69] type:#float range:[-100000,100000,0] scale:0.5
groupbox grp2 "Radius" pos:[8,100] width:146 height:64
spinner Radius_spn "Radius: " pos:[36,119] type:#float range:[-100000,100000,50] scale:0.25
spinner Falloff_spn "Falloff: " pos:[38,140] type:#float range:[0,1000,1] scale:0.01
hyperlink url_hp "Bodyul Vladislav" pos:[45,170] address:"http://bodulwlpc.wix.com/ms-scripts" color:(color 0 170 230) hovercolor:(color 0 170 230) visitedcolor:(color 0 170 230)
)
on map i p do
(
local dist = (distance p center)
local val = (radius - dist)
if val < 0 then val = 0
local percent = (100. / radius * (pow radius (falloffVal + 1))) / 100.
val = (pow val (falloffVal + 1)) / percent
p *= (eulerangles (val * RotX / radius) (val * RotY / radius) (val * RotZ / radius)) as quat
p
)
)
/*
author: Bodyul Vladislav
email: bodulwlpc@gmail.com
*/
plugin simpleMod SwirlingMod
name:"Swirling"
classID:#(0x1dad978f, 0x4fd0f4ba)
version:1
(
parameters main rollout:params
(
RotX type:#float ui:RotX_spn default:180
RotY type:#float ui:RotY_spn default:0
RotZ type:#float ui:RotZ_spn default:0
radiusVal type:#float ui:Radius_spn default:50
falloffVal type:#float ui:Falloff_spn default:1
)
rollout params "Parameters"
(
groupbox grp1 "Angle" pos:[8,8] width:146 height:85
spinner RotX_spn "X: " pos:[62,27] type:#float range:[-100000,100000,0] scale:0.5
spinner RotY_spn "Y: " pos:[62,48] type:#float range:[-100000,100000,0] scale:0.5
spinner RotZ_spn "Z: " pos:[62,69] type:#float range:[-100000,100000,0] scale:0.5
groupbox grp2 "Radius" pos:[8,100] width:146 height:64
spinner Radius_spn "Radius: " pos:[36,119] type:#float range:[-100000,100000,50] scale:0.25
spinner Falloff_spn "Falloff: " pos:[38,140] type:#float range:[0,1000,1] scale:0.01
hyperlink url_hp "Bodyul Vladislav" pos:[45,170] address:"http://bodulwlpc.wix.com/ms-scripts" color:(color 0 170 230) hovercolor:(color 0 170 230) visitedcolor:(color 0 170 230)
)
on map i p do
(
local dist = (distance p center)
local val = (radiusVal - dist)
if val < 0 then val = 0
local percent = (100. / radiusVal * (pow radiusVal (falloffVal + 1))) / 100.
val = (pow val (falloffVal + 1)) / percent
p *= (eulerangles (val * RotX / radiusVal) (val * RotY / radiusVal) (val * RotZ / radiusVal)) as quat
p
)
)
-------------------------------
-- Generic radius manipulator
-- Written by Scott Morrison
-- This manipulator sets the radius on any object or modifier with
-- a parameter named "radius". It creates a circle gizmo of the appropriate
-- radius centered at the origin in the XY plane.
plugin simpleManipulator falloffValmanip
name:"falloffManip"
invisible:true
(
-- Create the green and red colors for the gizmo
local g = [0, 1, 0], r = [1, 0, 0]
-- This manipulator manipulates any node with a "radius" property
on canManipulate target do
(
if classof target == SwirlingMod then
return ((findItem (getPropNames target) #falloffVal) != 0 and (findItem (getPropNames target) #radiusVal) != 0)
)
-- Create the manipulator gizmo.
-- This is called initially and whenever the manipulator target changes
on updateGizmos do
(
if classof target == SwirlingMod then
(
-- Clear the current gizmo cache
this.clearGizmos()
-- Set the radius of circle gizmo a little bigger than the target radius
giz_radiusVal=manip.makeCircle [0,0,0] (target.radiusVal* 1.01) 28
giz_falloffVal=manip.makeCircle [0,0,0] (target.falloffVal * 1.01) 28
-- Add the circle to the manipulator
this.addGizmoShape giz_radiusVal 0 g r
this.addGizmoShape giz_falloffVal 0 g r
-- return the ToolTip string
--return node.name + " radius = " + target.radius as string
)--if classof target == SwirlingMod then
)
-- mouseMove is called on every mouse move when dragging the manip
-- It needs to convert the mouse position 'm' into a new value for the radius
on mouseMove m which do
(
if classof target == SwirlingMod then
(
-- Create the XY plane.
-- manip.makePlaneFromNormal takes a normal vector and a point
-- and creates a plane passing through the point with the given normal
local pl = manip.makePlaneFromNormal z_axis [0, 0, 0],
projectedPoint = [0,0,0]
-- Compute the hit-ray in local coordinates
viewRay = this.getLocalViewRay m
-- Intersect the plane with the view ray
res = pl.intersect viewRay &projectedPoint
-- If the intersection worked, set the radius
if (res) then
(
if which==0 then target.radiusVal = (length projectedPoint) / 1.01
if which==1 then target.falloffVal = (length projectedPoint) / 1.01
)--if (res) then
)--if classof target == SwirlingMod then
)--on mouseMove m which do
)
----------------------------
Доступ к резюме доступен только по пакетному доступу HR менеджерам зарегистрированных компаний. Узнать о вариантах корпоративных пакетов можно по ссылке.
Владислав Бодюл
Вопрос: Можно ли как-то добавить ещё один манипулятор? Ведь имя Radius уже занято.
На всякий случай код.
/* author: Bodyul Vladislav email: bodulwlpc@gmail.com */ plugin simpleMod SwirlingMod name:"Swirling" classID:#(0x1dad978f, 0x4fd0f4ba) version:1 ( parameters main rollout:params ( RotX type:#float ui:RotX_spn default:180 RotY type:#float ui:RotY_spn default:0 RotZ type:#float ui:RotZ_spn default:0 radius type:#float ui:Radius_spn default:50 falloffVal type:#float ui:Falloff_spn default:1 ) rollout params "Parameters" ( groupbox grp1 "Angle" pos:[8,8] width:146 height:85 spinner RotX_spn "X: " pos:[62,27] type:#float range:[-100000,100000,0] scale:0.5 spinner RotY_spn "Y: " pos:[62,48] type:#float range:[-100000,100000,0] scale:0.5 spinner RotZ_spn "Z: " pos:[62,69] type:#float range:[-100000,100000,0] scale:0.5 groupbox grp2 "Radius" pos:[8,100] width:146 height:64 spinner Radius_spn "Radius: " pos:[36,119] type:#float range:[-100000,100000,50] scale:0.25 spinner Falloff_spn "Falloff: " pos:[38,140] type:#float range:[0,1000,1] scale:0.01 hyperlink url_hp "Bodyul Vladislav" pos:[45,170] address:"http://bodulwlpc.wix.com/ms-scripts" color:(color 0 170 230) hovercolor:(color 0 170 230) visitedcolor:(color 0 170 230) ) on map i p do ( local dist = (distance p center) local val = (radius - dist) if val < 0 then val = 0 local percent = (100. / radius * (pow radius (falloffVal + 1))) / 100. val = (pow val (falloffVal + 1)) / percent p *= (eulerangles (val * RotX / radius) (val * RotY / radius) (val * RotZ / radius)) as quat p ) )igorznag
/* author: Bodyul Vladislav email: bodulwlpc@gmail.com */ plugin simpleMod SwirlingMod name:"Swirling" classID:#(0x1dad978f, 0x4fd0f4ba) version:1 ( parameters main rollout:params ( RotX type:#float ui:RotX_spn default:180 RotY type:#float ui:RotY_spn default:0 RotZ type:#float ui:RotZ_spn default:0 radiusVal type:#float ui:Radius_spn default:50 falloffVal type:#float ui:Falloff_spn default:1 ) rollout params "Parameters" ( groupbox grp1 "Angle" pos:[8,8] width:146 height:85 spinner RotX_spn "X: " pos:[62,27] type:#float range:[-100000,100000,0] scale:0.5 spinner RotY_spn "Y: " pos:[62,48] type:#float range:[-100000,100000,0] scale:0.5 spinner RotZ_spn "Z: " pos:[62,69] type:#float range:[-100000,100000,0] scale:0.5 groupbox grp2 "Radius" pos:[8,100] width:146 height:64 spinner Radius_spn "Radius: " pos:[36,119] type:#float range:[-100000,100000,50] scale:0.25 spinner Falloff_spn "Falloff: " pos:[38,140] type:#float range:[0,1000,1] scale:0.01 hyperlink url_hp "Bodyul Vladislav" pos:[45,170] address:"http://bodulwlpc.wix.com/ms-scripts" color:(color 0 170 230) hovercolor:(color 0 170 230) visitedcolor:(color 0 170 230) ) on map i p do ( local dist = (distance p center) local val = (radiusVal - dist) if val < 0 then val = 0 local percent = (100. / radiusVal * (pow radiusVal (falloffVal + 1))) / 100. val = (pow val (falloffVal + 1)) / percent p *= (eulerangles (val * RotX / radiusVal) (val * RotY / radiusVal) (val * RotZ / radiusVal)) as quat p ) ) ------------------------------- -- Generic radius manipulator -- Written by Scott Morrison -- This manipulator sets the radius on any object or modifier with -- a parameter named "radius". It creates a circle gizmo of the appropriate -- radius centered at the origin in the XY plane. plugin simpleManipulator falloffValmanip name:"falloffManip" invisible:true ( -- Create the green and red colors for the gizmo local g = [0, 1, 0], r = [1, 0, 0] -- This manipulator manipulates any node with a "radius" property on canManipulate target do ( if classof target == SwirlingMod then return ((findItem (getPropNames target) #falloffVal) != 0 and (findItem (getPropNames target) #radiusVal) != 0) ) -- Create the manipulator gizmo. -- This is called initially and whenever the manipulator target changes on updateGizmos do ( if classof target == SwirlingMod then ( -- Clear the current gizmo cache this.clearGizmos() -- Set the radius of circle gizmo a little bigger than the target radius giz_radiusVal=manip.makeCircle [0,0,0] (target.radiusVal* 1.01) 28 giz_falloffVal=manip.makeCircle [0,0,0] (target.falloffVal * 1.01) 28 -- Add the circle to the manipulator this.addGizmoShape giz_radiusVal 0 g r this.addGizmoShape giz_falloffVal 0 g r -- return the ToolTip string --return node.name + " radius = " + target.radius as string )--if classof target == SwirlingMod then ) -- mouseMove is called on every mouse move when dragging the manip -- It needs to convert the mouse position 'm' into a new value for the radius on mouseMove m which do ( if classof target == SwirlingMod then ( -- Create the XY plane. -- manip.makePlaneFromNormal takes a normal vector and a point -- and creates a plane passing through the point with the given normal local pl = manip.makePlaneFromNormal z_axis [0, 0, 0], projectedPoint = [0,0,0] -- Compute the hit-ray in local coordinates viewRay = this.getLocalViewRay m -- Intersect the plane with the view ray res = pl.intersect viewRay &projectedPoint -- If the intersection worked, set the radius if (res) then ( if which==0 then target.radiusVal = (length projectedPoint) / 1.01 if which==1 then target.falloffVal = (length projectedPoint) / 1.01 )--if (res) then )--if classof target == SwirlingMod then )--on mouseMove m which do ) ----------------------------Владислав Бодюл
Спасибо.