| 283 | } |
| 284 | |
| 285 | Vec2 Camera::project(const Vec3& src) const |
| 286 | { |
| 287 | Vec2 screenPos; |
| 288 | |
| 289 | auto viewport = _director->getWinSize(); |
| 290 | Vec4 clipPos; |
| 291 | getViewProjectionMatrix().transformVector(Vec4(src.x, src.y, src.z, 1.0f), &clipPos); |
| 292 | |
| 293 | AXASSERT(clipPos.w != 0.0f, "clipPos.w can't be 0.0f!"); |
| 294 | float ndcX = clipPos.x / clipPos.w; |
| 295 | float ndcY = clipPos.y / clipPos.w; |
| 296 | |
| 297 | screenPos.x = (ndcX + 1.0f) * 0.5f * viewport.width; |
| 298 | screenPos.y = (1.0f - (ndcY + 1.0f) * 0.5f) * viewport.height; |
| 299 | return screenPos; |
| 300 | } |
| 301 | |
| 302 | Vec2 Camera::projectGL(const Vec3& src) const |
| 303 | { |
nothing calls this directly
no test coverage detected