本文整理汇总了C++中Vector2::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::Get方法的具体用法?C++ Vector2::Get怎么用?C++ Vector2::Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2
的用法示例。
在下文中一共展示了Vector2::Get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ScreenPointToRay
Ray Camera::ScreenPointToRay(const Vector2 point) const {
Matrix4x4 view = GetTransformation()->GetAccumulatedMatrix();
Vector3 camPos = Vector3(view.Get(3,0), view.Get(3,1), view.Get(3,2));
Matrix4x4 vp = GetProjectionMatrix() * view;
if (!Invert(vp)) Debug::LogError("Failed to invert view projection matrix");
// Convert from screen space to viewport space and to [-1;1] range.
float viewportX = (point.Get(0) - rect.x) * 2.0f / float(rect.width) - 1.0f;
float viewportY = (point.Get(1) - rect.y) * 2.0f / float(rect.height) - 1.0f;
Vector4 viewportPoint = Vector4(viewportX, viewportY, 1.0f, 1.0f);
Vector4 worldPos = vp * viewportPoint;
Vector3 rayEnd = Vector3(worldPos.Get(0) / worldPos.Get(3),
worldPos.Get(1) / worldPos.Get(3),
worldPos.Get(2) / worldPos.Get(3));
return Ray(camPos, Normalize(rayEnd - camPos));
}