blender 坐标系 金属度

目录

指向原点,并保持y轴朝上

设置金属度

具体操作

[1. 绕 X 轴旋转 90 度](#1. 绕 X 轴旋转 90 度)

[2. 绕 Z 轴旋转 90 度](#2. 绕 Z 轴旋转 90 度)

旋转矩阵示例

坐标系讲解视频


指向原点,并保持y轴朝上

python 复制代码
  direction = -camera.location
  rot_quat = direction.to_track_quat("-Z", "Y")  # [[1, 0, 0], [0, 0, -1], [0, 1, 0]]
  camera.rotation_euler = rot_quat.to_euler() 什么意思

设置金属度

python 复制代码
def fix_metallic(default_value=0.125):
    for material in bpy.data.materials:
        if material.use_nodes:
            nodes = material.node_tree.nodes
            try:
                bsdf = nodes.get("Principled BSDF")
                if bsdf:
                    # 设置金属度
                    bsdf.inputs['Metallic'].default_value = default_value
            except Exception as e:
                print(f"Error setting metallic for {material.name}: {e}")
        else:
            print(f"{material.name} does not use nodes.")

具体操作

1. 绕 X 轴旋转 90 度

如果你想让相机的 Y 轴朝上,可以尝试绕 X 轴旋转 90 度。这会把相机的 Z 轴从前向后旋转,同时使 Y 轴朝上。

camera.rotation_euler[0] += 1.5708 # 90 degrees in radians

2. 绕 Z 轴旋转 90 度

如果你要让相机的 Y 轴朝上,但方向仍然是平面旋转,绕 Z 轴旋转 90 度也是一个常见的方式。这种方式适用于你想让相机改变观察角度,但不涉及上下方向的变化。

camera.rotation_euler[2] += 1.5708 # 90 degrees in radians

旋转矩阵示例

如果你想手动应用一个旋转矩阵,可以利用 Blender 的旋转方法进行旋转,像这样:

import math import bpy # 让相机绕 X 轴旋转 90 度 camera = bpy.context.scene.camera camera.rotation_euler[0] = math.radians(90) # 绕 X 轴旋转 90 度

或者使用 to_quaternion 方法:

python 复制代码
import math

import bpy # 通过四元数进行旋转

rotation_quat = bpy.context.scene.camera.rotation_quaternion 
rotation_quat.rotate_axis('X', math.radians(90)) bpy.context.scene.camera.rotation_quaternion = rotation_quat

坐标系讲解视频

blender变换坐标系------blender小知识

相关推荐
一起搞IT吧6 小时前
高通Camx hal进程CSLAcquireDeviceHW crash问题分析一:CAM-ICP FW response timeout导致
android·图像处理·数码相机
格林威1 天前
Baumer工业相机堡盟工业相机如何通过YoloV8深度学习模型和EasyOCR实现汽车牌照动态检测和识别(C#代码,UI界面版)
人工智能·深度学习·数码相机·yolo·c#·汽车·视觉检测
8K超高清1 天前
广播级讯道摄像机CCU后挂上的PGM、ENG、PROD音频旋钮是做什么用的?
大数据·人工智能·科技·数码相机·音视频·智能硬件
格林威2 天前
Baumer高防护相机如何通过YoloV8深度学习模型实现网球运动员和网球速度的检测分析(C#代码UI界面版)
人工智能·深度学习·数码相机·yolo·ui·c#·视觉检测
hixiong1232 天前
C# OpencvSharp获取Astra Pro奥比中光深度相机深度图
数码相机·opencv·计算机视觉·c#
qq_526099134 天前
图像采集卡与工业相机:机器视觉“双剑合璧”的效能解析
图像处理·数码相机·计算机视觉
柠檬甜不甜呀4 天前
视觉采集模块的用法
数码相机·相机
北十南4 天前
ReLens「Focus & DSLR 大光圈虚化相机」v4.1.2 f 解锁付款版 —一款专业大光圈和单反级背景虚化编辑软件
数码相机
双翌视觉6 天前
机器视觉的磁芯定位贴合应用
数码相机·自动化·机器视觉
北十南8 天前
SODA自然美颜相机(甜盐相机国际版) v9.3.0
android·windows·数码相机