SP Waves
-
Wow!
-
Have tested the wave model. It works really great. Even the extension of the water surface is very easy to implement by copying the triangular faces. It would be cool, if the triggering of the waves would also work in contact with falling objects. But have no idea of Rubi-programming ... Unfortunately, storing and outputting the animation with Replay does not work. Terminates after 17 frames. Would love to do an animation test with water reflection and waves with the Twilight renderer.
-
SP Animation doesn't record the movement of vertices. It only records transformation of the groups or components.
Here is another version that responds to touching objects. Use key B to fire a shell.
-
Wow! How did you make this thing
-
Time consuming but funny. Thanks Anton! Have used an old script of C. Phillips to export SKP-files of every frame and rendered each single file in Twilight. (http://sketchucation.com/forums/viewtopic.php?f=61%26amp;t=32965%26amp;p=292060%26amp;hilit=export+script#p292595)
Does anyone know a batch processing method to render many SKP-files with Twilight? It would save much time.
-
Hey faust07! These are some nice rendering result. One thing I could change is increase wave travel distance for more realistic effect and add water splash effect, but I see no point as I'm aware there are some existing realistic liquid simulators in action.
I actually never thought of exporting animation using the write_image technique. It is kind of straight forward actually. As you mentioned, it's slow and all the planning has to be made ahead, such as pressing controls at the right time or switching cameras. The good side of it is that it can be exported at the desired resolution. I generally use screen recorders when I want to export my animation, just like I did with the gif image in the first post.
One thing one could do is make the animation recording tool more advanced. Make it record color changes, recreate emitters, move vertices like in water plane, change styles, change camera properties, and other things. One potential downside of it is the performance.
Another way of recording animation is to log all SketchUp API functions and their calling time that were called during simulation and call them again while the animation is recreating. I don't know if it will work or if logging is even possible, but thats just an idea that could actually be less performance consuming than finding and recording all the geometry and view changes.
-
This is a script to export every frame directly within the run of a SketchyPhysics simulation. So emitters or Antons water waves can be exported correct (without a screen recorder). Put the code into the scripted feeld of one object (group) in the model. The simulation should be tested before, the export slows it dramatic down. The directory for the image files must be created before too. Instead of "d:/SPh_Temp/" You can create a directory of your choise. In the script, the directory and the image parameters can be changed.
Sorry, do not know how to post code correctly. The middle two lines should be one in the script:ontick{
Sketchup.active_model.active_view.write_image("d:/SPh_Temp/frame_%06d.jpg" % frame,1920,1080,true,0.8)
}Run the simulation and you should find every frame as jpg file in the directory.
example Video:
http://youtu.be/uzp5MvY4QQI -
increase wave travel distance and reflection on objects would be great...
-
Hi Anton. Here's a quick question, I have reduced the water surface to an almost realistic size. The bowl is about 1 m in diameter. How can I change amplitude, wavelength and speed of the waves so that it fits again. Thanks in advance!
Yet another problem: "drops" of about 2.5 cm in diameter do not work in the normal setting worldscale 9.0 as an emitter. Here I have to reduce the worldscale to 7.0. Is this normal?
-
Hi, Anton. A small request: Is there a way to change your script so that other non grouped entities (lines, curves, faces) in the model are not influenced? One possibility might be to put the geometry of the wave surface on a specific layer and to drive only these. When attempting camera paths (curves, polylines) to use in the wave model, these are extremely manipulated and broken after the start. Thanks in advance!
-
Hello fause07,
Nice animation there.
Tweaking wave parameters is possible and easy. Here is what the
add_radial_wave
function looks like:
` # Create wave.@param [Geom::Point3d] origin Wave position in global space.
@param [Numeric] wavelength Wavelength in inches.
@param [Numeric] amplitude Initial wave height.
@param [Numeric] num_waves Number of waves to create.
@param [Numeric] max_radius Maximum wave travel distance in inches.
@param [Numeric] speed Speed in inches per second.
def add_radial_wave(origin, wavelength, amplitude, num_waves = 5, max_radius = 100, speed = 1)
...
end`
To change wave properties, unhide and select the touch plane, open SP UI, and in the "scripted" field you should see this piece of code:onTouch { |toucher, speed, pos| wave = getVar('wave') wave.add_radial_wave(pos, speed*0.4, speed*0.6, 2, speed*10, 10) }
Tweak the parameters of the
add_radial_wave
until the waves are fit for your surrounding.
Bodies with a very small mass are considered static. Changing world scale is normal. Perhaps world scale feature was added exactly for that purpose.
And it is possible to have only particular geometry be considered as waves. I tweaked the code to have all the geometry within the "SP Wave" layer be considered as waves. Geometry in other layers will not be affected. Select red cube and replace its code with this one:
class Wave # @param [Sketchup;;Group] grp Wave plane. def initialize @edges = Sketchup.active_model.entities.grep(Sketchup;;Edge) @edges.uniq! @vertices = [] wave_layer = Sketchup.active_model.layers["SP Wave"] @edges.each { |e| next if e.layer != wave_layer @vertices.concat e.vertices } @vertices.uniq! @waves = [] @ents = Array.new(@vertices.size) @vectors = Array.new(@vertices.size) end # Create wave. # @param [Geom;;Point3d] origin Wave position in global space. # @param [Numeric] wavelength Wavelength in inches. # @param [Numeric] amplitude Initial wave height. # @param [Numeric] num_waves Number of waves to create. # @param [Numeric] max_radius Maximum wave travel distance in inches. # @param [Numeric] speed Speed in inches per second. def add_radial_wave(origin, wavelength, amplitude, num_waves = 5, max_radius = 100, speed = 1) @waves << { ;origin => Geom;;Point3d.new(origin.to_a), ;wavelength => wavelength.to_f, ;amplitude => amplitude.to_f, ;num_waves => num_waves.to_f, ;max_radius => max_radius.to_f, ;speed => speed.to_f, ;dist => 0, ;life => Math;;PI*2*wavelength.to_f*num_waves.to_f } end # Update all waves. def update count = 0 @waves.delete_if { |w| w[;dist] += w[;speed] (w[;dist] - w[;max_radius]) > w[;life] } for i in 0...@vertices.size pt = @vertices[i].position z = -pt.z @waves.each { |w| cur_dist = Math.sqrt((pt.x - w[;origin].x)**2 + (pt.y - w[;origin].y)**2) next if cur_dist > w[;dist] || cur_dist > w[;max_radius] || (w[;dist]-cur_dist) > w[;life] z -= w[;amplitude] * Math.sin((w[;dist]-cur_dist)/w[;wavelength]) * (w[;max_radius]-cur_dist) / w[;max_radius] * (w[;life] + cur_dist - w[;dist]) / w[;life] } next if z.zero? @ents[count] = @vertices[i] @vectors[count] = Geom;;Vector3d.new(0, 0, z) count += 1 end Sketchup.active_model.entities.transform_by_vectors(@ents[0,count], @vectors[0,count]) #@edges.each { |e| # e.soft = true unless e.soft? # e.smooth = true unless e.smooth? #} end # Reset water height. def reset vectors = Array.new(@vertices.size) for i in 0...@vertices.size vectors[i] = Geom;;Vector3d.new(0, 0, -@vertices[i].position.z) end Sketchup.active_model.entities.transform_by_vectors(@vertices, vectors) end end # class Wave onStart { Sketchup.break_edges = false @wave = Wave.new @plane = [Geom;;Point3d.new(0,0,0), Geom;;Vector3d.new(0,0,1)] setVar('wave', @wave) } onUpdate { if key('v') == 1 && frame % 2 == 0 x,y = sp_tool_instance.cursorPos line = Sketchup.active_model.active_view.pickray(x,y) pt = Geom.intersect_line_plane(line, @plane) @wave.add_radial_wave(pt, 4+rand(10), 5+rand(10), 2, 200, 10) if pt end @wave.update } onEnd { Sketchup.break_edges = true @wave.reset }
Then create a new layer with a name "SP Wave" and place all the wave geometry in it.
-
Many thanks for the quick response! Meanwhile I had already found the small screws to adjust the parameters. The problem of the influence of other free geometry during physics simulation remains. Here the intermediate state of my Easter physics experimental scene:
-
@faust07 said:
The problem of the influence of other free geometry during physics simulation remains.
Did you replace the code in red box with the new code provided in my prior post? -
Your new script runs great! Haven't seen your full post this morning. Don't know why. Thank you so much! Now I can implement camera paths or walking lines for moving objects without conflicts.
-
Here some later happy Easter greetings to the friends of SketchyPhysics. Have a little too much tested and tasted the "Easter water"... Also a thank you to Anton for the important improvements to the plugin. One can already produce a lot of funny things with it without too much bugsplats. The video is a salute to my 2 week old granddaughter Matilda.
-
Nicely done faust. You have a talent
Advertisement