Dissolve Text Animation

mercredi 28 mars 2012
par  Yann
popularité : 7%

Dissolve Text animation

Le tutoriel original est ici http://blenderdiplom.com/index.php/en/tutorials/item/78-tutorial-dissolve-your-logo-in-blender-262/

Ce fichier nécessite la version 2.62 de blender.

Attention si vous utiliser la version SVN de blender, à partie de l’API 2.62.2 il faut modifier la ligne suivante dans le script :

#NbQuads = len(ActiveObjectText.data.faces)
NbQuads = len(ActiveObjectText.data.polygons.values()) #API 2.62.2

le script suivant, accompagné du fichier blender permet de générer une animation.

Fichier Blender
Fichier Blender

Un petit bug subsiste. Pour le bon déroulement de l’animation, il faut réaffecter le "plane" qui contrôle le déroulement de l’animation "dissolve" (cf. figure suivante).

Réaffectation du plan

import bpy
from bpy.props import *
from math import pi

newText="OpenShot 1.5"
#create text
bpy.ops.object.text_add(view_align=False, enter_editmode=False,location=(0, 0, 0), rotation=(0, 0, 0))
ActiveObjectText = bpy.context.scene.objects.active
#rotating text
#angles are in radians
#bpy.ops.transform.rotate(value=(pi/2,), axis=(1.0, 0.0, 0.0), constraint_axis=(False, False, False), constraint_orientation='GLOBAL', mirror=False, proportional='DISABLED', proportional_edit_falloff='SMOOTH', proportional_size=1, snap=False, snap_target='CLOSEST', snap_point=(0, 0, 0), snap_align=False, snap_normal=(0, 0, 0), release_confirm=False)
#second solution
ActiveObjectText.rotation_euler[0]=pi/2 #xaxis
ActiveObjectText.rotation_euler[1]=0.0  #yaxis
ActiveObjectText.rotation_euler[2]=0.0  #zaxis
ActiveObjectText.location[0]=0
ActiveObjectText.location[1]=0
ActiveObjectText.location[2]=0 #dur to shadow on the ground
#changing text
bpy.context.scene.objects.active=ActiveObjectText
bpy.ops.object.editmode_toggle()
bpy.ops.font.delete()
bpy.ops.font.text_insert(text=newText, accent=False)
bpy.ops.object.editmode_toggle()

#centering text
ActiveObjectText.data.align='CENTER'
#extrude text
ActiveObjectText.data.extrude=0.04
#bevel text
ActiveObjectText.data.bevel_depth = 0.005
ActiveObjectText.data.bevel_resolution = 5

#text size
ActiveObjectText.data.size = 1

bpy.ops.object.select_all(action='DESELECT')

#selecting Text
bpy.context.scene.objects.active  = ActiveObjectText
bpy.context.scene.objects.active.select = True

#convert to mesh to apply effect
bpy.ops.object.convert(target='MESH', keep_original=False)

#affect dissolve material
ActiveObjectText.data.materials.append(bpy.data.materials['DissolveMaterial'])
ActiveObjectText = bpy.context.scene.objects.active

#Don't forget to deselect before select!
bpy.ops.object.select_all(action='DESELECT')

#selecting Text
bpy.context.scene.objects.active  = ActiveObjectText
bpy.context.scene.objects.active.select = True

#add remesh modifier to text
bpy.ops.object.modifier_add(type='REMESH')
#modifying parameters
ActiveObjectText.modifiers['Remesh'].octree_depth = 9 #10 best quality but vertices number too high
ActiveObjectText.modifiers['Remesh'].scale=0.99
ActiveObjectText.modifiers['Remesh'].mode='SMOOTH'
ActiveObjectText.modifiers['Remesh'].remove_disconnected_pieces=False
#apply this mofifier
bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Remesh")

#Nb quads for particle system
#NbQuads = len(ActiveObjectText.data.faces)
NbQuads = len(ActiveObjectText.data.polygons.values()) #API 2.62.2

#Add Particle System
bpy.ops.object.particle_system_add()
#Particle parameters
ActiveObjectText.particle_systems['ParticleSystem'].settings.count = NbQuads
ActiveObjectText.particle_systems['ParticleSystem'].settings.frame_start = 10
ActiveObjectText.particle_systems['ParticleSystem'].settings.frame_end = 60
ActiveObjectText.particle_systems['ParticleSystem'].point_cache.frame_step = 1
ActiveObjectText.particle_systems['ParticleSystem'].settings.normal_factor = 0.0
#not useful
#ActiveObjectText.particle_systems['ParticleSystem'].settings.use_dynamic_rotation = True
ActiveObjectText.particle_systems['ParticleSystem'].settings.render_type='NONE'
ActiveObjectText.particle_systems['ParticleSystem'].settings.draw_method='DOT'
ActiveObjectText.particle_systems['ParticleSystem'].settings.effector_weights.gravity = 0


