18 dic 2006
|
#1
|
|
Megalodon...
Fecha de Ingreso: abril-2002
Ubicación: Aquí
Mensajes: 9,107
|
Softselection manipulator
Un compañero me ha pasado este script para la creacion de un manipulador para el softselection, es bastante comodo pero no me gusta su forma de gizmo esferico. A mi me gustaria que fuera un circulo que siempre tuviera la misma forma en todas las camaras. No se como hacerlo, evidentemente, y me gustaria que los expertos le echaran un ojo para saber si es posible hacerlo.
Gracias.
Saludetes.
Cita:
----------------------------------------------------------------------------------------
-- Script: Poly SSelectFalloff Manipulator
-- Version: v01.Max4
-- Started: 2/17/01
-- Last Modified: 2/18/01
-- Description: Adds Manipulator for SoftSelection Falloff in Editable Poly
-- Code by: Martin Coven mcoven@austin.rr.com
-- Thanks to: John Versluis and Borislav Petrov for their great help
-- Based on the Radius Manipulator code by Scott Morrisson from Discreet.
-- rework by Larry Minton 6/26/01
----------------------------------------------------------------------------------------
plugin simpleManipulator Poly_ssfalloffManip
name:"Poly_SSFalloffManip"
invisible:true
(
-- Create the green and red colors for the gizmo
local g = green -- [0,1,0]
local r = [1,0,0]
local b = [0,0,1]
local y = [1,1,0]
local GizPos, targClass, interface
-- This manipulator manipulates editable meshes and polys
on canManipulate target do -- called at class level, can't access plugin local variables
( getCommandPanelTaskMode() == #modify and
( local targClass = classof target
targClass == editable_poly or targClass == editable_mesh
)
)
-- Create the manipulator gizmo.
-- This is called initially and whenever the manipulator target changes
on updateGizmos do
(
try
(
-- Clear the current gizmo cache
this.clearGizmos()
targClass = classof target
interface = if targClass == editable_poly then polyop else if targClass == editable_mesh then meshop
local useSoftSel =
if targClass == editable_poly then target.useSoftSel
else if targClass == editable_mesh then meshop.getSoftSel target
else false
local size =
if targClass == editable_poly then target.falloff
else if targClass == editable_mesh then meshop.getfalloff target
if useSoftSel and subobjectlevel > 0 then
( local verts =
if subObjectLevel == 1 then -- verts
( if targClass == editable_poly then interface. getVertSelection target
else if targClass == editable_mesh then node.selectedVerts as bitarray -- why no meshop.getVertSelection?
)
else if subObjectLevel == 2 then -- edges
interface. getVertsUsingEdge target #selection
else -- faces
interface. getVertsUsingFace target #selection
GizPos = [0,0,0]
for i in verts do (GizPos += interface. getVert target i) -- local coord space
GizPos /= verts.numberSet
local giz1 = manip.makecircle [0,0,0] size 24
local my_tm = matrixFromNormal [0,1,0]
my_tm.position = GizPos
giz1.transform my_tm
local giz2 = manip.makecircle gizpos size 24
local giz3 = manip.makecircle [0,0,0] size 24
my_tm = matrixfromnormal [1,0,0]
my_tm.position = GizPos
giz3.transform my_tm
-- Add the circle to the manipulator
this.addGizmoShape giz1 0 g r
this.addGizmoShape giz2 0 g r
this.addGizmoShape giz3 0 g r
-- return the ToolTip string
node.name + " SSel falloff = " + size as string
)
)
catch()
)
-- 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 falloff
on mouseMove m which do
( try
(
-- manip.makePlaneFromNormal takes a normal vector and a point
-- and creates a plane passing through the point with the given normal
local axis = case which of -- get axis based on which gizmo hit
( 0: y_axis
1: z_axis
2: x_axis
)
local pl = manip.makePlaneFromNormal axis GizPos
-- Compute the hit-ray in local coordinates
local viewRay = this.getLocalViewRay m
-- Intersect the plane with the view ray
local projectedPoint = [0,0,0]
local res = pl.intersect viewRay &projectedPoint
-- format "% : % : % : %\n" viewRay projectedPoint GizPos which
-- If the intersection worked, set the falloff
if (res) then
( projectedPoint = GizPos - projectedPoint
local size = sqrt(projectedPoint.x^2+ projectedPoint.y^2+ projectedPoint.z^2)
if targClass == editable_poly then target.falloff = size
else if targClass == editable_mesh then (meshop.setuiparam target #falloff size;update node geometry:false topology:false normals:false) --meshop UI parameter setters broken
)
)
catch()
)
)
|
__________________
( ::: ) Tus puñetazos no sirven para nada. No puedes matar a tu maestro de boxeo con golpes que has aprendido de él.
Lu Sin
|
|
|