Furball89
06-26-2011, 09:41 AM
Hey!
i am trying to recreate THIS! (http://www.youtube.com/watch?v=9Ykt0FADk7E) grid effect in max. At first i thought i could do this with some sort of a world space deformer, or maybe a soft selection volume select, but i couldn't figure it out :( . So i decided to use particles by pushing them outward with an sdeflector, but did not please me either, it did not look right! Then i started to play with refractive material in vray to get this effect but that doesn't offer much control either! so i ended up writing this script :-
but the problem with this approach is
a) its very slow! creating a 11x11x11 grid takes half an hour!
b) it still doesn't feel right! i think its because the way the curve is smoothing! i will try bezier
c) its not easy to control! for example, every time i need to change the positions of the helper i need to run the scriptB, which is slow too!
scriptA - Grid Creation:
(
try(
delete $*
)catch()
/*
*Functions
*/
/*Prerequisite : "Passing SplineShape Knot Selections Up The Stack" - in the maxscript help file
The function basiclly takes an array of point helpers and creates a spline with knotpoint at each helpers position
then links each knot point to the helper with a linked xform modifier*/
fn createLine i j k = (
theLine = splineShape()
theLine.optimize = false
theLine.adaptive = true
addNewSpline theLine
if (i == -1) do (
for i = 1 to gridSize do (
addKnot theLine 1 #smooth #curve gridArray[i][j][k].pos
)
updateShape theLine
for i = 1 to gridSize do (
es = edit_spline name:("Edit_Spline_" + (i as string))
addmodifier theLine es before:theLine.modifiers.count
modPanel.setCurrentObject es
max modify mode
subobjectlevel = 1
setknotselection theline 1 #(i)
lxf = linked_xform name:("LinkedXform_"+(i as string))
modPanel.addModToSelection lxf
lxf.control = gridArray[i][j][k]
if i != gridSize do (
ss = splineselect name:"Blocker"
addmodifier theLine ss before:theLine.modifiers.count
)
)
)
if (j == -1) do (
for j = 1 to gridSize do (
addKnot theLine 1 #smooth #curve gridArray[i][j][k].pos
)
updateShape theLine
for j = 1 to gridSize do (
es = edit_spline name:("Edit_Spline_" + (j as string))
addmodifier theLine es before:theLine.modifiers.count
modPanel.setCurrentObject es
max modify mode
subobjectlevel = 1
setknotselection theline 1 #(j)
lxf = linked_xform name:("LinkedXform_"+(j as string))
modPanel.addModToSelection lxf
lxf.control = gridArray[i][j][k]
if j != gridSize do (
ss = splineselect name:"Blocker"
addmodifier theLine ss before:theLine.modifiers.count
)
)
)
if (k == -1) do (
for k = 1 to gridSize do (
addKnot theLine 1 #smooth #curve gridArray[i][j][k].pos
)
updateShape theLine
for k = 1 to gridSize do (
es = edit_spline name:("Edit_Spline_" + (k as string))
addmodifier theLine es before:theLine.modifiers.count
modPanel.setCurrentObject es
max modify mode
subobjectlevel = 1
setknotselection theline 1 #(k)
lxf = linked_xform name:("LinkedXform_"+(k as string))
modPanel.addModToSelection lxf
lxf.control = gridArray[i][j][k]
if k != gridSize do (
ss = splineselect name:"Blocker"
addmodifier theLine ss before:theLine.modifiers.count
)
)
)
)
/*
*Main : Create the grid
*/
global gridSize = 9
global gridSpacing = 35
global gridArray = #()
for z = 1 to gridSize do (
gridArray[z] = #()
for y = 1 to gridSize do (
gridArray[z][y] = #()
for x =1 to gridSize do (
gridArray[z][y][x] = point pos:([x,y,z] * [gridSpacing,gridSpacing,gridSpacing]) name:((x as string) + "," + (y as string) + "," + (z as string))
)
)
)
/*Center the grid*/
for h in helpers do (
h.pos = h.pos + ([gridSpacing,gridSpacing,gridSpacing] * -1 * ((gridSize - 1)/2 + 1))
)
/*Create the mesh of lines*/
for i = 1 to gridArray.count do (
for j = 1 to gridArray[i].count do (
createLine i j -1
)
)
for i = 1 to gridArray.count do (
for k = 1 to gridArray[i].count do (
createLine i -1 k
)
)
for j = 1 to gridArray.count do (
for k = 1 to gridArray[j].count do (
createLine -1 j k
)
)
forcecompleteredraw()
)
scriptB - Radial Grid Expansion:
if (storeInitialPositions == undefined) do (
global gridSize = 9
global gridArray = #()
global initialPositions = #()
global storeInitialPositions = true
for i = 1 to gridSize do (
initialPositions[i] = #()
gridArray[i] = #()
for j = 1 to gridSize do (
initialPositions[i][j] = #()
gridArray[i][j] = #()
)
)
for h in helpers do (
theIndices = filterstring h.name ","
gridArray [theIndices[1] as number][theIndices[2] as number][theIndices[3] as number] = h
)
)
for h in helpers do (
theIndices = filterstring h.name ","
thePoint = (gridArray [theIndices[1] as number][theIndices[2] as number][theIndices[3] as number])
if (storeInitialPositions == true) do
initialPositions[theIndices[1] as number][theIndices[2] as number][theIndices[3] as number] = thePoint.pos
if (thePoint.pos != [0,0,0]) then (
--if ((length thePoint.pos) < $ball.radius) do(
--thePoint.pos = initialPositions[theIndices[1] as number][theIndices[2] as number][theIndices[3] as number]
thePoint.pos = ((length thePoint.pos) + (140/(length thePoint.pos)) ) * (normalize thePoint.pos)
--)
)
)
storeInitialPositions = false
is there any easier way to create this effect, thanks a lot for help :)
[HERE (http://hotfile.com/dl/122237278/25efcce/Grid.zip.html)is the max file, scrub the slide to see it expand, maybe you will see some error message if you do not have vray :shrug: just ignore those]
i am trying to recreate THIS! (http://www.youtube.com/watch?v=9Ykt0FADk7E) grid effect in max. At first i thought i could do this with some sort of a world space deformer, or maybe a soft selection volume select, but i couldn't figure it out :( . So i decided to use particles by pushing them outward with an sdeflector, but did not please me either, it did not look right! Then i started to play with refractive material in vray to get this effect but that doesn't offer much control either! so i ended up writing this script :-
but the problem with this approach is
a) its very slow! creating a 11x11x11 grid takes half an hour!
b) it still doesn't feel right! i think its because the way the curve is smoothing! i will try bezier
c) its not easy to control! for example, every time i need to change the positions of the helper i need to run the scriptB, which is slow too!
scriptA - Grid Creation:
(
try(
delete $*
)catch()
/*
*Functions
*/
/*Prerequisite : "Passing SplineShape Knot Selections Up The Stack" - in the maxscript help file
The function basiclly takes an array of point helpers and creates a spline with knotpoint at each helpers position
then links each knot point to the helper with a linked xform modifier*/
fn createLine i j k = (
theLine = splineShape()
theLine.optimize = false
theLine.adaptive = true
addNewSpline theLine
if (i == -1) do (
for i = 1 to gridSize do (
addKnot theLine 1 #smooth #curve gridArray[i][j][k].pos
)
updateShape theLine
for i = 1 to gridSize do (
es = edit_spline name:("Edit_Spline_" + (i as string))
addmodifier theLine es before:theLine.modifiers.count
modPanel.setCurrentObject es
max modify mode
subobjectlevel = 1
setknotselection theline 1 #(i)
lxf = linked_xform name:("LinkedXform_"+(i as string))
modPanel.addModToSelection lxf
lxf.control = gridArray[i][j][k]
if i != gridSize do (
ss = splineselect name:"Blocker"
addmodifier theLine ss before:theLine.modifiers.count
)
)
)
if (j == -1) do (
for j = 1 to gridSize do (
addKnot theLine 1 #smooth #curve gridArray[i][j][k].pos
)
updateShape theLine
for j = 1 to gridSize do (
es = edit_spline name:("Edit_Spline_" + (j as string))
addmodifier theLine es before:theLine.modifiers.count
modPanel.setCurrentObject es
max modify mode
subobjectlevel = 1
setknotselection theline 1 #(j)
lxf = linked_xform name:("LinkedXform_"+(j as string))
modPanel.addModToSelection lxf
lxf.control = gridArray[i][j][k]
if j != gridSize do (
ss = splineselect name:"Blocker"
addmodifier theLine ss before:theLine.modifiers.count
)
)
)
if (k == -1) do (
for k = 1 to gridSize do (
addKnot theLine 1 #smooth #curve gridArray[i][j][k].pos
)
updateShape theLine
for k = 1 to gridSize do (
es = edit_spline name:("Edit_Spline_" + (k as string))
addmodifier theLine es before:theLine.modifiers.count
modPanel.setCurrentObject es
max modify mode
subobjectlevel = 1
setknotselection theline 1 #(k)
lxf = linked_xform name:("LinkedXform_"+(k as string))
modPanel.addModToSelection lxf
lxf.control = gridArray[i][j][k]
if k != gridSize do (
ss = splineselect name:"Blocker"
addmodifier theLine ss before:theLine.modifiers.count
)
)
)
)
/*
*Main : Create the grid
*/
global gridSize = 9
global gridSpacing = 35
global gridArray = #()
for z = 1 to gridSize do (
gridArray[z] = #()
for y = 1 to gridSize do (
gridArray[z][y] = #()
for x =1 to gridSize do (
gridArray[z][y][x] = point pos:([x,y,z] * [gridSpacing,gridSpacing,gridSpacing]) name:((x as string) + "," + (y as string) + "," + (z as string))
)
)
)
/*Center the grid*/
for h in helpers do (
h.pos = h.pos + ([gridSpacing,gridSpacing,gridSpacing] * -1 * ((gridSize - 1)/2 + 1))
)
/*Create the mesh of lines*/
for i = 1 to gridArray.count do (
for j = 1 to gridArray[i].count do (
createLine i j -1
)
)
for i = 1 to gridArray.count do (
for k = 1 to gridArray[i].count do (
createLine i -1 k
)
)
for j = 1 to gridArray.count do (
for k = 1 to gridArray[j].count do (
createLine -1 j k
)
)
forcecompleteredraw()
)
scriptB - Radial Grid Expansion:
if (storeInitialPositions == undefined) do (
global gridSize = 9
global gridArray = #()
global initialPositions = #()
global storeInitialPositions = true
for i = 1 to gridSize do (
initialPositions[i] = #()
gridArray[i] = #()
for j = 1 to gridSize do (
initialPositions[i][j] = #()
gridArray[i][j] = #()
)
)
for h in helpers do (
theIndices = filterstring h.name ","
gridArray [theIndices[1] as number][theIndices[2] as number][theIndices[3] as number] = h
)
)
for h in helpers do (
theIndices = filterstring h.name ","
thePoint = (gridArray [theIndices[1] as number][theIndices[2] as number][theIndices[3] as number])
if (storeInitialPositions == true) do
initialPositions[theIndices[1] as number][theIndices[2] as number][theIndices[3] as number] = thePoint.pos
if (thePoint.pos != [0,0,0]) then (
--if ((length thePoint.pos) < $ball.radius) do(
--thePoint.pos = initialPositions[theIndices[1] as number][theIndices[2] as number][theIndices[3] as number]
thePoint.pos = ((length thePoint.pos) + (140/(length thePoint.pos)) ) * (normalize thePoint.pos)
--)
)
)
storeInitialPositions = false
is there any easier way to create this effect, thanks a lot for help :)
[HERE (http://hotfile.com/dl/122237278/25efcce/Grid.zip.html)is the max file, scrub the slide to see it expand, maybe you will see some error message if you do not have vray :shrug: just ignore those]
