2
$\begingroup$

Being a beginner in Blender, I'm stuck with a basic (maybe for experts) problem. Please help me out.

Suppose a bunch of uv spheres is placed at equal distance on a plane (or grid). The animation will be such that the plane will oscillate with a sine wave, and those spheres will also be scaled along the z direction according to the wavy nature of the oscillating plane. As the spheres are placed at different positions of the plane and so at different phase of the wave, the scaling will be according to the current phase of the wave.

Please help.

$\endgroup$
6
  • $\begingroup$ This is very much a Geometry Nodes thing. I notice you tagged your post “Blender internal render engine.” Are you actually using Blender 2.79, or Blender 3? $\endgroup$
    – TheLabCat
    Apr 8, 2022 at 4:09
  • $\begingroup$ I am using Blender 2.92 $\endgroup$ Apr 8, 2022 at 5:08
  • $\begingroup$ I would very much recommend upgrading from that, since blender 2.92 doesn’t have any features that Blender 3+ hasn’t AFAIK. $\endgroup$
    – TheLabCat
    Apr 8, 2022 at 14:52
  • $\begingroup$ Hi, I edited your tags to be more relevant to your question. It's OK to add others in if you think they're relevant. $\endgroup$ Apr 8, 2022 at 15:28
  • $\begingroup$ It's not a basic problem. I can think of a couple of ways to solve it and they both require advanced knowledge. You might construct the entire thing with geometry nodes, if you upgrade to 3.1 as @TheLabCat has suggested; or you might be able to do it with drivers. I'll see if I can work out a driver solution. $\endgroup$ Apr 8, 2022 at 15:32

1 Answer 1

3
$\begingroup$

Control by driver

Run the script and you can get entire scene

import bpy

# select and del all object
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action = "SELECT")
bpy.ops.object.delete(use_global=True, confirm=False)

# add 20 sphere and set driver
x = 0 # use for distance offset
for r in range(20):
    bpy.ops.mesh.primitive_uv_sphere_add(radius=0.1, enter_editmode=False, align='WORLD', location=(x, 0, 0), scale=(1, 1, 1))
    bpy.ops.object.shade_smooth()

    oj = bpy.context.object

    # add driver
    dr = oj.driver_add("location")
    dr[2].driver.expression = f"sin({x}+frame*0.05)"

    drs = oj.driver_add("scale")
    max_scale = 1
    min_scale = 0.5

    for dr in drs:
        dr.driver.expression = f"{(min_scale-max_scale)/2}*(sin({x}+frame*0.05))+{(min_scale+max_scale)/2}"

    x += 0.3

enter image description here

How to get the scale function?

$$ Let f(n) = An + B \\ \left\{\begin{align*} &f(1)=A+B=min\\ &f(-1) = -A+B=max\; \end{align*}\right.\\ f(n) = \frac{min-max}2n+\frac{min+max}2 $$

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .