PDA

View Full Version : Could any one write a script: to create a sponge (a new idea)


hammerbchen
09-20-2005, 07:36 AM
Hi all, and to rdg:
I had a new idea to create a sponge-like object. Again, need help to realize this idea:
last time I proposed to creat a dot in a defined space, the dot flying around, and we use the trace of the dot to create a sponge-like structure. Then Mr. rdg create a very nice script like the idea.

Thanks for rdg insperation, now I had a new idea in my mind:
First, in a defined space, create many dot (or vertexs), each dot with similiar distance but not exactly the same. Then create spline from two of the vertexs, for each vertexs create a spline. But not all vertexs are connect to each other, set a thresold of distance for vertexs connection. Therefore, for each vertexs, only have few (maybe 5-7) to others vertexs. Finally, set all the spline with mesh, and add noise to the mesh. The final product would be very similar to a real world sponge.

Sorry for my English, I hope you understand my idea. So anyone know how to do it by scripting?

Thanks.



Hammer B. Chen

rdg
09-20-2005, 08:23 AM
Hammer,

I think I understand your approach.
I allready had the idea of having the option for multiple strings inside the sponge-thing.
Testing all vertices for a distance against all other vertices could be really slow ...
But a VolumeSelect could help.

I will give it a try.


Georg

j-man
09-20-2005, 08:32 AM
Hi everyone,

It seems to me you could just do exctly as you've before, and then select and delete a random selection of segments from your newly created shape, and this would leave you with multiple strings inside your volume like what you've described.
And also, as RDG pointed out before, if you want to use a non geometric volumne (ie: any mesh) you could use my laserbeam script from the CGTalk challenge 007, and then select and delete random segments.

www.joshuanewman.net/scripts/download/LaserWarsV1.1-01.zip (http://www.joshuanewman.net/scripts/download/LaserWarsV1.1-01.zip)

Please tell me if I miss-understood!

Regards,


rdg
09-20-2005, 08:42 AM
deleting random segements is a good idea.
having points connected to point with a given distance is not only a more "engineeric" approach, it will give you tendril like dead ends and last but not least will take much much longer images/icons/icon12.gif

I want to implement all three apprach, so we can see the differneces.
Also the LaserWars-Genesis-Option needs to be implemented finally.

I will just replace my soon to crash harddrive ...

Georg

hammerbchen
09-21-2005, 02:31 AM
Hmmm..deleting random segements will certainly looks different to vertex-linking approach.

For the vertex-linking approach, tendril like dead might give some realism to the sponge. So the three different or combination will represent different species of sponge.:)

j-man
09-21-2005, 04:46 PM
Hey Hammer,

I'd love to see some pics of these sponges to get a good idea about what you want to create, got any handy?

J.

rdg
09-21-2005, 06:24 PM
hi,

http://proforma.preset.de/cgtalk/scripts/rdg_object_thing-o-string-v.2.ms

I am trying to delete random segements. But somehow it won't work.
After creating the sponge I collect random segments and try to delete them. The selection stuff works but no segments are deleted?


max modify mode
select sponge
subobjectlevel=2
segArray=#()
for i=1 to (numSegments sponge 1) do (
if (random 0 100) < genPerc_spn.value then (
append segArray i
)
)
-- print segArray
setSegSelection sponge 1 segArray
updateShape sponge
splineOps.delete sponge

The genesis options are:
continuous: one thing made of one string
rdg: the mysterious value is percentage of the object desitity and controlls max string length. after max string length is reached a new string is added
j_man: one thing made of one string. then each segemtn is deleted by chance of the mysterious value ...
Hammer: not implemented yet.

another idea: assign different MatIds to the resulting splines/segments and generate a Multi/Subobject-Material with differnet Hues or Saturations.

The Question is: How to delete those segements ?



Georg

rdg
09-22-2005, 12:33 PM
this snippet creates a spline selects random segements and deletes them:
(
sponge = SplineShape pos:[0,0,0]
addnewspline sponge
for i=1 to 10 do (
addknot sponge 1 #corner #line [(random 0 25), (random 0 25), (random 0 25)]
)
updateShape sponge
segArray=#()
for i=1 to (numSegments sponge 1) do (
if (random 0 100) < 50 then (
append segArray i
)
)
max modify mode
select sponge
subobjectlevel=2
setSegSelection sponge 1 segArray
splineOps.delete sponge
subobjectlevel=0
)

But in my thing-o-string the segements aren't deleted.

Anybody knows why?

Georg

j-man
09-22-2005, 02:03 PM
Hi RDG,

Strange. I wrote this to test, and it works.


