Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BOOL Vox::Project(float objx, float objy, float objz, const mathfu::mat4 projMatrix, const mathfu::mat4 modelMatrix, RECT* viewport, int* winx, int* winy, int* winz)
- {
- mathfu::vec4 in;
- mathfu::vec4 out;
- in.x = objx;
- in.y = objy;
- in.z = objz;
- in.w = 1.0f;
- out = modelMatrix * in;
- in = projMatrix * out;
- if (in.z == 0.0f) {
- return FALSE;
- }
- in.x = in.x / in.z;
- in.y = in.y / in.z;
- in.z = in.z / in.z;
- /* Map x, y and z to range 0-1 */
- in.x = in.x * 0.5f + 0.5f;
- in.y = in.y * 0.5f + 0.5f;
- in.z = in.z * 0.5f + 0.5f;
- /* Map x,y to viewport */
- in.x *= viewport->left + viewport->right;
- in.y *= viewport->top + viewport->bottom;
- *winx = int(in.x);
- *winy = int(in.y);
- *winz = int(in.z);
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement