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

相关推荐
AttosTek1 天前
阿秒科技SWIR1503BU相机拍摄亚稳态氦原子在磁光阱中的俘获图象
数码相机
潜创微科技3 天前
ITE联阳IT920X系列:USB3.0摄像头走网线传100米——Webcam over IP的三种产品形态
数码相机
康谋自动驾驶4 天前
GMSL2相机ROS2采集链路:多相机时序偏差降低方案
数码相机·自动驾驶·汽车·仿真测试
a1117764 天前
工业视觉软件入门:VisionMaster(VM)、HALCON、VisionPro
嵌入式硬件·数码相机
cxoptics4 天前
机器视觉/工业检测中光源选择?
数码相机
埃科光电5 天前
极速扫描 多元散热:8K高阶TDI线阵相机 阵容升级
图像处理·人工智能·数码相机·计算机视觉·制造
黑马水牛5 天前
Carla仿真系列:5_Carla 四路相机标定与BEV环视拼接
数码相机
在世修行6 天前
从零打造 C# 工业视觉检测系统(五):相机连接、连续取流与双路实时预览
数码相机·c#·视觉检测
格林威6 天前
多相机微秒级对齐:硬件触发 vs PTP(IEEE 1588)方案实战对比
开发语言·人工智能·数码相机·机器学习·计算机视觉·视觉检测·机器视觉
xcLeigh7 天前
Unity基础:Camera相机组件详解——透视投影与正交投影的区别
数码相机·unity·游戏引擎