spl=splineshape()
s=addnewspline spl
for i=1 to 50 do addknot spl s #corner #line [i*10,(random 0 100),0]
updateshape spl
segs=#()
for i=1 to 10 do (setsegselection spl 1 #((random 1 50)) keep:true)
max modify mode
select spl
subobjectlevel=2
splineops.delete spl
subobjectlevel=0



It seems though, when placed inside brackets (as your test rig is) or called in a function, it doesn't. Sorry, I cannot explain why.


fn deleteseg splshp=
(
max modify mode
select spl
subobjectlevel=2
splineops.delete splshp
subobjectlevel=0
)
spl=splineshape()
s=addnewspline spl
for i=1 to 50 do addknot spl s #corner #line [i*10,(random 0 100),0]
updateshape spl
segs=#()
for i=1 to 10 do (setsegselection spl 1 #((random 1 50)) keep:true)
deleteseg spl


How about adding a deletespline modifier to the stack?


prettyPixel
09-22-2005, 02:06 PM
It's probably an update problem.
If you don't return in subobjectlevel=0, the obliteration occurs.
I'm not familiar with the Splines.

rdg
09-22-2005, 02:31 PM
prettyPixel, j_man,

not returning to subobjectlevel=0 works in j_man's example function.
But in my script the deletion still doesn't happen.

I never heard of the deleteSpline Modifier before - but it does what I need.
And there is no documentation in the MAXreference ... anyway:

stay tuned for more sponges !

http://proforma.preset.de/cgtalk/scripts/rdg_object_thing-o-string-v.2.ms (http://proforma.preset.de/cgtalk/scripts/rdg_object_thing-o-string-v.2.ms)
**: j_man genesis working
**: enhanced rdg genesis

Georg

j-man
09-22-2005, 04:40 PM
Maybe it's a bug. It's probably a question for Larry or Bobo anyway. Why don't you post it at the discreet ah-hem AME board.

Anyway, there is always another way!

Well done,

Josh.

hammerbchen
09-24-2005, 01:37 AM
Hi all, and to rdg:

I had another aproach in mind, however maybe need not by scripting:
1)create a solid object, so the object have many vertexs inside its body.
2)apply a lattice modifer to the object (turn on the stick but not ball option)
3)apply a noise modifer

But the problem is: how could I creat a solid obect with a scattered vertexs inside its body.


P.S: I will upload my "real sponge" pictures later.



Thanks.

hammerbchen
09-24-2005, 02:35 PM
Hey!

I modify my idea, and this time almost create the things I want:
1)create a super spray particle
2)set the particle geometry to sphere
3)ajust the size of the sphere and life....this superspray particle will be the body of the sponge, let the particle bump to each other.
4)create a compund object--mesher, select the superspray that we previous create
5)apply a lattice modifer to the mesher
6)in the lattice modifer layout, turn on stick only not ball, change the size of the stick smaller.


that it, but still this method creat many hole and intersecting meshs problem, anyone have suggestion?


Regard

Hammer.

hammerbchen
09-28-2005, 07:56 AM
Hi:

Just post some great links about 3d sponge (search keyword: liquid foams, Surface Evolver simulation)

I wish those can inspire you to script something like that! :thumbsup:
http://www.esam.northwestern.edu/~sascha/foam.html
http://www.susqu.edu/facstaff/b/brakke/

prettyPixel
09-29-2005, 09:55 AM
Interesting thread :)

I am also interested by the creation of structures, particularly the structures in honeycomb.
One moment ago, I had written a script to do that by modifying a plan but the method was limited.
The idea of structure inspired to me an another concept:
The structure is formed gradually. It extends gradually. I adapted the principle of the structures in honeycomb in the script which follows.
After that, I added random factors to move the vectors before they connect itself to the others. That allows to create structures like sponges.
Here is my participation.

