12345678910111213141516171819202122232425262728293031323334353637 |
- /*
- * 3D Engine
- * clipping.c:
- * Based on pikuma.com 3D software renderer in C
- * Copyright (c) 2021 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 11/03/2021.
- */
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <clipping.h>
- static plane_t frustum[TOTAL_PLANES];
- void initFrustumPlanes(double fov, double aspectRation, double zNear, double zFar)
- {
- frustum[LEFT_PLANE].point = vec3(0, 0, 0);
- frustum[LEFT_PLANE].normal = vec3( cos(fov) / 2, 0, sin(fov) / 2);
- frustum[RIGHT_PLANE].point = vec3(0, 0, 0);
- frustum[RIGHT_PLANE].normal = vec3( -cos(fov) / 2, 0, sin(fov) / 2);
- frustum[TOP_PLANE].point = vec3(0, 0, 0);
- frustum[TOP_PLANE].normal = vec3(0, -cos(fov) / 2, sin(fov) / 2);
- frustum[BOTTOM_PLANE].point = vec3(0, 0, 0);
- frustum[BOTTOM_PLANE].normal = vec3(0, cos(fov) / 2, sin(fov) / 2);
- frustum[NEAR_PLANE].point = vec3(0, 0, zNear);
- frustum[NEAR_PLANE].normal = vec3(0, 0, 1);
- frustum[FAR_PLANE].point = vec3(0, 0, zFar);
- frustum[FAR_PLANE].normal = vec3(0, 0, -1);
- }
|