Notifications
Clear all
[Closed] Books and more books
Page 2 / 2
Prev
Feb 07, 2013 12:28 am
slice… ok, ok… here is it:
/* denisT collection 2013 */
plugin simpleObject ConePlus name:"ConePlus"
classID:#(0x00001967, 0x1023099b)
category:"Standard Plus"
version:1
(
local coneobject
parameters params rollout:params
(
radius1 type:#worldUnits default:0 ui:ui_radius1
radius2 type:#worldUnits default:0 ui:ui_radius2
height type:#worldUnits default:0 ui:ui_height
bias type:#float default:0 ui:ui_bias
biasPower type:#float default:10 ui:ui_biasPower
heightsegs type:#integer default:1 ui:ui_heightsegs
capsegs type:#integer default:1 ui:ui_capsegs
sides type:#integer default:16 ui:ui_sides
smooth type:#boolean default:on ui:ui_smooth
sliceOn type:#boolean default:off ui:ui_sliceOn
sliceFrom type:#float default:0 ui:ui_sliceFrom
sliceTo type:#float default:0 ui:ui_sliceTo
mapCoords type:#boolean default:on ui:ui_mapCoords
realWorldMapSize type:#boolean default:off ui:ui_realWorldMapSize
on sliceOn get val do try
(
this.params.ui_sliceFrom.enabled = this.params.ui_sliceTo.enabled = val
)
catch (false)
)
rollout params "Parameters"
(
spinner ui_radius1 "Radius 1: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,0]
spinner ui_radius2 "Radius 2: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,-2]
spinner ui_height "Height: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,2]
spinner ui_bias "Height Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_biasPower "Bias Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2] tooltip:"Bias Power"
spinner ui_heightsegs "Height Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,4]
spinner ui_capsegs "Cap Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,0]
spinner ui_sides "Sides: " type:#integer range:[3,256,0] fieldwidth:52 align:#right offset:[8,0]
checkbox ui_smooth "Smooth" align:#left offset:[83,4]
checkbox ui_sliceOn "Slice On" align:#left offset:[83,2]
spinner ui_sliceFrom "Slice From: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,0]
spinner ui_sliceTo "Slice To: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_mapCoords "Generate Mapping Coords." align:#left offset:[-8,4]
checkbox ui_realWorldMapSize "Real-World map Size" align:#left offset:[-8,0]
)
on buildmesh do
(
fn fastValue f bias:0.0 power:1 =
(
if bias < 0 then 1 - (pow (1 - f) (1 - power*bias)) else (pow f (1 + power*bias))
)
if coneobject == undefined do coneobject = createinstance cone
coneobject.radius1 = radius1
coneobject.radius2 = radius2
coneobject.height = height
coneobject.heightsegs = heightsegs
coneobject.capsegs = capsegs
coneobject.sides = sides
coneobject.smooth = smooth
coneobject.sliceOn = sliceOn
coneobject.sliceFrom = sliceFrom
coneobject.sliceTo = sliceTo
coneobject.mapCoords = mapCoords
coneobject.realWorldMapSize = realWorldMapSize
mesh = coneobject.mesh
for k=1.0 to heightsegs-1 do
(
ss = if sliceOn then (sides+2) else sides
s = (k*ss+2) + (capsegs-1)*ss
e = ((k+1)*ss+1) + (capsegs-1)*ss
verts = #{s..e}
z = height*(fastValue (k/heightsegs) bias:bias power:biasPower)
for v in verts do
(
p = getvert mesh v
setvert mesh v [p.x,p.y,z]
)
)
update mesh
)
tool create
(
on mousePoint click do case click of
(
1: nodeTM.translation = gridPoint
4: #stop
)
on mouseMove click do case click of
(
2: radius1 = amax (abs gridDist.x) (abs gridDist.y)
3: height = gridDist.z
4: radius2 = amax (abs gridDist.x) (abs gridDist.y)
)
)
)
Feb 07, 2013 12:28 am
That is pretty slick.
I’ll have to play around with it and see what I can learn from it in how you are making an arch.
Feb 07, 2013 12:28 am
Adjust the span and the height then run
delete objects
clearlistener()
span = 200.0
height = 30.0
h = 1.0/2.0*(span)
a = -(height) / ((span - h)^2) -- equation to get a
for i = 0.0 to span by 5.0 do
(
x = i --distance out from center
arch = (a*((x - h)^2)) + height
b= box height:2.0 width:2.0 length:2.0 wirecolor:[1*i,120,120] pos:[i/(2),0,arch]
)
Feb 07, 2013 12:28 am
new version includes Radius Bias
/* denisT collection 2013 */
plugin simpleObject ConePlus name:"ConePlus"
classID:#(0x00001967, 0x1023099b)
category:"Standard Plus"
version:1
(
local coneobject
parameters params rollout:params
(
radius1 type:#worldUnits default:0 ui:ui_radius1
radius2 type:#worldUnits default:0 ui:ui_radius2
radiusBias type:#float default:0 ui:ui_radiusBias
radiusBiasPower type:#float default:10 ui:ui_radiusBiasPower
height type:#worldUnits default:0 ui:ui_height
heightBias type:#float default:0 ui:ui_heightBias
heightBiasPower type:#float default:10 ui:ui_heightBiasPower
heightsegs type:#integer default:1 ui:ui_heightsegs
capsegs type:#integer default:1 ui:ui_capsegs
sides type:#integer default:16 ui:ui_sides
smooth type:#boolean default:on ui:ui_smooth
sliceOn type:#boolean default:off ui:ui_sliceOn
sliceFrom type:#float default:0 ui:ui_sliceFrom
sliceTo type:#float default:0 ui:ui_sliceTo
mapCoords type:#boolean default:on ui:ui_mapCoords
realWorldMapSize type:#boolean default:off ui:ui_realWorldMapSize
on sliceOn get val do try
(
this.params.ui_sliceFrom.enabled = this.params.ui_sliceTo.enabled = val
)
catch (false)
)
rollout params "Parameters"
(
spinner ui_radius1 "Radius 1: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,0]
spinner ui_radius2 "Radius 2: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,-2]
spinner ui_radiusBias "Radius Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_radiusBiasPower "Radius Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_height "Height: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,6]
spinner ui_heightBias "Height Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_heightBiasPower "Height Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_heightsegs "Height Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,6]
spinner ui_capsegs "Cap Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,-2]
spinner ui_sides "Sides: " type:#integer range:[3,256,0] fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_smooth "Smooth" align:#left offset:[83,6]
checkbox ui_sliceOn "Slice On" align:#left offset:[83,2]
spinner ui_sliceFrom "Slice From: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,0]
spinner ui_sliceTo "Slice To: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_mapCoords "Generate Mapping Coords." align:#left offset:[-8,4]
checkbox ui_realWorldMapSize "Real-World map Size" align:#left offset:[-8,0]
)
fn domesh =
(
fn fastValue f heightBias:0.0 power:1 =
(
if heightBias < 0 then 1 - (pow (1 - f) (1 - power*heightBias)) else (pow f (1 + power*heightBias))
)
if coneobject == undefined do coneobject = createinstance cone
coneobject.radius1 = radius1
coneobject.radius2 = radius2
coneobject.height = height
coneobject.heightsegs = heightsegs
coneobject.capsegs = capsegs
coneobject.sides = sides
coneobject.smooth = smooth
coneobject.sliceOn = sliceOn
coneobject.sliceFrom = sliceFrom
coneobject.sliceTo = sliceTo
coneobject.mapCoords = mapCoords
coneobject.realWorldMapSize = realWorldMapSize
mesh = coneobject.mesh
for k=1.0 to heightsegs-1 do
(
f = k/heightsegs
ss = if sliceOn then (sides+2) else sides
s = (k*ss+2) + (capsegs-1)*ss
e = ((k+1)*ss+1) + (capsegs-1)*ss
verts = #{s..e}
r = radius1 + (radius2 - radius1)*(fastValue f heightBias:radiusBias power:radiusBiasPower)
h = height*(fastValue f heightBias:heightBias power:heightBiasPower)
for v in verts do
(
d = getvert mesh v
p = (normalize [d.x,d.y,0])*r
setvert mesh v [p.x,p.y,h]
)
)
update mesh
mesh
)
on buildmesh do domesh()
tool create
(
on mousePoint click do case click of
(
1: nodeTM.translation = gridPoint
4: #stop
)
on mouseMove click do case click of
(
2: radius1 = amax (abs gridDist.x) (abs gridDist.y)
3: height = gridDist.z
4: radius2 = amax (abs gridDist.x) (abs gridDist.y)
)
)
on update do domesh()
)
Feb 07, 2013 12:28 am
If radius2 = 0.0 it should weld all the center verts. Rather than having them all sit ontop of one another.
1 Reply
i don’t think so. it should behave the same way as cone
there is a new version (i fixed topology issue when slice was on)
/* denisT collection 2013 */
plugin simpleObject ConePlus name:"ConePlus"
classID:#(0x00001967, 0x1023099b)
category:"Standard Plus"
version:1
(
local coneobject
parameters params rollout:params
(
radius1 type:#worldUnits default:0 ui:ui_radius1
radius2 type:#worldUnits default:0 ui:ui_radius2
radiusBias type:#float default:0 ui:ui_radiusBias
radiusBiasPower type:#float default:10 ui:ui_radiusBiasPower
height type:#worldUnits default:0 ui:ui_height
heightBias type:#float default:0 ui:ui_heightBias
heightBiasPower type:#float default:10 ui:ui_heightBiasPower
heightsegs type:#integer default:1 ui:ui_heightsegs
sides type:#integer default:16 ui:ui_sides
capsOn type:#boolean default:on ui:ui_capsOn
capsegs type:#integer default:1 ui:ui_capsegs
smooth type:#boolean default:on ui:ui_smooth
sliceOn type:#boolean default:off ui:ui_sliceOn
sliceFrom type:#float default:0 ui:ui_sliceFrom
sliceTo type:#float default:0 ui:ui_sliceTo
mapCoords type:#boolean default:on ui:ui_mapCoords
realWorldMapSize type:#boolean default:off ui:ui_realWorldMapSize
on capsOn get val do
(
try(this.params.ui_capsegs.enabled = val) catch (false)
val
)
on sliceOn get val do
(
try(this.params.ui_sliceFrom.enabled = this.params.ui_sliceTo.enabled = val) catch (false)
val
)
)
rollout params "Parameters"
(
spinner ui_radius1 "Bottom Radius: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,0]
spinner ui_radius2 "Top Radius: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,-2]
spinner ui_radiusBias "Radius Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_radiusBiasPower "Radius Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_height "Height: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,6]
spinner ui_heightBias "Height Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_heightBiasPower "Height Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_heightsegs "Height Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,6]
spinner ui_sides "Sides: " type:#integer range:[3,256,0] fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_capsOn "Caps On" align:#left offset:[83,4]
spinner ui_capsegs "Cap Segments: " type:#integer enabled:capsOn range:[1,256,0] fieldwidth:52 align:#right offset:[8,0]
checkbox ui_smooth "Smooth" align:#left offset:[83,6]
checkbox ui_sliceOn "Slice On" align:#left offset:[83,2]
spinner ui_sliceFrom "Slice From: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,0]
spinner ui_sliceTo "Slice To: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_mapCoords "Generate Mapping Coords." align:#left offset:[-8,4]
checkbox ui_realWorldMapSize "Real-World map Size" align:#left offset:[-8,0]
)
fn domesh =
(
fn fastValue f heightBias:0.0 power:1 =
(
if heightBias < 0 then 1 - (pow (1 - f) (1 - power*heightBias)) else (pow f (1 + power*heightBias))
)
if coneobject == undefined do coneobject = createinstance cone
coneobject.radius1 = radius1
coneobject.radius2 = radius2
coneobject.height = height
coneobject.heightsegs = heightsegs
coneobject.capsegs = capsegs
coneobject.sides = sides
coneobject.smooth = smooth
coneobject.sliceOn = sliceOn
coneobject.sliceFrom = sliceFrom
coneobject.sliceTo = sliceTo
coneobject.mapCoords = mapCoords
coneobject.realWorldMapSize = realWorldMapSize
mesh = coneobject.mesh
for v=1 to mesh.numverts do
(
d = getvert mesh v
if d.z > 0 and d.z < height do
(
f = d.z/height
h = height*(fastValue f heightBias:heightBias power:heightBiasPower)
if (r = length [d.x,d.y,0]) > 0 do
(
f = (r-radius1)/(radius2-radius1)
r = radius1 + (radius2-radius1)*(fastValue f heightBias:radiusBias power:radiusBiasPower)
)
p = (normalize [d.x,d.y,0])*r
setvert mesh v [p.x,p.y,h]
)
)
if not capsOn do
(
faces = #{}
for f=1 to mesh.numfaces do faces[f] = (getfacematid mesh f != 3)
meshop.deletefaces mesh faces
)
update mesh
mesh
)
on buildmesh do domesh()
tool create
(
on mousePoint click do case click of
(
1: nodeTM.translation = gridPoint
4: #stop
)
on mouseMove click do case click of
(
2: radius1 = amax (abs gridDist.x) (abs gridDist.y)
3: height = gridDist.z
4: radius2 = amax (abs gridDist.x) (abs gridDist.y)
)
)
on update do domesh()
)
Feb 07, 2013 12:28 am
Here is some additional fun…radial noise controls.
You’ll see I commented out some code I had implemented to resemble what you had there, but it kept throwing errors when it was un-commented.
Anywho it works great. Fun to mess with.
plugin simpleObject ConePlus name:"ConePlus"
classID:#(0x00001967, 0x1023099b)
category:"Standard Plus"
version:1
(
local coneobject
parameters params rollout:params
(
radius1 type:#worldUnits default:0 ui:ui_radius1
radius2 type:#worldUnits default:0 ui:ui_radius2
radiusBias type:#float default:0 ui:ui_radiusBias
radiusBiasPower type:#float default:10 ui:ui_radiusBiasPower
noiseFrequency type:#float default:1 animatable:off ui:ui_noiseFrequency
noisePhase type:#float default:0 animatable:off ui:ui_noisePhase
noiseScale type:#float default:1 animatable:off ui:ui_noiseScale
height type:#worldUnits default:0 ui:ui_height
heightBias type:#float default:0 ui:ui_heightBias
heightBiasPower type:#float default:10 ui:ui_heightBiasPower
heightsegs type:#integer default:1 ui:ui_heightsegs
capsegs type:#integer default:1 ui:ui_capsegs
sides type:#integer default:16 ui:ui_sides
smooth type:#boolean default:on ui:ui_smooth
sliceOn type:#boolean default:off ui:ui_sliceOn
sliceFrom type:#float default:0 ui:ui_sliceFrom
sliceTo type:#float default:0 ui:ui_sliceTo
mapCoords type:#boolean default:on ui:ui_mapCoords
realWorldMapSize type:#boolean default:off ui:ui_realWorldMapSize
on sliceOn get val do try
(
this.params.ui_sliceFrom.enabled = this.params.ui_sliceTo.enabled = val
)
catch (false)
)
rollout params "Parameters"
(
spinner ui_radius1 "Radius 1: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,0]
spinner ui_radius2 "Radius 2: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,-2]
spinner ui_radiusBias "Radius Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_radiusBiasPower "Radius Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_noiseScale "Noise Scale: " range:[-1e9,1e9,0] type:#float scale:0.01 fieldwidth:54 align:#right offset:[8,6] tooltip:"Noise Scale"
spinner ui_noiseFrequency "Noise Frequency: " range:[0,1e9,0] type:#float scale:0.01 fieldwidth:54 align:#right offset:[8,-2] tooltip:"Noise Frequency"
spinner ui_noisePhase "Noise Phase: " range:[-1e9,1e9,0] type:#float scale:0.1 fieldwidth:54 align:#right offset:[8,-2] tooltip:"Noise Phase"
spinner ui_height "Height: " type:#worldUnits range:[0,1e9,0] fieldwidth:52 align:#right offset:[8,6]
spinner ui_heightBias "Height Bias: " type:#float range:[-1,1,0] scale:0.01 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_heightBiasPower "Height Power: " range:[1,100,0] type:#float scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
spinner ui_heightsegs "Height Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,6]
spinner ui_capsegs "Cap Segments: " type:#integer range:[1,256,0] fieldwidth:52 align:#right offset:[8,-2]
spinner ui_sides "Sides: " type:#integer range:[3,256,0] fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_smooth "Smooth" align:#left offset:[83,6]
checkbox ui_sliceOn "Slice On" align:#left offset:[83,2]
spinner ui_sliceFrom "Slice From: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,0]
spinner ui_sliceTo "Slice To: " type:#float enabled:sliceOn range:[-1e9,1e9,0] scale:0.1 fieldwidth:52 align:#right offset:[8,-2]
checkbox ui_mapCoords "Generate Mapping Coords." align:#left offset:[-8,4]
checkbox ui_realWorldMapSize "Real-World map Size" align:#left offset:[-8,0]
)
fn domesh =
(
fn fastValue f heightBias:0.0 power:1 =
(
if heightBias < 0 then 1 - (pow (1 - f) (1 - power*heightBias)) else (pow f (1 + power*heightBias))
)
if coneobject == undefined do coneobject = createinstance cone
coneobject.radius1 = radius1
coneobject.radius2 = radius2
-- coneobject.noiseFrequency = noiseFrequency
-- coneobject.noisePhase = noisePhase
-- coneobject.noiseScale = noiseScale
coneobject.height = height
coneobject.heightsegs = heightsegs
coneobject.capsegs = capsegs
coneobject.sides = sides
coneobject.smooth = smooth
coneobject.sliceOn = sliceOn
coneobject.sliceFrom = sliceFrom
coneobject.sliceTo = sliceTo
coneobject.mapCoords = mapCoords
coneobject.realWorldMapSize = realWorldMapSize
mesh = coneobject.mesh
for k=1.0 to heightsegs-1 do
(
f = k/heightsegs
ss = if sliceOn then (sides+2) else sides
s = (k*ss+2) + (capsegs-1)*ss
e = ((k+1)*ss+1) + (capsegs-1)*ss
verts = #{s..e}
noise = ((noise3 ([f*noiseFrequency,0,noisePhase]))*10*noiseScale)
r = radius1 + (radius2 - radius1)*(fastValue f heightBias:radiusBias power:radiusBiasPower) + noise
h = height*(fastValue f heightBias:heightBias power:heightBiasPower)
print noise
for v in verts do
(
d = getvert mesh v
p = (normalize [d.x,d.y,0])*r
setvert mesh v [p.x,p.y,h]
)
)
update mesh
mesh
)
on buildmesh do domesh()
tool create
(
on mousePoint click do case click of
(
1: nodeTM.translation = gridPoint
4: #stop
)
on mouseMove click do case click of
(
2: radius1 = amax (abs gridDist.x) (abs gridDist.y)
3: height = gridDist.z
4: radius2 = amax (abs gridDist.x) (abs gridDist.y)
)
)
on update do domesh()
)
Page 2 / 2
Prev