rollout honeycombRollout "honeycomb"
(
group "honeycomb"
(
spinner numberLinks_osd "number links: " range:[3,2000,400] type:#integer scale:1.0 fieldWidth:40
spinner nodeSize_osd "link size: " range:[1.0,10000.0,10.0] type:#float scale:1.0 fieldWidth:40
spinner nodeLinks_osd "links by node: " range:[1,8,3] type:#integer scale:1.0 fieldWidth:40
spinner varLength_osd "length var.: %" range:[0.0,250.0,40.0] type:#float scale:0.1 fieldWidth:40
spinner varAngle_osd "angle var.: deg" range:[0.0,360.0,40.0] type:#float scale:0.1 fieldWidth:40
spinner weldZone_osd "weld zone: %" range:[0.0001,75.0,60.0] type:#float scale:0.5 fieldWidth:40
button calculate_osd "create"
)
group "presets"
(
dropdownlist preset_osd "" items:#("studious bees","sponge","oh no") selection:2 height:4
)
label lb1 "by Olivier Vandecasteele"
label lb2 "email: gray@skynet.be"

struct geomStructure
(
node=#([0,0,0]),
links=#(#()),
baseVector=#([0,1,0]),
basePlaneNormal=#([0,0,1]),
uniqueLinks=#(),
alive=#{1},
fn count = return node.count,
fn addNode coord = ( append links #(); append baseVector [0,1,0]; append node coord; append alive node.count; return node.count ),
fn getPos idx = return node[idx],
fn setPos idx coord = node[idx]=coord,
fn getLink idx = return links[idx],
fn setLink idx idxOtherNode = ( if (idx<=node.count and idxOtherNode<=node.count) then (append links[idx] idxOtherNode; append links[idxOtherNode] idx; append uniqueLinks #(idx,idxOtherNode)) else false ),
fn getBaseVector idx = baseVector[idx],
fn setBaseVector idx v = baseVector[idx]=v,
fn getBasePlane idx = basePlaneNormal[idx],
fn setBasePlane idx v = basePlaneNormal[idx]=v,
fn addVector fromNode v p =
(
append baseVector -v
append basePlaneNormal p
append links #()
append node (node[fromNode]+v)
newNode=node.count
append alive newNode
append links[fromNode] newNode
append links[newNode] fromNode
append uniqueLinks #(fromNode,newNode)
return newNode
),
fn getUniqueLinksCount = return uniqueLinks.count,
fn getUniqueLinks idx = return uniqueLinks[idx],
fn isAlive idx = alive[idx],
fn killLife idx = alive[idx]=false
)

fn firstAlive structure =
(
numberNodes=structure.count()
count=0
for currentNode=1 to numberNodes do
(
count+=1
if structure.isAlive currentNode then exit
)
return count
)

fn existNodeInZone structure pos delta =
(
numberNodes=structure.count()
existAtPos=0
for currentNode=1 to numberNodes do
(
p=structure.getPos currentNode
if ((abs(pos.x-p.x))<delta)and((abs(pos.y-p.y))<delta)and((abs(pos.z-p.z))<delta) do (existAtPos=currentNode;exit)
)
existAtPos
)

fn randomVector2Dvariation theVector varLength varAngle lengthToConform =
(
var=lengthToConform*varLength
newLength=random (lengthToConform-var) (lengthToConform+var)
theVector*=(newLength/(length theVector))
theVector*=quat (random -(varAngle/2.0) (varAngle/2.0) ) [0,0,1]
)

fn growNode structure idx share =
(
rotShare=360.0/(share as float)
theBaseVector=structure.getBaseVector idx
thePlaneNormal=structure.getBasePlane idx
lengthToConform=length (structure.getBaseVector 1)
for shareIdx=1 to (share-1) do
(
theBaseVector*=quat rotShare thePlaneNormal
theRealVector=randomVector2Dvariation theBaseVector (varLength_osd.value/200.0) varAngle_osd.value lengthToConform
pos=(structure.getPos idx)+theRealVector
delta=(weldZone_osd.value/100.0)*(length theBaseVector)
otherNode=existNodeInZone structure pos delta
if otherNode!=0
then (
currentLinks=structure.getLink idx
if (findItem currentLinks otherNode)==0 do
(
structure.setLink idx otherNode
p=structure.getPos otherNode
structure.setPos otherNode ((pos+p)/2.0)
)
)
else structure.addVector idx theRealVector thePlaneNormal
)
structure.killLife idx
)

fn createGeom structure =
(
count=structure.getUniqueLinksCount()
obj=SplineShape pos:[0,0,0]
obj.steps=0
for idx=1 to count do
(
thisLink=structure.getUniqueLinks idx
splineIdx=addNewSpline obj
addknot obj splineIdx #corner #line ((structure.getPos thisLink[1])*nodeSize_osd.value)
addknot obj splineIdx #corner #line ((structure.getPos thisLink[2])*nodeSize_osd.value)
)
updateShape obj
return obj
)

on calculate_osd pressed do
(
clearListener()
myStructure=geomStructure()
myStructure.addVector 1 [0,1,0] [0,0,1]
securityCounter=0
while myStructure.getUniqueLinksCount()<(numberLinks_osd.value) do
(
securityCounter+=1
thisNode=firstAlive myStructure
growNode myStructure thisNode nodeLinks_osd.value
if securityCounter>numberLinks_osd.value*8 do ((messageBox("the weld value is too high\nprogram stopped") title:"honeycomb warning");exit)
)
obj=createGeom myStructure
)--on

on preset_osd selected idx do
(
case idx of
(
1: (
numberLinks_osd.value=323
nodeLinks_osd.value=3
varLength_osd.value=0.0
varAngle_osd.value=0.0
weldZone_osd.value=10.0
)
2: (
numberLinks_osd.value=400
nodeLinks_osd.value=3
varLength_osd.value=40.0
varAngle_osd.value=40.0
weldZone_osd.value=60.0
)
3: (
numberLinks_osd.value=250
nodeLinks_osd.value=3
varLength_osd.value=160.0
varAngle_osd.value=60.0
weldZone_osd.value=50.0
)
)
)--on

)--rollout
try (closerolloutfloater honeycombFloater)catch()
honeycombFloater = newRolloutFloater "honeycomb" 162 260
addRollout honeycombRollout honeycombFloater rolledUp:false
Note: all routines are not yet optimized.


As soon as I would have time, I will adapt this principle in volume.

prettyPixel
09-29-2005, 10:00 AM
Here is a screenshot

j-man
09-29-2005, 11:12 AM
very cool prettypixel very cool. Can't wait to see a 3D version!!!


rdg
09-29-2005, 12:21 PM
very cool indeed!

I am back from short vacation and will read the links.

Georg

hammerbchen
09-29-2005, 01:32 PM
To rdg and you all:
Here are the picture of my "sponge", actually its not a sponge, it is one kind of vegetable--melon like vegetable. We used to use that to wash our body in the old day in Taiwan. We dry the melon under the sun for many days, then the remain are the "bone" of the melon.
http://blog.yam.com/hammerbchen/archives/536577.html
Anyway, I am really enjoy this kind of modeling, and really happy to provide idea and discuss in this forum.

I also start another thread in cgtalk:
http://forums.cgsociety.org/showthread.php?t=270364
MasterBercon said the effect I want to creat was called "Implicit Surfaces". I think it is another direction to creat a sponge.

Thanks

prettyPixel
09-30-2005, 11:48 PM
Hi all

I modified the program so that it supports the 3D.
There are interesting results, but it is difficult to find the good angles to create regular 3d structures.
Somebody knows how to create geometrical structures ?
Which are the angles ? ...

hammerbchen: it does not make fibers yet as you wish, but I did not yet test all the possibilities that this method allows.

rollout honeycombRollout "honeycomb"
(
group "honeycomb"
(
dropdownlist structureType_osd "structure type:" items:#("planar: 3 (hexagonal)","planar: 4 (square)","semi-planar: 3","volume: 4 (tetraedric)","volume: 6 (cubic)") selection:1 height:6
spinner numberLinks_osd "number links: " range:[3,5000,323] type:#integer scale:1.0 fieldWidth:40
spinner nodeSize_osd "link size: " range:[1.0,10000.0,10.0] type:#float scale:1.0 fieldWidth:40
spinner varLength_osd "length var.: %" range:[0.0,250.0,0.0] type:#float scale:0.1 fieldWidth:40
spinner varAngle_osd "angle var.: deg" range:[0.0,360.0,0.0] type:#float scale:0.1 fieldWidth:40
spinner weldZone_osd "weld zone: %" range:[0.0001,75.0,60.0] type:#float scale:0.5 fieldWidth:40
button calculate_osd "create"
)
progressBar pBar value:0
group "presets"
(
dropdownlist preset_osd "" items:#("honeycomb","vegetable fibers (plane)","snowflake","vegetable fibers (volume)","damaged structure","vegetable sheets") selection:1 height:7
)
label lb1 "by Olivier Vandecasteele"
label lb2 "email: gray@skynet.be"

struct geomStructure
(
node=#([0,0,0]),
links=#(#()),
baseVector=#([0,1,0]),
basePlaneNormal=#([0,0,1]),
uniqueLinks=#(),
alive=#{1},
fn count = return node.count,
fn addNode coord = ( append links #(); append baseVector [0,1,0]; append node coord; append alive node.count; return node.count ),
fn getPos idx = return node[idx],
fn setPos idx coord = node[idx]=coord,
fn getLink idx = return links[idx],
fn setLink idx idxOtherNode = ( if (idx<=node.count and idxOtherNode<=node.count) then (append links[idx] idxOtherNode; append links[idxOtherNode] idx; append uniqueLinks #(idx,idxOtherNode)) else false ),
fn getBaseVector idx = baseVector[idx],
fn setBaseVector idx v = baseVector[idx]=v,
fn getBasePlane idx = basePlaneNormal[idx],
fn setBasePlane idx v = basePlaneNormal[idx]=v,
fn addVector fromNode v p =
(
append baseVector -v
append basePlaneNormal p
append links #()
append node (node[fromNode]+v)
newNode=node.count
append alive newNode
append links[fromNode] newNode
append links[newNode] fromNode
append uniqueLinks #(fromNode,newNode)
return newNode
),
fn getUniqueLinksCount = return uniqueLinks.count,
fn getUniqueLinks idx = return uniqueLinks[idx],
fn isAlive idx = alive[idx],
fn killLife idx = alive[idx]=false
)

fn firstAlive structure =
(
numberNodes=structure.count()
count=0
for currentNode=1 to numberNodes do
(
count+=1
if structure.isAlive currentNode then exit
)
return count
)

fn existNodeInZone structure pos delta =
(
numberNodes=structure.count()
existAtPos=0
for currentNode=1 to numberNodes do
(
p=structure.getPos currentNode
if ((abs(pos.x-p.x))<delta)and((abs(pos.y-p.y))<delta)and((abs(pos.z-p.z))<delta) do (existAtPos=currentNode;exit)
)
existAtPos
)

fn randomVector2Dvariation theVector varLength varAngle lengthToConform planeNormal =
(
var=lengthToConform*varLength
newLength=random (lengthToConform-var) (lengthToConform+var)
theVector*=(newLength/(length theVector))
theVector*=quat (random -(varAngle/2.0) (varAngle/2.0) ) planeNormal
)

fn randomVector3Dvariation theVector varLength varAngle lengthToConform planeNormal =
(
var=lengthToConform*varLength
newLength=random (lengthToConform-var) (lengthToConform+var)
theVector*=(newLength/(length theVector))
theVector*=quat (random -(varAngle/2.0) (varAngle/2.0) ) planeNormal
theVector*=quat (random -(varAngle/2.0) (varAngle/2.0) ) (cross theVector planeNormal)
)

fn rot3d v pn rot1 rot2 =
(
vbis=v*quat rot1 pn
rotAxis=cross vbis pn
v2=vbis*quat rot2 rotAxis
p2=cross rotAxis v2
#(v2,p2)
)

fn growNode structure idx str3D =
(
theBaseVector=structure.getBaseVector idx
thePlaneNormal=structure.getBasePlane idx
lengthToConform=length (structure.getBaseVector 1)
for currentStr=1 to (str3D.count-1) do
(
ret=rot3d theBaseVector thePlaneNormal (str3D[currentStr][1] as float) (str3D[currentStr][2] as float)
theNewVector=ret[1]; theNewPlaneNormal=ret[2]
if str3D[str3D.count]=="2D"
then theRealVector=randomVector2Dvariation theNewVector (varLength_osd.value/200.0) varAngle_osd.value lengthToConform theNewPlaneNormal
else theRealVector=randomVector3Dvariation theNewVector (varLength_osd.value/200.0) varAngle_osd.value lengthToConform theNewPlaneNormal
-- attention si le vecteur change il est normal que le plan soit également modifié
pos=(structure.getPos idx)+theRealVector
delta=(weldZone_osd.value/100.0)*(length theBaseVector)
otherNode=existNodeInZone structure pos delta
if otherNode!=0
then (
currentLinks=structure.getLink idx
if (findItem currentLinks otherNode)==0 do
(
structure.setLink idx otherNode
p=structure.getPos otherNode
structure.setPos otherNode ((pos+p)/2.0)
)
)
else structure.addVector idx theRealVector theNewPlaneNormal
)
structure.killLife idx
)

fn createGeom structure =
(
count=structure.getUniqueLinksCount()
obj=SplineShape pos:[0,0,0]
obj.steps=0
for idx=1 to count do
(
thisLink=structure.getUniqueLinks idx
splineIdx=addNewSpline obj
addknot obj splineIdx #corner #line ((structure.getPos thisLink[1])*nodeSize_osd.value)
addknot obj splineIdx #corner #line ((structure.getPos thisLink[2])*nodeSize_osd.value)
)
updateShape obj
return obj
)

fn getStructure n =
(
case n of
(
1:#(#(120,0),#(-120,0),"2D")
2:#(#(90,0),#(180,0),#(-90,0),"2D")
3:#(#(120,0),#(-120,0),"3D")
4:#(#(0,-109.5),#(112.2,28.13),#(-112.2,28.13),"3D")
5:#(#(90,0),#(-90,0),#(180,0),#(0,90),#(0,-90),"3D")
)
)

on calculate_osd pressed do
(
clearListener()
myStructure=geomStructure()
myStructure.addVector 1 [0,1,0] [0,0,1]
securityCounter=0
actualLinks=myStructure.getUniqueLinksCount()
maxLinks=numberLinks_osd.value
while actualLinks<maxLinks do
(
securityCounter+=1
thisNode=firstAlive myStructure
growNode myStructure thisNode (getStructure structureType_osd.selection)
actualLinks=myStructure.getUniqueLinksCount()
pBar.value=((actualLinks as float / maxLinks as float)*100.0)as integer
if securityCounter>maxLinks*8 do ((messageBox("the weld value is too high\nprogram stopped") title:"honeycomb warning");exit)
)
pBar.value=0
obj=createGeom myStructure
)--on

on preset_osd selected idx do
(
case idx of
(
1: (
structureType_osd.selection=1
numberLinks_osd.value=900
varLength_osd.value=0.0
varAngle_osd.value=0.0
weldZone_osd.value=60.0
)
2: (
structureType_osd.selection=1
numberLinks_osd.value=900
varLength_osd.value=40.0
varAngle_osd.value=40.0
weldZone_osd.value=60.0
)
3: (
structureType_osd.selection=4
numberLinks_osd.value=200
varLength_osd.value=0.0
varAngle_osd.value=0.0
weldZone_osd.value=60.0
)
4: (
structureType_osd.selection=4
numberLinks_osd.value=900
varLength_osd.value=30.0
varAngle_osd.value=30.0
weldZone_osd.value=60.0
)
5: (
structureType_osd.selection=5
numberLinks_osd.value=900
varLength_osd.value=8.0
varAngle_osd.value=12.0
weldZone_osd.value=60.0
)
6: (
structureType_osd.selection=3
numberLinks_osd.value=2500
varLength_osd.value=15.0
varAngle_osd.value=25.0
weldZone_osd.value=50.0
)
)
)--on

)--rollout
try (closerolloutfloater honeycombFloater)catch()
honeycombFloater = newRolloutFloater "honeycomb" 162 300
addRollout honeycombRollout honeycombFloater rolledUp:false

stuh505
10-01-2005, 12:52 AM
This is really cool, good work :)

If you are looking for more cool things to do with it, you could allow the user to use maps to control the variables over the region of space...so that they could create predictable randomness...

hammerbchen
10-01-2005, 01:59 AM
Very Nice!:thumbsup:
How about adding an option: set target object, so we can create a fiberous teapot!

hammerbchen
10-01-2005, 03:20 PM
Ok, I post my fibrous teapot. Created by Boolean method.
I am thinking this is not a good approach to do this kind of task, because it was too inefficient.
http://blog.yam.com/hammerbchen/archives/cat_81535.html

prettyPixel
10-04-2005, 01:29 AM
It's time to download the last version of the script ;)
There are some improvements.
I added the gravity. There are structures to make plants.
All parameters are not yet accessible via the interface but you can edit the INI file (and you can add yours vectors)

EDIT: script removed : you will find further the new version of the script.

hammerbchen
10-04-2005, 03:55 AM
:thumbsup: you are really really really good!
After seeing your trees pictures, because I am a neuroscience doctor studient, may I ask you if you can modify your script so we can create a neuronal cell or neuron networks.

Here's some reference picture on the net:
http://www.dpo.uab.edu/~jgemmill/Visualizing_Neurons/3D_Camera_Lucida/3d_camera_lucida.html
http://www.mind.ilstu.edu/curriculum2/neuro/neuron_1.html
http://parasol.tamu.edu/groups/amatogroup/research/NeuronPRM/

a neuronal cell contain: cell body, axon(input line) and dendrite(output line)
a neuron network: are cells connecting each other, however there is a gap between axon and dendrite connetion.

prettyPixel
10-04-2005, 11:45 AM
All your suggessions are interesting.
To conform the structure to a surface too.
My next goal is to be able to choose between various variations in structure in each node.
That should make it possible to create neuronal networks. To carry out all that, some additional variables should be added.
The main problem to which I am confronted is that the more the grown structure the more it becomes slow. To avoid that, divide the space will be needed. (to create a volume around the links too)

rdg
10-04-2005, 11:53 AM
:bowdown:
I feel small.

j-man
10-04-2005, 02:05 PM
Hey Pretty pixel,

I'm impressed, the results are excellent! I can't wait until you get your interface going a bit more so don't stop now

Cheers,


prettyPixel
10-07-2005, 02:29 AM
Hi

I improved the interface of the script.
Now you can edit all parameters from the interface.
Moreover you can also save your own adjustements.

well There are not other modifications of the possiblities for the moment...
Maybe you will find other forms ?

EDIT: script removed : you will find further the new version of the script.

prettyPixel
10-08-2005, 02:42 PM
optimized speed...

EDIT:
For the fun: the datas of the dodecahedron. (Add this text in the ini file)

[dodecaedron]
numberLinks=30
numberGenerations=6
numberMode=3
linkSize=117.557
is3D=false
rotAngle=#([-72,0,0], [54,-58.2825,-31.7175])
varAngle=[0,0,0]
length=#(1.0, 1.0)
varLength=0.0
startPoint=[-1,0,0]
startVector=[1,0,0]
startPlaneNormal=[0,0,1]
growDirect=true
biPolar=false
constantLength=true
weldZone=10.0
gravity=0.0

Blue
10-08-2005, 10:12 PM
This thread looked like so much fun I decided to give it a shot.

I've been toying with filling an objects volume with a network of geo. I've found this to be very demanding on memory and cpu. I've attached a few pics of a torus knot used as the source volume, the first pic is a spline volume network, the second pic is ball and bone type network similar to the lattice mod result, and the last is a more complex mesh fiberous result. The last is still in the design stage to get better results but its getting there. I generate connections to other sample points within a tolerance range and there is a chance to not make the connection so that there is some randomness to the structure. I'm not quite done yet, still have some bugs to work out and if more than about 1000 sample points are used I crash because I'm out of memory :) I'm working on that too.

The attached images only use 500 sample points, so there is some breakage in the volume meshes. I would do more points but my laptop is not the work horse that my office machine is.

rdg
10-09-2005, 02:21 PM
great you joined in, Thomas.

How do you define the volume?

Georg

prettyPixel
10-09-2005, 03:15 PM
Hi Thomas Hi rdg
It is very interesting. I already thought of transforming the vectors into geometry.
Currently in the function ' fn createGeom structure' I transform all the links into splines.
For that I use the array: structure.getUniqueLinks n
It is an array only creates to facilitate the transformation of the links in splines.

There is another way to read the datas in my program...
For each node, we can know the other nodes which are attached to him:

otherNodes=structure.getLink theNodeIndice -- return an array of nodes indices

and you can know the position of a node with this method:
thisPosition=structure.getPos theNodeIndice

So For each node you can know the various links. Thereafter I would like to use this method to create the geometry of the nodes. The problem to be solved is to create a geometry with a number of unspecified links.

It seems that your third method makes something which approaches that ? Isn't ?

Blue
10-09-2005, 05:01 PM
How do you define the volume?
Any geo will work. Parametric primative or collapsed mesh.

So For each node you can know the various links. Thereafter I would like to use this method to create the geometry of the nodes. The problem to be solved is to create a geometry with a number of unspecified links.

It seems that your third method makes something which approaches that ? Isn't ?
The volume result is a single spline shape, huge number of segments, adding a sweep mod to it and using the intesection option to bool the generated geo at the places where the sweep meet. Then a meshsmooth and a relax, but this is not quite the final result I really want this is more of a stand in till I come up with something more proper.

rdg
10-10-2005, 10:01 AM
maybe of interest:
the use of particleflow to generate splines:

http://forums.cgsociety.org/showthread.php?p=2720990#post2720990

http://www.charleycarlat.com/
http://core2core.de/spielwiese/PFSplines/PFSplines1.htm
[German version]

Georg

hammerbchen
10-10-2005, 11:26 AM
Hi rdg:
Very thanks for the links, especially the german PFSPline1.htm.
Everytime I link to the alias Maya page, I always wonder how they model the trees/fibers face of woman (http://www.alias.com/glb/eng/products-services/family_details.jsp?familyId=3900009). Now the link gave me some clue.

Also thank you all other trying the sponge script (or other name you like). I only know the very very basic of maxscript, but seeing all your works really cool and fun.:)

maybe of interest:
the use of particleflow to generate splines:

http://forums.cgsociety.org/showthread.php?p=2720990#post2720990

http://www.charleycarlat.com/
http://core2core.de/spielwiese/PFSplines/PFSplines1.htm
[German version]

Georg

rdg
10-10-2005, 12:20 PM
Now the link gave me some clue.
http://forums.cgsociety.org/showthread.php?t=278451
It's Meats Meier without plugins :)


Georg

prettyPixel
10-10-2005, 12:46 PM
Wow ! The particles give impressive results.
thanks for the links rdg :thumbsup:
The method seems more effective to create fibrous objects.

Nevertheless I hope to also create a real geometry before being interested in the particles because I would like to also generate structures regular... like dodecaedron , honeycomb, trees...

Do you believe that it is possible to generate regular structures with particles?

rdg
10-12-2005, 12:28 PM
http://forums.cgsociety.org/showpost.php?p=2731014&postcount=2663

this the MRsolidVolume Shader for MAX.

Look Ma' - no geometry.

Georg

nebille
10-12-2005, 01:17 PM
This may or may not help theoretically but to create a sponge or write a programme that creates sponges you will first need to examine what local interactions effect the growth of a sponge in nature be it water forces or chemicals. However i can bet you any money that the forces are random so if you set a class called agent and this agent has co-ordinates that move at random and when they reach a paticular node object they stick to it and create some form of geometry you would be creating a programme that allows the script to grow the sponge and a different sponge each time. This is called emergent or agent based programming. you could even script in a little intelligence to your agent class to allow it them to interact with each other. Do some research into agent based design or swarm modelling. This could give you an interesting result.

Remember the key to the above is simple programme rules = complex outcome

hmmm, hope you are not confused

regards

Nebille

Blue
10-12-2005, 03:14 PM
Thanks Nebille, I've got another idea on how to attack this problem, now to find the free time to explore it.

Hey Georg, don't take the fun out of this exercise with a shader solution :), thanks for the info though.

rdg
10-13-2005, 07:41 AM
Thomas,
finding a 3d procedural shader that creates neural-networks wouldn't be less fun ?

But I still at the scripting approach, too.

Maybe something that fills the volume with point that have attributes.
In a second stage geometry for fibers, cells and connections could be linked/attached to the points.
? How to merge the connections without boolean? Blobmesh?

Currently I can only brain storm, ...

Georg

rdg
10-13-2005, 10:07 AM
here is something differnt with the blobmesh approach:

(

struct Neuron (
theBlobMesh,
theMainNode,
theTendrils,
fn calcSpherePoint theRadius = (
r=theRadius
tetha=(random 0 180)
phi=(random 0 360)
x=r*(sin tetha)*(cos phi)
y=r*(sin tetha)*(sin phi)
z=r*cos tetha
[x, y, z]
),
fn addTendril =(
startRadius=theMainNode.radius
print startRadius
maxRadius= random 1. 4.
startPoint=(calcSpherePoint startRadius)
-- not really working tendril mechanism
theTendril = SplineShape pos:(startPoint)
addNewSpline theTendril
addKnot theTendril 1 #corner #line startPoint
secondPoint=(-(theBlobMesh.pos-startPoint)*maxRadius)
addKnot theTendril 1 #corner #line secondPoint
updateShape theTendril
append theTendrils theTendril
-- blobbing
theLength=distance startPoint secondPoint
blobCount=theLength/25
for i=1 to blobCount do(
sBlob=SDeflector pos:(secondPoint/blobCount*i) radius:(75-(50/blobCount*i))
-- add the blobs:
theBlobMesh.addBlob sBlob
)
),
fn init = (
-- generic setup
-- a mainNode and the Blob mesh
theBlobMesh=BlobMesh()
theMainNode=SDeflector()
theMainNode.radius=random 80 150
theBlobMesh.addBlob theMainNode
theTendrils=#()
for i=1 to 3 do (
addTendril();
)
),

start=init();
)

fn mkNeuron = (
theNeuron=Neuron()
theNeuron
)
myNeuron=mkNeuron();
)

It needs the updated BlobMesh-Object that Wahooney gave us:
http://www.wahooney.net/

There a a few things I could not solve for now:

I try to calculate a point on the spherical surface of the deflector, but the Point doesn't sit on the surface ... surely some stupid thing.

I the tendril function should take care of some minimum distance between the tendrils.

the blob should be placed with exponential (?) spaceing, not linear - as longer tendril tend to frikkle.

And the master challange:
a algorythm that rotates multiple neurons so their tendrils do not cross ...

Georg

hammerbchen
10-17-2005, 09:05 AM
Hi
I don't know if this will help, but I post it anyway.

During embryonic develop, our brain generate a bunch of neurons, those cells may not have connection between each other. However, later on, cells without interaction will die while cells have interaction (connection) survive.

So can you just randomly generate many many neurons, then delete those are not connect to each other? Or that doesn't make any sense to do it in script writing?

nebille
10-17-2005, 12:37 PM
It seems this thread is going along the path of neural networks, I can recomend some reading material about them which explains the dynamics of the reality and paralels within programes to create a sponge although i think the neural network may complicate things while creating a sponge because. But give it a go. Mean while i may create an agent based sponge script if i have time.

regards

nebille

prettyPixel
10-20-2005, 12:48 PM
Here is a attempt to transform the links into geometry.
There is still a problem which I am trying to solve... (in fact the links are .. unlinked lol)

http://users.skynet.be/arketip/CGtalk/renderVolumeDEMO.jpg

hammerbchen
11-07-2005, 02:22 AM
It is not like neuron, but very organic!
I just can't wait to try your script and play around, sorry.

prettyPixel
11-07-2005, 05:14 PM
OK I am going to look at what it is necessary to finish.
Currently the code is "open".

hammerbchen
11-11-2005, 01:25 AM
Hi you all:

I found this webpage might be useful for neuron modeling or sponge growth.
http://www.biologie.uni-hamburg.de/b-online/virtuallaboratory/Animations.html

wish this help^_^

(search keyword: pruning and Prusinkiewicz)

stuh505
11-11-2005, 02:18 AM
Hi you all:

I found this webpage might be useful for neuron modeling or sponge growth.
http://www.biologie.uni-hamburg.de/b-online/virtuallaboratory/Animations.html

wish this help^_^

(search keyword: pruning and Prusinkiewicz)

Hehe, funny you should mention this. Prusinkiewicz has gotten some great looking results, but his models aren't based on science. I've been working on some much more biologically accurate models...and I'm doing my research in Max, which means that there will be a plugin coming out sometime :D

hammerbchen
11-11-2005, 04:46 AM
Oh that would be nice!
What do you mean biological accurate? You can model neurite outgrowth accroding to their enviroment and synapse transmisstion strength?

stuh505
11-11-2005, 06:01 AM
Synapses, no...that was last summer!

I cannot simply describe the ways in which trees grow, it is very complicated, and it is also largely a mystery to science...but I can incorporate the most modern theories and evidence, as well as many detailed observations...my father has written books on the subject

prettyPixel
11-13-2005, 05:54 PM
Hi all.

Hammer b chen: I finally removed the some bug which prevented me to give you before my script.
This version does work but the function to create real geometry is not terminated.
The nodes are not connected. It is visible closely.
But you can already play with it.

http://users.skynet.be/arketip/CGtalk/dodecaedron.jpg

I advice not to create geometry with more than 200 links at the start because the geometry creation is slow. (and especially the attachement)

wip version:
http://users.skynet.be/arketip/CGtalk/honeyComb.zip

Tunac
11-13-2005, 06:55 PM
if you want that script to work in max 8 replace the line:


local chamferResult=polyOp.chamferVerts obj vertsFlag chamferValue
by
local chamferResult=obj.editablePoly.chamferVertices chamferValue

great script :)

prettyPixel
11-13-2005, 07:11 PM
Thanks Tunac :thumbsup:
I have just updated the zip file.

Do we have to replace all "polyOp.xxx obj" by "obj.editablePoly.xxx" for max 8 ?

CGTalk Moderation
11-13-2005, 07:11 PM
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.