I haven’t coded anything yet, but I have some ideas in my head. I just need to trim down my ideas to something I can finished.
here is my web:
I tried to generate bones for the “rays” to deform the web, but my rigging knowledge is still not good enough to script it.
There is no inteface for my script, just execute it with “crtl-e”.
And you need the webdings font, looks like this is a standard font … ???
Here is the download link: rdg-spiderweb.ms
Here is the code:
(
-- a spider web
-- CgTalk Maxscript Challenge 014: "Spider Web"
-- ---
-- setup
-- needs inteface
-- ---
-- complexity of the web
complex = 40
-- radius of the web
r = 200
-- number of rays
rays = random 5 10
-- ---
--- clean up
try(
delete $Spider
delete $spiderweb
)catch()
-- the spider
theSpider = text()
theSpider.name = uniquename "Spider"
theSpider.text = "!"
theSpider.font = "Webdings"
addModifier theSpider (extrude amount:1)
theRot = eulerangles 0 0 180
rotate theSpider theRot
theRot = eulerangles 90 0 0
rotate theSpider theRot
-- the web
theweb = line()w
theweb.name = uniquename "spiderweb"
for i = 1 to rays do (
addNewSpline theweb
addKnot theweb i #smooth #line [0,0,0]
tetha=360/rays * i + (random -10 10)
phi=(random 0 360)
r = r + (random -10 10)
x=r*(cos tetha)
y=r*(sin tetha)
for j = 1 to complex do (
addKnot theweb i #smooth #line ([x, y, 0]/complex*j)
)
)
addNewSpline theweb
print rays
for i = 1 to complex do (
currRay = ((mod (i-1) rays) + 1 )
print currRay
addKnot theweb (rays+1) #smooth #line (getKnotPoint theweb (currRay as integer) i)
)
-- place the spider
addNewSpline theweb
addKnot theweb (rays + 2) #smooth #line [0, 0, 0]
spiderOffset = random 20 100
addKnot theweb (rays + 2) #smooth #line [0, 0, -spiderOffset]
updateshape theweb
theSpider.pos = [0, 0, -spiderOffset]
theweb.render_renderable = true
theweb.render_displayRenderMesh = true
theweb.render_thickness = 2
theSpider.parent = theweb
theweb.material = theSpider.material = standard()
)
I am looking forward seeing the other entries.
Georg
Hi Georg,
Nice web. What about using an FFD(box) Modifier to animate it?
I also tried using a an edit poly on the generated web from your script. Then linked xform using the spider as the control object. Here’s a quick sample.
Chris
Crap, I misread the date. I thought we had until Dec 12.
I hadn’t started yet.
Can we get an extension?
I didn’t get started on this till the 4th but here is my quick web tool, there are many more features that I would like to add but time did not permit.
USAGE:
Copy and evaluate the following code to get the spider web UI, make a web frame, customize it or don’t and then push the big button to make the web. If you turn off the gravity effect, which makes the web segments droop down, the web segments will bow towards the center point (classic halloween look). I could explain more of the features but I was hoping it would be fun to experiment with what I was able to add.
This was a fun challenge, but I should have started a few days earlier
-------------------------------------------------
-------------------------------------------------
-- spiderWebGenerator
-- written by: Blue
-- version 1.0
-- history:
-- Tuesday, Dec 05, 2006 - changed framing method to spline
-- Monday, Dec 04, 2006 - started development
--
-- TODO:
--
-------------------------------------------------
-------------------------------------------------
global spiderWebROLL
(
centerNode = undefined
webShape
webShapeNgon
webShapeCustom
knotPositionArray
centerPos = [0,0,0]
webBendLow = 0.05
webBendHigh = 0.05
try(DestroyDialog spiderWebROLL)catch()
-------------------------------------------------
-- main UI
-------------------------------------------------
rollout spiderWebROLL "Spider Web Generator v1.0 - by Blue" width:300 height:237
(
fn splineFilter obj = classof obj == SplineShape
fn enableCreatWebButton =
(
try
(
if webShape.name != undefined then spiderWebROLL.createWeb.enabled = true
)
catch(spiderWebROLL.createWeb.enabled = false)
)
button createFrame "Template Web Frame" height:20 width:135 across:3 offset:[6,0]
button frameSwap "<-" height:20 width:20 offset:[1,0]
pickbutton customFrame "Pick Custom Frame" height:20 width:135 offset:[-27,0] filter:splineFilter
label step2Label "Edit the Web Frame to adjust placement of points and" align:#left
label step21Label "add points as needed." align:#left
pickButton webCenter "Overide Center Node - undefined" height:20 width:270 across:2 offset:[10,0]
button resetCenter "X" height:20 width:20 offset:[67,0]
label optionsLabel "Options:" width:39 height:13 align:#left
spinner webSegs "Web Segs :" width:80 height:16 range:[4,100,24] type:#integer across:2 align:#left
checkbox webSegsRandom "Random Seg Length" width:122 height:15 checked:true align:#left
checkbox webbingGapsRandom "Random Gaps" width:92 height:15 checked:true across:2 align:#left
spinner webbingGapsRandomPercent "Gap % " width:80 height:16 range:[0,100,15] align:#left
checkbox webbingBendEnabled "Webbing Bend" width:95 height:15 checked:true across:2 align:#left
checkbox webbingBendRandom "Randomize Bend" width:105 height:15 checked:false align:#left
checkbox webbingGravity "Gravity" width:57 height:15 checked:true across:2 align:#left
spinner webbingGravityStrength "Strength " width:90 height:16 range:[0,1000,5.0] align:#left
button createWeb "Create Web From Web Frame" height:40 width:290 offset:[-1,0] enabled:false
timer finishWeb "" interval:100 active:false
on createFrame pressed do
(
webShapeNgon = ngon radius:30 nSides:8
webShapeNgon.name = "Web Frame"
frameSwap.text = "<-"
webShape = webShapeNgon
convertTo webShapeNgon SplineShape
enableCreatWebButton()
)
on frameSwap pressed do
(
if frameSwap.text == "<-" then
(
frameSwap.text = "->"
webShape = webShapeCustom
enableCreatWebButton()
)
else
(
frameSwap.text = "<-"
webShape = webShapeNgon
enableCreatWebButton()
)
)
on customFrame picked obj do
(
webShapeCustom = obj
convertTo obj SplineShape
frameSwap.text = "->"
webShape = webShapeCustom
customFrame.text = obj.name
enableCreatWebButton()
)
on webCenter picked node do
(
centerNode = node
webCenter.text = "Overide Center Node - " + node.name
centerPos = centerNode.pos
)
on resetCenter pressed do
(
centerNode = undefined
webCenter.text = "Overide Center Node - undefined"
)
on webbingBendEnabled changed state do
(
if state == true then
(
webbingBendRandom.enabled = true
webbingGravity.enabled = true
if webbingBendRandom.checked == true then
(
webBendLow = 0.01
webBendHigh = 0.05
)
else
(
webBendLow = 0.05
webBendHigh = 0.05
)
)
else
(
webbingBendRandom.enabled = false
webbingGravity.enabled = false
webBendLow = 0.0
webBendHigh = 0.0
)
)
on webbingBendRandom changed state do
(
if state == true then
(
webBendLow = 0.01
webBendHigh = 0.05
)
else
(
webBendLow = 0.05
webBendHigh = 0.05
)
)
on createWeb pressed do
(
disableSceneRedraw()
splineDivisions = webSegs.value
knotPositionArray = #()
for i = 1 to (numKnots webShape 1) do
(
append knotPositionArray (getKnotPoint webShape 1 i)
)
if centerNode == undefined then
(
centerPos = [0,0,0]
for i in knotPositionArray do
(
centerPos += i
)
centerPos /= knotPositionArray.count
)
else
(
try(centerPos = centerNode.pos)catch()
)
webSpline = SplineShape()
for i = 1 to knotPositionArray.count do
(
addNewSpline webSpline
addKnot webSpline i #smooth #curve centerPos
addKnot webSpline i #smooth #curve knotPositionArray[i]
updateShape webSpline
subdivideSegment webSpline i 1 splineDivisions
updateShape webSpline
)
if webSegsRandom.checked == true then
(
for i = 1 to knotPositionArray.count do
(
for j = 2 to (splineDivisions + 1) do
(
scaledPos = ((getKnotPoint webSpline i j)-(((getKnotPoint webSpline i j) - ((getKnotPoint webSpline i (j-1))))*(random -.5 .5)))
setKnotType webSpline i j #smooth
setKnotPoint webSpline i j scaledPos
updateShape webSpline
)
setKnotType webSpline i (splineDivisions + 2) #corner
setKnotType webSpline i 1 #corner
)
)
addNewSpline webSpline
webbingSpline = knotPositionArray.count + 1
ringPoint = 2
addKnot webSpline webbingSpline #corner #curve (getKnotPoint webSpline 1 ringPoint)
for i = 2 to (splineDivisions + 1) do
(
for j = 1 to knotPositionArray.count do
(
addKnot webSpline webbingSpline #corner #curve (getKnotPoint webSpline j i)
)
)
updateShape webSpline
for i = (knotPositionArray.count * splineDivisions) to 1 by -1 do
(
subdivideSegment webSpline (knotPositionArray.count + 1) i 1
updateShape webSpline
)
webArcCount = (splineDivisions * (knotPositionArray.count * 2))
for i = 2 to webArcCount by 2 do
(
setKnotSelection webSpline webbingSpline #(i) keep:true
)
updateShape webSpline
selectedKnots = getKnotSelection webSpline webbingSpline
if webbingBendEnabled.checked == true then
(
for i = 1 to selectedKnots.count do
(
if webbingGravity.checked == true then
(
scaledPos = ((getKnotPoint webSpline webbingSpline selectedKnots[i])-(((getKnotPoint webSpline webbingSpline selectedKnots[i]) - centerPos)*(random webBendLow webBendHigh)))
scaledPos = (getKnotPoint webSpline webbingSpline selectedKnots[i]) - scaledPos
scaledPos = (getKnotPoint webSpline webbingSpline selectedKnots[i]) - (([0,0,((abs(scaledPos[1]) + abs(scaledPos[2]) + abs(scaledPos[3]))/3)])*webbingGravityStrength.value)
)
else
(
scaledPos = ((getKnotPoint webSpline webbingSpline selectedKnots[i])-(((getKnotPoint webSpline webbingSpline selectedKnots[i]) - centerPos)*(random webBendLow webBendHigh)))
)
setKnotPoint webSpline webbingSpline selectedKnots[i] scaledPos
setKnotType webSpline webbingSpline selectedKnots[i] #smooth
updateShape webSpline
)
)
if webbingGapsRandom.checked == true then
(
for i = (numSegments webSpline webbingSpline) to 2 by -2 do
(
if (random 0 100.0) < webbingGapsRandomPercent.value then
(
setSegSelection webSpline webbingSpline #(i,(i-1)) keep:true
)
updateShape webSpline
)
max modify mode
select webSpline
subobjectlevel = 2
splineOps.delete webSpline
updateShape webSpline
finishWeb.active = true
)
webSpline.pivot = webSpline.center
webSpline.render_renderable = true
webSpline.render_thickness = 0.05
enableSceneRedraw()
)
on finishWeb tick do
(
finishWeb.active = false
subobjectlevel = 0
enableSceneRedraw()
)
)
createdialog spiderWebROLL style:#(#style_minimizebox, #style_titlebar, #style_sysmenu, #style_border)
)
Blue,
I like your frame approach, though I didn’t get the custom frame mode working.
No spline type is selectable … ???
I was thinking a lot how to figure out
how to constrain the web to userdefines shapes, and you showed a good way.
Chris,
thanks for the movie
Georg
Hmmm, you should only be able to select a splineshape from the custom frame pickbutton. Do you have an example object that you were trying to pick but wasn’t working? Keep in mind that the spline should only have one shape in it. Try converting the object to spline first. Worst case senario make one of the default web frames and delete the splines in it, and attach the spline that was not working to the web frame.
Well, in any case thanks for giving it a run.
hey, congratulations, it work’s really well! looks nice!
there are nearly endless things that would be cool like scripted waterdrops on the web and wind effects or something… keep it up man!! it’s so cool
Water droplets (the main reasons I added control for gravity strength), anchor thread sag, applying materials etc… were on my todo for this challenge, but time ran out. Maybe in v2 wouldn’t be to hard to do, just need the time.