Yeah im using particles to generate the positions and then it is deleted asap.
I’ll post the code for the particle position generating to see what results you get.
For testing purposes I’ve been testing on 4 objects and 400 particles.
The new one will be posted tomorrow morning first thing. Then I’d love if everyone could play around with it and see if we could figure out ways of improving the processing speed.
Maybe down the road I’ll make it a modifier so it will be easier to tweak.
Use scene creation from my last code. There you have 10 torus obj. , 2 bended cylinders and extruded text with your name. Non of the pivots of this objects are inside volume.
Tell me are you create PF for each object?
Processing took 0.08 seconds
fn fnPFPoints surfObjs = (
posPtsArr = #()
if surfObjs.count >= 1 do
(
pfSys = PF_Source name:"Cobweb" X_Coord:0 Y_Coord:0 Emitter_Length:10 Emitter_Width:10 Quantity_Viewport:100 Show_Logo:off Show_Emitter:off wirecolor:orange
particleFlow.BeginEdit()
op1 = Birth name:"Cobweb_Birth" amount:200 Emit_Stop:0 Emit_Start:0
op2 = Position_Object Lock_On_Emitter:on Emitter_Objects:surfObjs
op3 = RenderParticles()
op4 = DisplayParticles name:"_display" color:pfSys.wireColor
ev1 = Event name:"Cobweb_Ends"
ev1.SetPViewLocation (pfSys.X_Coord) (pfSys.Y_Coord+100)
particleFlow.EndEdit()
ev1.AppendAction op1
ev1.AppendAction op2
ev1.AppendAction op4
pfSys.AppendAction op3
pfSys.AppendInitialActionList ev1
forceCompleteRedraw()
--Collect the point 3 positions of all particles
count = pfSys.NumParticles()
posPtsArr = for i = 1 to count collect
(
pfSys.particleIndex = i
pfSys.particlePosition
)
particleFlow.BeginEdit()
particleFlow.delete pfSys
particleFlow.EndEdit()
)
return posPtsArr
)
arr = #()
for i = 1 to 10 do (
append arr (obj = Torus smooth:2 segs:24 sides:12 radius1:10 radius2:5 wirecolor:blue pos:[0,i*30,0])
)
start = timeStamp()
generatedPos = fnPFPoints arr
end = timeStamp()
clearlistener()
format "Processing took % seconds
" ((end - start) / 1000.0)
format "%" generatedPos
This is my test:
I use PF birth amount 300
fn fnPFPoints surfObjs = (
posPtsArr = #()
if surfObjs.count >= 1 do
(
pfSys = PF_Source name:"Cobweb" X_Coord:0 Y_Coord:0 Emitter_Length:10 Emitter_Width:10 Quantity_Viewport:100 Show_Logo:off Show_Emitter:off wirecolor:orange
particleFlow.BeginEdit()
op1 = Birth name:"Cobweb_Birth" amount:300 Emit_Stop:0 Emit_Start:0
op2 = Position_Object Lock_On_Emitter:on Emitter_Objects:surfObjs
op3 = RenderParticles()
op4 = DisplayParticles name:"_display" color:pfSys.wireColor
ev1 = Event name:"Cobweb_Ends"
ev1.SetPViewLocation (pfSys.X_Coord) (pfSys.Y_Coord+100)
particleFlow.EndEdit()
ev1.AppendAction op1
ev1.AppendAction op2
ev1.AppendAction op4
pfSys.AppendAction op3
pfSys.AppendInitialActionList ev1
forceCompleteRedraw()
--Collect the point 3 positions of all particles
count = pfSys.NumParticles()
posPtsArr = for i = 1 to count collect
(
pfSys.particleIndex = i
pfSys.particlePosition
)
particleFlow.BeginEdit()
particleFlow.delete pfSys
particleFlow.EndEdit()
)
return posPtsArr
)
arr = #()
delete objects
clearlistener()
-- create scenr (every object in the scene will have center outside volume)
obj1=text size:100 kerning:0 leading:0 pos:[0,0,0] text:"Jocker
Martini" wirecolor:blue
addModifier obj1 (extrude amount:30)
for c in 1 to 2 do
(
obj2=Cylinder smooth:on heightsegs:10 height:360 radius:20 wirecolor:blue
addModifier obj2 (Bend BendAngle:180 BendDir:90)
obj2.pivot = obj2.center ; z = obj2.pos.z
if mod c 2 != 0 then obj2.pos = [-230,0,z] else obj2.pos = [230,0,z]
)
posTArr = #([-156.646,140,0], [-78.3232,140,0], [-5.72205e-006,140,0], [78.3232,140,0], [156.646,140,0], [156.646,-140,0], [78.3232,-140,0], [-5.72205e-006,-140,0], [-78.3232,-140,0], [-156.646,-140,0])
for t in 1 to 10 do (Torus smooth:2 segs:24 sides:12 radius1:20 radius2:10 wirecolor:blue pos:posTArr[t])
arr = objects as array
t1 = timestamp() ; m1 = heapfree
generatedPos = fnPFPoints arr
clearlistener()
format "time:% memory:%
" (timestamp() - t1) (m1 - heapfree)
format "%" generatedPos
time:101 memory:28400L
But your method generate 300 random position (total)
My produce 300 for each object. If i reduce pos count i will get fester solution for sure:p
Thet is difference. Am I right?
Are Bobo suggested this method?
This seems quite fast to me. Not sure if you’ll get much better results from anything else. Maybe, but you’d want to turbosmooth these objects or get some higher res geo in there to be sure of the speed and memory usage.
This method makes 300 points in total. Not for each object individually.
Bobo suggested a different method. I’ll get a rest together and show ya what he said. But for now the pf seemed to work ok…
What code are you using to get time and memory. So i can try
300 particles aNd compare our results.
This is the code for time and memory calculations
t1 = timestamp() ; m1 = heapfree
generatedPos = fnPFPoints arr -- your FN
format "time:% memory:%
" (timestamp() - t1) (m1 - heapfree)
My code shoot 300 rays for each obj but these 300 rays are spread in space if pivot are outside of volume. Some of them interset geometry surface. You can collect intersect pos and choose how much you need (1-1000000). Maybe is better use selections center instead of obj center. That will be fester solution.
So the code you built does 300 per object. The particle one I built only does 300 as a total for all objects passed through it.
But you don’t need always pass trough object (for outside web).Set 2 options for the web:
inside(your method is better) and outside(my method). Just think about it.
This is what he suggested.
Not sure how ill do this yet or if it would be faster…what are you guys thoughts. I guess we could make this and then test to see its speed.
For surface, you could just go through every face of the mesh, measure its area and generate a respective number of points by producing random barycentric coordinates.
I’m using his code he posted at one point to generate random points using barycentric coords.
I haven’t tested the new particle method, but that seems like it should be fast enough? If you have a highres mesh, doing the bary method might get to be too slow.