[Closed] 3D Grid Effect
Hey!
i am trying to recreate THIS! 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
[HEREis 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 would use a script to create the spline geometry, and skin or ffd modifier to animate its deformation.
Thanks for the reply!
yea I am using splines! the script creates splines and then uses linked xform modifier to link the splines knot points to point helpers (i got the idea from maxscript help file topic “Passing SplineShape Knot Selections Up The Stack” but this method takes lot of time to create the stack for multiple knot points, isn’t there any fast way to link a knot point to a point helper?)! i tried using spline ik modifier but the problem with it is, you have to create separate point helpers for each spline!.. Will give animating the FDD vertices a shot! i think the “animate vertex” or something method is used for that (have to check mx help!).
Not that i want to discourage you from scripting it, by all means, go ahead and have fun!
But, have you tried using box primitives and adding lattice modifier?
I’ve just tested it, the trick is to use symmetry modifier wisely and position the mirror precisely.
Try it on a simple 2x2x2 grid and if you like the result, expand as needed.
Create a box dimensions: h:10, w: 20, l: 10, segments: h:1, w: 2, l:1
position x:0, y: 5, z: 0
add modifier lattice: adjust radius and segments, turn of joints
collapse the stack
add symmetry modifer, use Y axis, positon the mirror to [0,0,0] in world space
add another symetry, use Z axis, positon the miror to [0,0,5] in world space.
collapse stack.
And you’ve got your 2x2x2 grid.
For larger grids and more segments simply create a wider box primitve with more segments and use additional symmetry modifier to reach the full volume.
just my 2 cents.
Cheers!
Even better, you can use a plane, extrude it by polygon and add lattice on top. Collapse stack and it’s done.
Thanks for the reply!
please watch the link i posted in my first post, i want to animate the grid expanding radially as well, lattice modifier will only give me the grid! i tried using the "spherify" modifier, it obviously din't work, heh i have tried so many methods for this simple effect lol! been playing with fdd now, some problems i am facing, the control points are offset! i.e they are not centered to the origin (and they are normalized too!!) by default even though the object and the lattice transforms are set to (matrix3 1, or identity matrix) :S (no big deal can perform my computation and re transform the fdd points back, i guess!) also how can i loop through each control point !?! i am using the execute method like so:
fddSize = 3
for i = 1 to (fddSize*fddSize*fddSize) do (
[b]cp = execute ("$.modifiers[1].control_point_" + (i as string))[/b]
point pos:(cp * [140,140,140])
)
but there is an easier, more elegant, way right!? (i am modifying the control points directly for testing, i will write the positions to there controllers later, oh or better still, just use the [b]animate [/b][b]context[/b])
thanks for the help :)
After modeling the grid, you should reset x form, center the pivot, align to world and definitely collapse the stack. You can then easily use ffd to expand it any way you want it.
This was done in 5 minutes.
A 20x20x20 grid.
Created a plane 200×200, segments 20×20. Selected all edged and clicked split. Selected all polygons, and extruded by polygon, 10 units, clicked apply 20 times. Selected all vertices, click weld. Collapse stack. Add Lattice, use Struts only, radius 0.1. Collapse stack, reset x form, collapse again, apply 3x3x3 FFD and deform. Works like a charm.
Just saying.
Thanks for the reply!
Created a plane 200×200, segments 20×20. Selected all edged and clicked split. Selected all polygons, and extruded by polygon, 10 units, clicked apply 20 times. Selected all vertices, click weld. Collapse stack. Add Lattice, use Struts only, radius 0.1. Collapse stack, reset x form, collapse again, apply 3x3x3 FFD and deform. Works like a charm.
Thanks for this! you the best! .