Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rollout pusher "Normal push" width:150 height:66
- (
- --Normal Push Works with Editable Poly only
- button 'btn1' "Push" pos:[10,33] width:130 height:23 align:#left
- spinner 'spn1' "Dist:" type:#worldunits pos:[10,8] width:140 height:16 align:#left range:[-10000,10000,1]
- fn GetVectorsAngle v1 v2 =
- (
- ang = acos(dot (normalize v1) (normalize v2))
- if bit.isNAN ang then 0.0 else ang
- )
- fn GetProportionalityFactor a = (
- 1/(cos a)
- )
- fn pushIt _ = (
- undo on(
- val = spn1.value
- obj = $
- faces = polyop.getFaceSelection obj
- vertices = #()
- directions = #()
- vert_normals = #()
- for face in faces do(
- polyVerts = polyop.getFaceVerts obj face
- normal = polyop.getFaceNormal obj face
- for v in polyVerts do (
- foundResult = findItem vertices v
- if foundResult == 0 then(
- append vertices v
- append directions normal
- append vert_normals normal
- ) else (
- oldDirection = directions[foundResult]
- newDirection = oldDirection + normal
- directions[foundResult] = newDirection
- )
- )
- )
- for i = 1 to vertices.count do(
- curVert = vertices[i]
- curDir = normalize directions[i]
- k = GetProportionalityFactor (GetVectorsAngle curDir vert_normals[i])
- offset = curDir*val*k
- polyop.moveVert obj curVert offset
- )
- )
- )
- on btn1 pressed do
- pushIt 0
- )
- createDialog pusher
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement