|
AnyCAD Rapid API 2026
Help you to create a better world!
|
相机类 更多...
Public 成员函数 | |
| Camera (global::System.IntPtr cPtr, bool cMemoryOwn) | |
| 仅供内部使用 | |
| void | Dispose () |
| Camera () | |
| 默认构造函数,创建透视投影相机 | |
| Camera (uint width, uint height, Vector3d position, Vector3d target, Vector3d up) | |
| 构造函数 | |
| Vector3d | GetPosition () |
| void | SetPosition (Vector3d val) |
| Vector3 | GetPositionf () |
| Vector3d | GetUp () |
| void | SetUp (Vector3d val) |
| Vector3 | GetUpf () |
| Vector3d | GetTarget () |
| void | SetTarget (Vector3d val) |
| Vector3 | GetTargetf () |
| Vector2d | GetPageOffset () |
| void | SetPageOffset (Vector2d val) |
| Vector2 | GetPageOffsetf () |
| Matrix4d | GetViewMatrix () |
| Matrix4 | GetViewMatrixf () |
| double | GetNear () |
| void | SetNear (double val) |
| double | GetFar () |
| void | SetFar (double val) |
| double | GetFovy () |
| void | SetFovy (double val) |
| ViewPosition | GetOrigin () |
| void | SetOrigin (ViewPosition val) |
| ViewPosition | GetSize () |
| void | SetSize (ViewPosition val) |
| uint | GetWidth () |
| void | SetWidth (uint val) |
| uint | GetHeight () |
| void | SetHeight (uint val) |
| double | GetOrthoZoomFactor () |
| float | GetOrthoZoomFactorf () |
| 获取正交缩放因子(float 类型) | |
| EnumProjectionType | GetProjectionType () |
| void | SetProjectionType (EnumProjectionType val) |
| Matrix4d | GetProjectionMatrix () |
| Matrix4 | GetProjectionMatrixf () |
| bool | GetLockNearFar () |
| void | SetLockNearFar (bool val) |
| Vector3d | GetDirection () |
| 获取相机观察方向(单位向量) | |
| Vector3 | GetDirectionf () |
| 获取相机观察方向(float 类型) | |
| Vector3d | GetRight () |
| 获取相机右方向向量 | |
| Vector3 | GetRightf () |
| 获取相机右方向向量(float 类型) | |
| double | GetDistance () |
| 获取相机到目标点的距离 | |
| float | GetDistancef () |
| 获取相机到目标点的距离(float 类型) | |
| void | LookAt (Vector3d position, Vector3d target, Vector3d up) |
| 设置相机姿态(LookAt 方式) | |
| void | LookByDirection (Vector3d target, Vector3d dir, Vector3d up) |
| 设置相机姿态(方向方式) | |
| void | UpdateNearFar (AABox sceneBox) |
| 根据场景包围盒更新近远裁剪面 | |
| Vector2d | GetViewportSize () |
| 获取视口尺寸 | |
| Vector2d | GetViewportOrigin () |
| 获取视口原点坐标 | |
| Vector4d | GetViewport () |
| 获取完整的视口参数 | |
| Vector2d | GetViewportCenter () |
| 获取视口中心点坐标 | |
| void | Resize (uint width, uint height) |
| 调整视口大小 | |
| void | SetOrthoZoomFactor (double zoomFactor) |
| 设置正交投影的缩放因子 | |
| void | Zoom (double ratio, double distance) |
| 执行缩放操作 | |
| void | SetZoomFactorRange (double minV, double maxV) |
| 设置缩放因子的限制范围 | |
| void | ClearZoomFactorRange () |
| 清除缩放因子限制 | |
| Matrix4d | ComputeOrthoMatrix (double zoomFactor) |
| 根据缩放因子计算正交投影矩阵 | |
| bool | Contain (uint winX, uint winY) |
| 测试屏幕坐标点是否在视口范围内 | |
| void | UpdateViewMatrix () |
| 更新视图矩阵 | |
| void | UpdateProjectionMatrix () |
| 更新投影矩阵 | |
| void | Dump () |
| 输出相机参数到日志 | |
相机类
表示3D场景中的虚拟相机,控制观察位置、方向、投影方式等。
相机视口坐标系:
| AnyCAD.Foundation.Camera.Camera | ( | uint | width, |
| uint | height, | ||
| Vector3d | position, | ||
| Vector3d | target, | ||
| Vector3d | up ) |
构造函数
| width | 视口宽度(像素) |
| height | 视口高度(像素) |
| position | 相机位置坐标 |
| target | 目标点坐标(观察点) |
| up | 上方向向量 |
创建一个 LookAt 相机,自动计算视图矩阵
| void AnyCAD.Foundation.Camera.ClearZoomFactorRange | ( | ) |
清除缩放因子限制
移除最小/最大值约束,允许任意缩放
| Matrix4d AnyCAD.Foundation.Camera.ComputeOrthoMatrix | ( | double | zoomFactor | ) |
根据缩放因子计算正交投影矩阵
| zoomFactor | 缩放因子 |
基于当前视口宽高比和缩放因子构建对称的正交投影矩阵
| bool AnyCAD.Foundation.Camera.Contain | ( | uint | winX, |
| uint | winY ) |
测试屏幕坐标点是否在视口范围内
| winX | 窗口坐标 X |
| winY | 窗口坐标 Y |
检查点是否在视口的矩形区域内
| void AnyCAD.Foundation.Camera.Dump | ( | ) |
输出相机参数到日志
打印所有关键参数,用于调试和问题排查
| Vector3d AnyCAD.Foundation.Camera.GetDirection | ( | ) |
获取相机观察方向(单位向量)
计算公式:normalize(Target - Position)
| Vector3 AnyCAD.Foundation.Camera.GetDirectionf | ( | ) |
获取相机观察方向(float 类型)
| double AnyCAD.Foundation.Camera.GetDistance | ( | ) |
获取相机到目标点的距离
计算公式:|Target - Position|
| float AnyCAD.Foundation.Camera.GetDistancef | ( | ) |
获取相机到目标点的距离(float 类型)
| float AnyCAD.Foundation.Camera.GetOrthoZoomFactorf | ( | ) |
获取正交缩放因子(float 类型)
方便与 OpenGL/DirectX API 交互
| Vector3d AnyCAD.Foundation.Camera.GetRight | ( | ) |
获取相机右方向向量
通过 Direction × Up 叉积计算得到
| Vector3 AnyCAD.Foundation.Camera.GetRightf | ( | ) |
获取相机右方向向量(float 类型)
| Vector4d AnyCAD.Foundation.Camera.GetViewport | ( | ) |
获取完整的视口参数
组合原点和尺寸为四元组,方便传递给渲染 API
| Vector2d AnyCAD.Foundation.Camera.GetViewportCenter | ( | ) |
获取视口中心点坐标
| Vector2d AnyCAD.Foundation.Camera.GetViewportOrigin | ( | ) |
获取视口原点坐标
| Vector2d AnyCAD.Foundation.Camera.GetViewportSize | ( | ) |
获取视口尺寸
设置相机姿态(LookAt 方式)
| position | 相机位置 |
| target | 目标点位置 |
| up | 上方向向量 |
重新设置相机位置和目标点,自动更新视图矩阵
设置相机姿态(方向方式)
| target | 目标点位置 |
| dir | 观察方向向量 |
| up | 上方向向量 |
通过目标和方向设置相机,Position = Target - Dir * Distance
| void AnyCAD.Foundation.Camera.Resize | ( | uint | width, |
| uint | height ) |
调整视口大小
| width | 新的宽度 |
| height | 新的高度 |
更新视口尺寸并重新计算投影矩阵
| void AnyCAD.Foundation.Camera.SetOrthoZoomFactor | ( | double | zoomFactor | ) |
设置正交投影的缩放因子
| zoomFactor | 缩放因子(必须 > 0) |
增大 zoomFactor 会看到更大的范围(缩小效果)
| void AnyCAD.Foundation.Camera.SetZoomFactorRange | ( | double | minV, |
| double | maxV ) |
设置缩放因子的限制范围
| minV | 最小缩放因子 |
| maxV | 最大缩放因子 |
防止用户过度缩放导致显示异常
| void AnyCAD.Foundation.Camera.UpdateNearFar | ( | AABox | sceneBox | ) |
根据场景包围盒更新近远裁剪面
| sceneBox | 场景的轴对齐包围盒 |
自动计算合适的 Near 和 Far 值,确保整个场景可见且深度精度最优
| void AnyCAD.Foundation.Camera.UpdateProjectionMatrix | ( | ) |
更新投影矩阵
根据投影类型、FOV、宽高比、Near/Far 重新计算 ProjectionMatrix
| void AnyCAD.Foundation.Camera.UpdateViewMatrix | ( | ) |
更新视图矩阵
根据当前的 Position、Target、Up 重新计算 ViewMatrix
| void AnyCAD.Foundation.Camera.Zoom | ( | double | ratio, |
| double | distance ) |
执行缩放操作
| ratio | 缩放比例(> 0),用于正交投影 |
| distance | 移动距离,用于透视投影 |
正交投影:调整 zoomFactor;透视投影:沿观察方向移动相机