This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blender 質感・マテリアル設定実践テクニック 2-02-1.blend | |
import bpy | |
def init_engine(): | |
"""レンダリングエンジンの設定をします。""" | |
bpy.context.scene.render.engine = 'CYCLES' | |
bpy.context.scene.cycles.samples = 1_024 | |
def init_material(): | |
"""マテリアルの設定をします。""" | |
material = bpy.data.materials['Material'] | |
assert isinstance(material, bpy.types.Material) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BlenderユーザーのためのPython入門 | |
# 第22節 ランダムな色の複数の球を並べる | |
import bpy | |
import random | |
def delete_all(): | |
"""既存のメッシュとマテリアルを削除します。""" | |
for mesh in bpy.data.meshes: | |
assert isinstance(mesh, bpy.types.Mesh) | |
bpy.data.meshes.remove(mesh) | |
for material in bpy.data.materials: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BlenderユーザーのためのPython入門 | |
# 第23節 トーラスの各面にマテリアルインデックスをセットする | |
import bmesh | |
import bpy | |
import random | |
def delete_all(): | |
"""既存のメッシュとマテリアルを削除します。""" | |
for mesh in bpy.data.meshes: | |
assert isinstance(mesh, bpy.types.Mesh) | |
bpy.data.meshes.remove(mesh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BlenderユーザーのためのPython入門 | |
# 第24節 複数のキューブをsinで並べてグラデーションする | |
import colorsys | |
import bpy | |
import math | |
import random | |
def delete_all(): | |
"""既存のメッシュとマテリアルを削除します。""" | |
for mesh in bpy.data.meshes: | |
assert isinstance(mesh, bpy.types.Mesh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blender 質感・マテリアル設定実践テクニック 3-02-1.blend | |
import bpy | |
object = bpy.data.objects['export3dcoat'] # シーンに配置済みのオブジェクト | |
slot = object.material_slots[0] # そのマテリアルスロット | |
material = slot.material # に設定されているマテリアル | |
node_tree = material.node_tree # のノードネットワーク | |
nodes = node_tree.nodes # にある各ノード | |
def delete(): | |
"""過去に生成したノードを削除します。""" | |
for node in nodes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BlenderユーザーのためのPython入門 | |
# 第25節 ボーンを作成してボーンアニメーションさせる | |
import bpy | |
import math | |
import mathutils | |
class BoneAnimation(): | |
def __init__(self): | |
"""既存のアーマチュアとメッシュを削除します。""" | |
for armature in bpy.data.armatures: | |
assert isinstance(armature, bpy.types.Armature) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Makes all objects' material metallic.""" | |
import bpy | |
USE_TRANSMISSION = False | |
def remove(): | |
"""Removes previously created materials.""" | |
for material in bpy.data.materials: | |
if material.name == 'MyMaterial': | |
bpy.data.materials.remove(material) | |
def create_material(): | |
"""Creates a metallic material and returns it.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BlenderユーザーのためのPython入門 | |
# 第26節 ギャグマシーンを作成する | |
import bpy | |
import math | |
import random | |
# 人体を構成する10個のオブジェクトです。 | |
objs = [] | |
# 身体の各部分に許容する回転角です。 | |
rot_range = (10, 45, 90, 90, 90, 90, 90, 90, 90, 90) | |
def make_cube(parent, loc, scale, pivot, name): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blender 質感・マテリアル設定実践テクニック 3-03-1.blend | |
import bpy | |
object = bpy.data.objects['export3dcoat'] # シーンに配置済みのオブジェクト | |
slot = object.material_slots[0] # そのマテリアルスロット | |
material = slot.material # に設定されているマテリアル | |
node_tree = material.node_tree # のノードネットワーク | |
nodes = node_tree.nodes # にある各ノード | |
def delete(): | |
"""過去に生成したノードを削除します。""" | |
for node in nodes: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Blender 質感・マテリアル設定実践テクニック 3-03-1.blend | |
import bpy | |
object = bpy.data.objects['export3dcoat'] # シーンに配置済みのオブジェクト | |
slot = object.material_slots[0] # そのマテリアルスロット | |
material = slot.material # に設定されているマテリアル | |
node_tree = material.node_tree # のノードネットワーク | |
nodes = node_tree.nodes # にある各ノード | |
def delete(): | |
"""過去に生成したノードを削除します。""" | |
for node in nodes: |
OlderNewer