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小知识

相关推荐
枫叶林FYL10 小时前
【强化学习】4 视觉引导的时序奖励塑形:多视角视频驱动的强化学习状态对齐框架
数码相机·音视频
cd_9492172112 小时前
鸿蒙系统给抖音开启相机权限的操作指南(2026)
数码相机·华为·harmonyos
2601_9574188013 小时前
深入解析Android相机有线连接:PTP与MTP协议栈实现原理与实践
android·数码相机·智能手机
qq_526099132 天前
工业视觉核心硬件:图像采集卡性能体系与选型逻辑解析
数码相机
kyle~2 天前
机器人感知 --- 多相机传感时间误差分析
linux·c++·数码相机·机器人·ros2·传感器
ZPC82102 天前
moveit2_servo 怎么接收相机调节指令(视觉伺服)
人工智能·数码相机·算法·计算机视觉·机器人
苏映视官方账号3 天前
展会回顾丨INSNEX苏映视精彩亮相CIBF 深圳国际电池展
数码相机
8K超高清3 天前
2026传媒技术大会:博冠赋能融媒体制播
大数据·人工智能·科技·数码相机·计算机视觉·传媒·媒体
视图猿人3 天前
ubuntu24.04系统使用深度相机Astra pro时的配置方法
数码相机
2601_957418804 天前
Android相机有线连接全栈解决方案:PTP/MTP协议深度实现与应用实践
android·数码相机