Python generated attractors

Hey there!

I use the following code to generate attractors and I want to do some very simple animation and deformation of these shapes:

import Blender
from Blender import NMesh
import math

me = NMesh.GetRaw()

STARTING LOCATION

px = 0.1
py = 0.0
pz = 0.0

SEED

a = -1.4
b = 1.6
c = 1.0
d = 0.7

LOOP itr TIMES

itr=0
while itr<200000:
newpx = math.sin(a * py) + c * math.cos(a * px)
newpy = math.sin(b * pz) + d * math.cos(b * py)
newpz = math.sin(c * px) + a * math.cos(c * pz)
px = newpx
py = newpy
pz = newpz
v = NMesh.Vert(px, py, pz)
me.verts.append(v)
itr += 1

ca = NMesh.PutRaw(me)

Changing the values of a,b,c,d produces another shape.
The things I would like to do are the following:

  • Change the values of variables a,b,c,d on every frame,
  • Animate simple deform modifer (for example twist)
  • Create a morph between 2 different attractors

I’m completely new to blender and I have tried several different ways like shape keys but nothing really worked.
I would appreciate any help.

Thanks

I would look into script links. There’s some intro posts around on this forum (if you search) about getting started with them.

Its somewhat difficult to discuss this without going into painstaking detail, but basically, you just need to associate some piece of data (like your coefficients) with the frame number. Another option is to precompute it all, store it as a .obj file, and then use a script to import those .obj files on every frame (check out a script by the user Atom, called MeshFoot).

I would do some research into script links first off, and if it doesn’t help, we can try to give you some more direction!

Thank you very much, I appreciate this!