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

Replace animate_particles.py

parent b2d26444
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
# $ blender -P ./animacao.py # $ blender -P ./animacao.py
import bpy import bpy
bpy.context.user_preferences.view.show_splash = False
import numpy as np import numpy as np
import math import math
import os import os
...@@ -23,6 +24,8 @@ t_simulado=100 # tempo próprio da simulação em segundos ...@@ -23,6 +24,8 @@ t_simulado=100 # tempo próprio da simulação em segundos
fps = 24 # quadros por segundo fps = 24 # quadros por segundo
N_quadros=t_video*fps # calculando numero de quadros totais N_quadros=t_video*fps # calculando numero de quadros totais
delta_t=t_simulado/N_quadros # tempo passado por quadro delta_t=t_simulado/N_quadros # tempo passado por quadro
# Raio da paticula
r_part = 0.1 r_part = 0.1
#i, x1, x2, x3, v1, v2, v3, omega = np.genfromtxt(r'dados.txt',unpack=True) #i, x1, x2, x3, v1, v2, v3, omega = np.genfromtxt(r'dados.txt',unpack=True)
...@@ -31,48 +34,40 @@ r_part = 0.1 ...@@ -31,48 +34,40 @@ r_part = 0.1
#Npartics = Nevents*Ntracks #Npartics = Nevents*Ntracks
def criaobjetos(particles): def criaobjetos(particles):
bpy.context.scene.render.fps=fps
#Inicia limpando a cena - ATENÇÃO - apaga todos os objetos!! bpy.context.scene.frame_start = 0
for objeto in bpy.data.objects: bpy.context.scene.frame_end = N_quadros
bpy.data.objects.remove(objeto) blender_particles=[]
for particle in particles: for particle in particles:
bpy.ops.mesh.primitive_uv_sphere_add() bpy.ops.mesh.primitive_uv_sphere_add()
part = bpy.context.object part = bpy.context.object
part.name = "particula"+str(particle.iDx) part.name = "part"+str(particle.iDx)
part.location=((part.x,part.y,part.z)) part.location=((particle.x,particle.y,particle.z))
part.delta_scale=(r_part,r_part,r_part) part.delta_scale=(r_part,r_part,r_part)
blender_particles.append(part) blender_particles.append(part)
return blender_particles 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): def run(objects):
for f in range(1, N_quadros): for f in range(1, N_quadros):
t=delta_t*f t=delta_t*f
bpy.context.scene.render.fps=fps
bpy.context.scene.frame_current = f bpy.context.scene.frame_current = f
for i in range(0,len(objects)): 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].location=(particles[i].Propagate(t))
objects[i].keyframe_insert(data_path='location') objects[i].keyframe_insert(data_path='location')
# Remove cube # Remove cube
bpy.data.objects.remove(bpy.data.objects['Cube']) bpy.data.objects.remove(bpy.data.objects['Cube'])
# Create particles # Create particles
particles = createNparticlesProp(10) particles = createNparticlesProp(1000)
# Create blender objects # Create blender objects
blender_particles = criaobjetos(particles) blender_particles = criaobjetos(particles)
#Animate Scene #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