if 'simple_obj_export' in locals():
imp.reload(simple_obj_export)
import bpy
from bpy.props import *
from io_utils import ExportHelper, ImportHelper
#
# ΠΠ΅Π½Ρ Import
#
class IMPORT_OT_simple_obj(bpy.types.Operator, ImportHelper):
bl_idname = "io_import_scene.simple_obj"
bl_description = 'Import from simple OBJ file format (.obj)'
bl_label = "Import simple OBJ" bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
filename_ext = ".obj"
filter_glob = StringProperty(default="*.obj;*.mtl", options={'HIDDEN'})
filepath = bpy.props.StringProperty(
name="File Path",
description="File path used for importing the simple OBJ file",
maxlen= 1024, default= "")
rot90 = bpy.props.BoolProperty(
name = "Rotate 90 degrees",
description="Rotate mesh to Z up",
default = True)
scale = bpy.props.FloatProperty(
name = "Scale",
description="Scale mesh",
default = 0.1, min = 0.001, max = 1000.0)
def execute(self, context):
from . import simple_obj_import
print("Load", self.properties.filepath)
simple_obj_import.import_simple_obj(
self.properties.filepath,
self.rot90,
self.scale)
return {'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
#
# ΠΠ΅Π½Ρ Export
#
class EXPORT_OT_simple_obj(bpy.types.Operator, ExportHelper):
bl_idname = "io_export_scene.simple_obj"
bl_description = 'Export from simple OBJ file format (.obj)'
bl_label = "Export simple OBJ"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
# ΠΠ· ExportHelper. Π€ΠΈΠ»ΡΡΡΠ°ΡΠΈΡ ΠΈΠΌΡΠ½ ΡΠ°ΠΉΠ»ΠΎΠ².
filename_ext = ".obj"
filter_glob = StringProperty(default="*.obj", options={'HIDDEN'})
filepath = bpy.props.StringProperty(
name="File Path",
description="File path used for exporting the simple OBJ file",
maxlen= 1024, default= "")
rot90 = bpy.props.BoolProperty(
name = "Rotate 90 degrees",
description="Rotate mesh to Y up",
default = True)
scale = bpy.props.FloatProperty(
name = "Scale",
description="Scale mesh",
default = 0.1, min = 0.001, max = 1000.0)
def execute(self, context):
print("Load", self.properties.filepath)
from . import simple_obj_export
simple_obj_export.export_simple_obj(
self.properties.filepath,
context.object,
self.rot90,
1.0/self.scale)
return {'FINISHED'}
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
#
# Π Π΅Π³ΠΈΡΡΡΠ°ΡΠΈΡ
#
def menu_func_import(self, context):
self.layout.operator(IMPORT_OT_simple_obj.bl_idname, text="Simple OBJ (.obj)...")
def menu_func_export(self, context):
self.layout.operator(EXPORT_OT_simple_obj.bl_idname, text="Simple OBJ (.obj)...")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_import.append(menu_func_import)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_import.remove(menu_func_import)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
if __name__ == "__main__":
register()
Π‘ΠΈΠΌΡΠ»ΡΡΠΈΠΈ
Π ΡΡΠΎΠΌ ΡΠ°Π·Π΄Π΅Π»Π΅ ΠΌΡ ΠΎΠ±ΡΠ°ΡΠ°Π΅ΠΌΡΡ ΠΊ ΠΏΠΎΡΠ΅Π½ΡΠΈΠ°Π»Ρ ΡΠΈΠΌΡΠ»ΡΡΠΈΠΉ ΠΠ»Π΅Π½Π΄Π΅ΡΠ° ΠΈΠ· ΠΠΈΡΠΎΠ½Π°. ΠΠ΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠ· ΠΏΡΠΈΠΌΠ΅ΡΠΎΠ² Π±ΡΠ»ΠΈ Π²Π΄ΠΎΡ Π½ΠΎΠ²Π»Π΅Π½Ρ ΠΊΠ½ΠΈΠ³ΠΎΠΉ Bounce, Tumble and Splash Π’ΠΎΠ½ΠΈ ΠΡΠ»Π»Π΅Π½Π° (ΠΈΡΠΈΡΠ΅ Π² Π‘Π΅ΡΠΈ Π²Π΅Π»ΠΈΠΊΠΎΠ»Π΅ΠΏΠ½ΡΠΉ ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ ΠΎΡ Morthan'Π°, ΠΏΠΎΠ»ΡΠ·ΡΡΡΡ ΡΠ»ΡΡΠ°Π΅ΠΌ, ΠΏΠ΅ΡΠ΅Π΄Π°Ρ Π΅ΠΌΡ Π±ΠΎΠ»ΡΡΠΎΠ΅ Π‘ΠΠΠ‘ΠΠΠ! - ΠΏΡΠΈΠΌ. ΠΏΠ΅Ρ.). ΠΠ΄Π½Π°ΠΊΠΎ, Π±ΠΎΠ»ΡΡΠΈΠ½ΡΡΠ²ΠΎ ΡΠ΅Π½Π΄Π΅ΡΠΎΠ² Π½Π΅ Π²ΡΠ³Π»ΡΠ΄ΡΡ ΡΠ°ΠΊ ΠΆΠ΅ Ρ ΠΎΡΠΎΡΠΎ, ΠΊΠ°ΠΊ Π² ΠΊΠ½ΠΈΠ³Π΅ ΠΡΠ»Π»Π΅Π½Π°, ΡΠ°ΠΊ ΠΊΠ°ΠΊ ΡΠ΅Π»ΡΡ ΡΡΠΈΡ Π·Π°ΠΌΠ΅ΡΠΎΠΊ Π½Π΅ Π±ΡΠ»ΠΎ Π½Π°ΠΉΡΠΈ ΠΎΠΏΡΠΈΠΌΠ°Π»ΡΠ½ΡΠΉ ΡΠΏΠΎΡΠΎΠ± Π΄Π»Ρ Π½Π°ΡΡΡΠΎΠΉΠΊΠΈ ΠΏΠ°ΡΠ°ΠΌΠ΅ΡΡΠΎΠ², Π° ΡΠΊΠΎΡΠ΅Π΅ ΡΡΠΎΠ±Ρ ΠΏΠΎΠΊΠ°Π·Π°ΡΡ, ΠΊΠ°ΠΊ ΠΈΡ ΠΌΠΎΠΆΠ½ΠΎ Π½Π°ΡΡΡΠ°ΠΈΠ²Π°ΡΡ ΠΈΠ· ΠΠΈΡΠΎΠ½Π°.
ΠΡΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅Ρ Π΄Π²Π΅ ΡΠΈΡΡΠ΅ΠΌΡ ΡΠ°ΡΡΠΈΡ.
#---------------------------------------------------
# File particle.py
#---------------------------------------------------
import bpy, mathutils, math
from mathutils import Vector, Matrix
from math import pi
def run(origo):
# ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΌΠ΅ΡΠ° ΡΠΌΠΈΡΡΠ΅ΡΠ°
origin = Vector(origo)
bpy.ops.mesh.primitive_plane_add(location=origin)
emitter = bpy.context.object
# --- Π‘ΠΈΡΡΠ΅ΠΌΠ° ΡΠ°ΡΡΠΈΡ 1: ΠΠ°Π΄Π΅Π½ΠΈΠ΅ ΠΈ ΡΠ΄ΡΠ²Π°Π½ΠΈΠ΅ ΠΊΠ°ΠΏΠ΅Π»Ρ ---
# ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΏΠ΅ΡΠ²ΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ ΡΠ°ΡΡΠΈΡ
bpy.ops.object.particle_system_add()
psys1 = emitter.particle_systems[-1]
psys1.name = 'Drops'
# ΠΠΌΠΈΡΡΠΈΡ, ΠΈΡΠΏΡΡΠΊΠ°Π½ΠΈΠ΅
pset1 = psys1.settings
pset1.name = 'DropSettings'
pset1.frame_start = 40
pset1.frame_end = 200
pset1.lifetime = 50
pset1.lifetime_random = 0.4
pset1.emit_from = 'FACE'
pset1.use_render_emitter = True
pset1.object_align_factor = (0,0,1)
# Π€ΠΈΠ·ΠΈΠΊΠ°
pset1.physics_type = 'NEWTON'
pset1.mass = 2.5
pset1.particle_size = 0.3
pset1.use_multiply_size_mass = True
# ΠΠ΅ΡΠ° ΡΡΡΠ΅ΠΊΡΠΎΡΠΎΠ²
ew = pset1.effector_weights
ew.gravity = 1.0
ew.wind = 1.0
# ΠΠΎΡΠ΅ΡΠ½ΠΈΠ΅ ΡΠ°ΡΡΠΈΡΡ
pset1.child_nbr = 10
pset1.rendered_child_count = 10
pset1.child_type = 'SIMPLE'
# ΠΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ ΠΈ ΡΠ΅Π½Π΄Π΅Ρ
pset1.draw_percentage = 100
pset1.draw_method = 'CROSS'
pset1.material = 1
pset1.particle_size = 0.1
pset1.render_type = 'HALO'
pset1.render_step = 3
# ------------ ΠΡΡΠ΅ΠΊΡΠΎΡ Π²Π΅ΡΡΠ° -----
# ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΡΡΡΠ΅ΠΊΡΠΎΡΠ° Π²Π΅ΡΡΠ°
bpy.ops.object.effector_add(
type='WIND',
enter_editmode=False,
location = origin - Vector((0,3,0)),
rotation = (-pi/2, 0, 0))
wind = bpy.context.object
# ΠΠ°ΡΡΡΠΎΠΉΠΊΠΈ ΠΏΠΎΠ»Π΅ΠΉ
fld = wind.field
fld.strength = 2.3
fld.noise = 3.2
fld.flow = 0.3
# --- Π‘ΠΈΡΡΠ΅ΠΌΠ° ΡΠ°ΡΡΠΈΡ 2: ΠΠ±Π΅Π·ΡΡΠ½Ρ Π½Π° Π²Π΅ΡΡΡ ----
# ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΎΠ±Π΅Π·ΡΡΠ½Ρ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΠΎΠΉ ΠΊΠ°ΠΊ ΠΎΠ±ΡΠ΅ΠΊΡ ΡΠ°Π·ΠΌΠ½ΠΎΠΆΠ΅Π½ΠΈΡ
# Π‘ΠΊΡΡΡΠΈΠ΅ ΠΎΠ±Π΅Π·ΡΡΠ½Ρ Π² ΡΠ»ΠΎΠ΅ 2
layers = 20*[False]
layers[1] = True
bpy.ops.mesh.primitive_monkey_add(
location=origin+Vector((0,5,0)),
rotation = (pi/2, 0, 0),
layers = layers)
monkey = bpy.context.object
#ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ Π²ΡΠΎΡΠΎΠΉ ΡΠΈΡΡΠ΅ΠΌΡ ΡΠ°ΡΡΠΈΡ
bpy.context.scene.objects.active = emitter
bpy.ops.object.particle_system_add()
psys2 = emitter.particle_systems[-1]
psys2.name = 'Monkeys'
pset2 = psys2.settings
pset2.name = 'MonkeySettings'
# ΠΠΌΠΈΡΡΠΈΡ, ΠΈΡΠΏΡΡΠΊΠ°Π½ΠΈΠ΅
pset2.count = 4
pset2.frame_start = 1
pset2.frame_end = 50
pset2.lifetime = 250
pset2.emit_from = 'FACE'
pset2.use_render_emitter = True
# Π‘ΠΊΠΎΡΠΎΡΡΡ
pset2.factor_random = 0.5
# Π€ΠΈΠ·ΠΈΠΊΠ°
pset2.physics_type = 'NEWTON'
pset2.brownian_factor = 0.5
# ΠΠ΅ΡΠ° ΡΡΡΠ΅ΠΊΡΠΎΡΠΎΠ²
ew = pset2.effector_weights
ew.gravity = 0
ew.wind = 0.2
# ΠΠΎΡΠ΅ΡΠ½ΠΈΠ΅ ΡΠ°ΡΡΠΈΡΡ
pset2.child_nbr = 1
pset2.rendered_child_count = 1
pset2.child_size = 3
pset2.child_type = 'SIMPLE'
# ΠΡΠΎΠ±ΡΠ°ΠΆΠ΅Π½ΠΈΠ΅ ΠΈ ΡΠ΅Π½Π΄Π΅Ρ
pset2.draw_percentage = 1
pset2.draw_method = 'RENDER'
pset2.dupli_object = monkey
pset2.material = 1
pset2.particle_size = 0.1
pset2.render_type = 'OBJECT'
pset2.render_step = 3
return
if __name__ == "__main__":
bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete()
run((0,0,0))
bpy.ops.screen.animation_play(reverse=False, sync=False)
ΠΡΠ° ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠ° Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅Ρ ΡΡΠ΅ΡΡ Ρ Π²ΠΎΠ»ΠΎΡΠ°ΠΌΠΈ. ΠΠ»Ρ Π²ΠΎΠ»ΠΎΡ ΡΡΡΠΎΠΈΡΡΡ ΡΠ΅ΠΉΠ΄Π΅Ρ ΡΠΈΠΏΠ° strand.
#---------------------------------------------------
# File hair.py
#---------------------------------------------------
import bpy
def createHead(origin):
# ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ ΠΌΠ΅ΡΠ° ΡΠΌΠΈΡΡΠ΅ΡΠ°
bpy.ops.mesh.primitive_ico_sphere_add(location=origin)
ob = bpy.context.object
bpy.ops.object.shade_smooth()
# Π‘ΠΎΠ·Π΄Π°Π½ΠΈΠ΅ Π³ΡΡΠΏΠΏΡ Π²Π΅ΡΡΠΈΠ½ scalp (ΡΠΊΠ°Π»ΡΠΏ), Π° ΡΠ°ΠΊΠΆΠ΅ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΠ΅ Π²Π΅ΡΡΠΈΠ½ ΠΈ Π²Π΅ΡΠΎΠ²