Ask Your Question

3d animation with tachyon

asked 2012-05-17 10:35:17 +0200

Roctiv gravatar image

updated 2012-05-17 10:37:27 +0200


I'm trying to create a 3d animations, frame per frame. I've discovered that tachyon plotter is very usefull to create images. But after that, I'm unable to make it as animation.

For example, I have copied a code and generate some scenes with tachyon with this:

saved = []
for j in srange(-0.9,1,0.3):
   t = Tachyon(xres=512,yres=512, camera_center=(3,0.3,0))
   t.light((4,3,2), 0.2, (1,1,1))
   t.texture('t0', ambient=0.1, diffuse=0.9, specular=0.5, opacity=1.0, color=(1.0,0,0))
   t.texture('t1', ambient=0.1, diffuse=0.9, specular=0.3, opacity=1.0, color=(0,1.0,0))
   t.texture('t2', ambient=0.2,diffuse=0.7, specular=0.5, opacity=0.7, color=(0,0,1.0))
   for i in srange(-1,j,0.05):
      k += 1
      t.sphere((i,i^2-0.5,i^3), 0.1, 't%s'%(k%3))

In "saved" array I have all the png of the animation I want to do, and I can view it with saved[i].show().

I tried to unite all the frames with the command animate:

animate(saved[i].show() for i in range(0,len(saved)))

But it didn't work. What other alternatives do I have? (without using ffmpeg)

Thank you!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2012-05-17 13:19:01 +0200

kcrisman gravatar image

I see. Well, first off, the things in your saved are not actually graphics file, but Tachyon scenes. Secondly, we can access things in the notebook via the DATA variable. Borrowing some ideas from the thread mentioned in the other post:

for i in range(len(saved)):

os.system('cd '+DATA+'; convert -delay %s -loop %s *.png "Done.gif"'%(int(100),int(2)))
os.system('ls '+DATA)

This shows that the Done.gif is there. If you then go to the "Data..." menu and choose it, you will see it and be able to download it. That's not ideal, but a lot better than nothing.

where to look

Naturally, this all assumes you have animate working properly (because that requires the convert command we are using here). Probably I should also use sage-native-execute but I don't really understand that.

edit flag offensive delete link more


Thank you!!! That's it! I wanted something simple, because I can only use the notebook (I cannot modify the system). Thank you very much

Roctiv gravatar imageRoctiv ( 2012-05-17 13:35:31 +0200 )edit

To the guy who will see this in the future (he could be me tomorrow): that funtion is ok if len(saved) < 10, if it's bigger the names of the should have more digits.

Roctiv gravatar imageRoctiv ( 2012-05-17 13:53:13 +0200 )edit

Oh, maybe I should have used %s instead of %d?

kcrisman gravatar imagekcrisman ( 2012-05-17 14:47:43 +0200 )edit

@Roctiv you're right. This should be used instead: 'mypic%02d.png' % i. Then it is ok if len(saved) < 100. You can of course change 02 to something bigger if desired.

Joel Sjögren gravatar imageJoel Sjögren ( 2013-07-08 12:11:12 +0200 )edit

answered 2012-05-17 11:53:43 +0200

kcrisman gravatar image

updated 2012-05-17 14:50:26 +0200

You say without ffmpeg, but apparently that's the only obvious way to do it. You might also find Trac 7298 helpful, though apparently that has unresolved issues.

Note that this "answer" is really just Marshall's from the other question.

Edit: Trac 12827 actually is about adding more types to the animate command, such as Tachyon-generated pictures.

edit flag offensive delete link more


Thank you. I had already seen that answer. But I think, that what I want to do is too simple to attack it with a powerfull tool (that I don't know how to use). I mean, animate function should be enough to join a couple of photgrams... or not?

Roctiv gravatar imageRoctiv ( 2012-05-17 12:04:56 +0200 )edit

It looks like there would be a way to use the code in `animate??` to do this, but as it stands the `animate` command is for animating either 2-D graphics objects or something which can be 2-D plotted. Extending it to do what you want is probably not a bad idea, but would take some work.

kcrisman gravatar imagekcrisman ( 2012-05-17 12:31:48 +0200 )edit

I thought animate function had more freedom to choose the types :(

Roctiv gravatar imageRoctiv ( 2012-05-17 13:41:16 +0200 )edit

No, it's pretty clear in the constructor what it does. Doesn't mean we couldn't add them! See my edit to this answer.

kcrisman gravatar imagekcrisman ( 2012-05-17 14:49:58 +0200 )edit

I wanted to aswer just ":)", but I need 10 chararcters :D

Roctiv gravatar imageRoctiv ( 2012-05-18 12:14:14 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-05-17 10:35:17 +0200

Seen: 1,393 times

Last updated: May 17 '12