MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / project

Function project

Source/Node/Node.cpp:1539–1563  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1537}
1538
1539static bool project(float objx, float objy, float objz,
1540 const Matrix& model, const Matrix& proj,
1541 const float viewport[4],
1542 float* winx, float* winy, float* winz) {
1543 /* matrice de transformation */
1544 Vec4 in, out;
1545 /* initilise la matrice et le vecteur a transformer */
1546 in.x = objx;
1547 in.y = objy;
1548 in.z = objz;
1549 in.w = 1.0;
1550 Matrix::mulVec4(out, model, in);
1551 Matrix::mulVec4(in, proj, out);
1552 /* d’ou le resultat normalise entre -1 et 1 */
1553 if (in.z == 0.0) return false;
1554 in.x /= in.w;
1555 in.y /= in.w;
1556 in.z /= in.w;
1557 /* en coordonnees ecran */
1558 *winx = viewport[0] + (1.0f + in.x) * viewport[2] / 2.0f;
1559 *winy = viewport[1] + (1.0f + in.y) * viewport[3] / 2.0f;
1560 /* entre 0 et 1 suivant z */
1561 *winz = (1.0f + in.z) / 2.0f;
1562 return true;
1563}
1564
1565class ProjectNode : public Node {
1566public:

Callers 1

renderMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected