Unity的Graphics.DrawMesh在其任何构造函数重载中不接受缩放参数是否有特殊原因?



目前Graphics.DrawMesh具有以下构造函数:

public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation);
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, int materialIndex);
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, Material material, int layer, Camera camera = null, int submeshIndex = 0, MaterialPropertyBlock properties = null, bool castShadows = true, bool receiveShadows = true);
public static void DrawMesh(Mesh mesh, Vector3 position, Quaternion rotation, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows = true, Transform probeAnchor = null);
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix);
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, int materialIndex);
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera = null, int submeshIndex = 0, MaterialPropertyBlock properties = null, bool castShadows = true, bool receiveShadows = true);
public static void DrawMesh(Mesh mesh, Matrix4x4 matrix, Material material, int layer, Camera camera, int submeshIndex, MaterialPropertyBlock properties, Rendering.ShadowCastingMode castShadows, bool receiveShadows = true, Transform probeAnchor = null);

位置旋转公开时,任何重载都不接受缩放参数来动态设置绘制网格的比例。

  1. 这有什么特别的原因吗?
  2. 无论如何,扩展的最佳方法是什么?

您可以使用 Matrix4x4.TRS 函数创建一个组合位置、旋转和缩放的矩阵,然后可以在 Graphics.DrawMesh 中使用。例如:

Vector3 position = Random.insideUnitSphere;
Quaternion rotation = Random.rotation;
Vector3 scale = new Vector3(0.5f, 1, 2.5f);
Matrix4x4 matrix = Matrix4x4.TRS(position, rotation, scale);
Graphics.DrawMesh(mesh, matrix, material, 0);

伙计在使用DrawMesh时,您不会只使用转换矩阵本身来扩展它,对吗?

即,

  1. 这有什么特别的原因吗?

您可能只在转换矩阵中执行此操作,因此无需添加缩放命令

  1. 无论如何,扩展的最佳方法是什么?

我猜在转换矩阵中

相关内容

最新更新