#Adding Wind force field on center and rotate it -90 on Y
bpy.ops.object.effector_add(type='WIND', view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, -pi/2, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
ActiveObjectWindField = bpy.context.scene.objects.active
ActiveObjectWindField.name = 'WindField'
#settings
ActiveObjectWindField.field.strength = 1.0
ActiveObjectWindField.field.flow = 1.0
ActiveObjectWindField.field.noise = 0.0
ActiveObjectWindField.field.seed = 27
ActiveObjectWindField.field.apply_to_location = True
ActiveObjectWindField.field.apply_to_rotation = True
ActiveObjectWindField.field.use_absorption = False

#Adding Turbulence Force Field
bpy.ops.object.effector_add(type='TURBULENCE', view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(0, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
ActiveObjectTurbulenceField = bpy.context.scene.objects.active
ActiveObjectTurbulenceField.name = 'TurbulenceField'
#settings
ActiveObjectTurbulenceField.field.strength = 15
ActiveObjectTurbulenceField.field.size = 0.75
ActiveObjectTurbulenceField.field.flow = 0.5
ActiveObjectTurbulenceField.field.seed = 23
ActiveObjectTurbulenceField.field.apply_to_location = True
ActiveObjectTurbulenceField.field.apply_to_rotation = True
ActiveObjectTurbulenceField.field.use_absorption = False

#Don't forget to deselect before select!
bpy.ops.object.select_all(action='DESELECT')

#selecting Text
bpy.context.scene.objects.active  = ActiveObjectText
bpy.context.scene.objects.active.select = True
#adding wipe texture to text

sTex = bpy.data.textures.new('Wire2', type = 'BLEND')
sTex.use_color_ramp = True

ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots.create(0)
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture = bpy.data.textures['Wipe']

#Don't forget to deselect before select!
bpy.ops.object.select_all(action='DESELECT')

#Create plane for controlling action of particle system (based on time)
#if text is created on the fly 'Wipe' texture does not work! don't know really why!
# so use of an existing plane, and resize it to the text x dimension
bpy.ops.mesh.primitive_plane_add(view_align=False, enter_editmode=False, location=(0, 0, 0), rotation=(pi/2, 0, 0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
ActiveObjectPlane = bpy.context.scene.objects.active
#ActiveObjectPlane = bpy.context.scene.objects['Plane']
#bpy.context.scene.objects.active = ActiveObjectPlane
#bpy.context.scene.objects.active.select = True
ActiveObjectPlane.name = 'Plane'
#Change dimensions
ActiveObjectPlane.dimensions = ((ActiveObjectText.dimensions[0]*1.2),2,0)
#hide plane for render
ActiveObjectPlane.hide_render = True
#show as wire in 3D
ActiveObjectPlane.draw_type = 'WIRE'

#Don't forget to deselect before select!
bpy.ops.object.select_all(action='DESELECT')

#selecting Text
bpy.context.scene.objects.active  = ActiveObjectText
bpy.context.scene.objects.active.select = True

#affect new texture
ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture = sTex
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture.update_tag()
#need to know how to affect WIpe texture to particle texture slot
ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture_coords  = 'OBJECT'
ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].object = bpy.data.objects['Plane'] #ActiveObjectPlane #bpy.context.scene.objects['Plane']
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].object.update_tag(refresh={'OBJECT', 'DATA', 'TIME'})
ActiveObjectText.data.update()


#bpy.data.scenes['Scene'].update()

#Adding explode modifier
bpy.ops.object.modifier_add(type='EXPLODE')
bpy.ops.mesh.uv_texture_add()
ActiveObjectText.modifiers['Explode'].particle_uv = 'UVMap'

#testing....

#ActiveObjectText.data.update()
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture.update_tag()
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].object.update_tag(refresh={'OBJECT', 'DATA', 'TIME'})
#ActiveObjectText.data.update()
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].scale[0]=1.1
#ActiveObjectText.data.update()
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].scale[0]=1.0
#ActiveObjectText.data.update()

#need to really apply plane to slot
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].use_map_time = False
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].use_map_time = True

#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture_coords  = 'ORCO'
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture_coords  = 'OBJECT'
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].object  = ActiveObjectPlane

#bpy.ops.screen.animation_play()
#bpy.ops.screen.animation_cancel()
#bpy.ops.screen.frame_jump()

#ActiveObjectText.data.update()
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].texture.update_tag()
#ActiveObjectText.particle_systems['ParticleSystem'].settings.texture_slots[0].object.update_tag(refresh={'OBJECT', 'DATA', 'TIME'})
#bpy.data.scenes['Scene'].update()

Brèves

25 février 2011 - Scilab : Application GUI

Application GUI dans Scilab : Étude des systèmes automatiques. Systèmes Linéaires

9 janvier 2011 - Modèle 3D dans Scilab

Afficher des patchs dans Scilab à partir de Modèle 3D blender. Modèle 3D dans (...)

2 octobre 2010 - Plugins LDraw pour Blender 2.49

Importez vos modèles LEGO (MLCad et autres) dans blender grâce au plugin d’importation (...)