Method: CGLM::Mat4#unproject
- Defined in:
- ext/cglm/rb_cglm_project.c
#unproject(pos, viewport[, dest]) ⇒ dest | new Vec3
Maps the specified position into the space represented by this matrix,
places it in dest or a new Vec3 if dest is omitted, and returns it.
NOTE: This method must calculate the inverse of the current matrix. If you already have the inverse handy, you should use #unproject_i for better performance.
If
selfis aprojectionmatrix, then the result will be in view space.If
selfis aprojection * viewmatrix, then the result will be in world space.If
selfis anprojection * view * modelmatrix, then the result will be in object space.posis a Vec3 specifying the coordinates to unproject.viewportis a Vec4 specifying the dimensions of the viewport in[x, y, width, height]format.destis the Vec3 to place the results into, and will be created if omitted.
66 67 68 69 70 71 72 |
# File 'ext/cglm/rb_cglm_project.c', line 66 VALUE rb_cglm_project_unproject(int argc, VALUE *argv, VALUE self) { VALUE pos, , dest; rb_scan_args(argc, argv, "21", &pos, &, &dest); if (NIL_P(dest)) dest = VEC3_NEW(ALLOC_VEC3); glm_unproject(VAL2VEC3(pos), VAL2MAT4(self), VAL2VEC4(), VAL2VEC3(dest)); return dest; } |