MCPcopy Create free account
hub / github.com/axmolengine/axmol / project

Method project

core/2d/Camera.cpp:285–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

283}
284
285Vec2 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
302Vec2 Camera::projectGL(const Vec3& src) const
303{

Callers

nothing calls this directly

Calls 2

transformVectorMethod · 0.80
Vec4Function · 0.50

Tested by

no test coverage detected