CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 02-07-2013, 07:25 PM   #16
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,498
Send a message via ICQ to denisT
new version includes Radius Bias
Code:
/* 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() )
 
Old 02-07-2013, 07:35 PM   #17
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,307
Send a message via AIM to JokerMartini
If radius2 = 0.0 it should weld all the center verts. Rather than having them all sit ontop of one another.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 02-07-2013, 09:26 PM   #18
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,498
Send a message via ICQ to denisT
Quote:
Originally Posted by JokerMartini
If radius2 = 0.0 it should weld all the center verts. Rather than having them all sit ontop of one another.

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)
Code:
/* 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() )
 
Old 02-07-2013, 09:28 PM   #19
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,307
Send a message via AIM to JokerMartini
could always make it an option.
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 02-12-2013, 04:00 PM   #20
JokerMartini
Expert
 
JokerMartini's Avatar
portfolio
John Martini
CG Supervisor, 3D, Maxscript, VFX
Ingenuity Engine
Los Angeles, USA
 
Join Date: Mar 2009
Posts: 1,307
Send a message via AIM to JokerMartini
Denis

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.

Code:
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() )
__________________
____________ ___ __ _
John A. Martini
JokerMartini@hotmail.com
www.JokerMartini.com
 
Old 02-12-2013, 04:00 PM   #21
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:17 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.