Commit cb64281e authored by Pedro Widniczck's avatar Pedro Widniczck
Browse files

Replace animate_particles.py

parent b2d26444
......@@ -8,6 +8,7 @@
# $ blender -P ./animacao.py
import bpy
bpy.context.user_preferences.view.show_splash = False
import numpy as np
import math
import os
......@@ -23,6 +24,8 @@ t_simulado=100 # tempo próprio da simulação em segundos
fps = 24 # quadros por segundo
N_quadros=t_video*fps # calculando numero de quadros totais
delta_t=t_simulado/N_quadros # tempo passado por quadro
# Raio da paticula
r_part = 0.1
#i, x1, x2, x3, v1, v2, v3, omega = np.genfromtxt(r'dados.txt',unpack=True)
......@@ -31,48 +34,40 @@ r_part = 0.1
#Npartics = Nevents*Ntracks
def criaobjetos(particles):
#Inicia limpando a cena - ATENÇÃO - apaga todos os objetos!!
for objeto in bpy.data.objects:
bpy.data.objects.remove(objeto)
bpy.context.scene.render.fps=fps
bpy.context.scene.frame_start = 0
bpy.context.scene.frame_end = N_quadros
blender_particles=[]
for particle in particles:
bpy.ops.mesh.primitive_uv_sphere_add()
part = bpy.context.object
part.name = "particula"+str(particle.iDx)
part.location=((part.x,part.y,part.z))
part.name = "part"+str(particle.iDx)
part.location=((particle.x,particle.y,particle.z))
part.delta_scale=(r_part,r_part,r_part)
blender_particles.append(part)
return blender_particles
#bpy.ops.object.camera_add(location=(0, 0, 10))
#bpy.ops.object.lamp_add(location=(0,0,0))#type='SUN',location=(0,0,0))
## TODO: Fazer sol não emitir sombra e adicionar lamp type='POINT' na origem
## Isto irá representar o dia/noite dos planetas
def run(objects):
for f in range(1, N_quadros):
t=delta_t*f
bpy.context.scene.render.fps=fps
bpy.context.scene.frame_current = f
for i in range(0,len(objects)):
bpy.contecct.scene.objects.activate=objects[i]
bpy.context.scene.objects.active=objects[i]
objects[i].location=(particles[i].Propagate(t))
objects[i].keyframe_insert(data_path='location')
# Remove cube
bpy.data.objects.remove(bpy.data.objects['Cube'])
# Create particles
particles = createNparticlesProp(10)
particles = createNparticlesProp(1000)
# Create blender objects
blender_particles = criaobjetos(particles)
#Animate Scene
animate(blender_particles)
run(blender_particles)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment