MCPcopy Create free account
hub / github.com/bernhardstrobl/Pico3D / update_camera

Function update_camera

engine/render_camera.cpp:11–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9
10
11void update_camera() {
12
13 float cosPitch = cos(pitch);
14 float sinPitch = sin(pitch);
15 float cosYaw = cos(yaw);
16 float sinYaw = sin(yaw);
17
18
19 float xaxis[3] = { cosYaw, 0, -sinYaw };
20 float yaxis[3] = { sinYaw * sinPitch, cosPitch, cosYaw * sinPitch };
21 float zaxis[3] = { sinYaw * cosPitch, -sinPitch, cosPitch * cosYaw };
22
23
24 mat_camera[0][0] = xaxis[0];
25 mat_camera[0][1] = xaxis[1];
26 mat_camera[0][2] = xaxis[2];
27 mat_camera[0][3] = -dot_product3( xaxis, camera_position );
28
29 mat_camera[1][0] = yaxis[0];
30 mat_camera[1][1] = yaxis[1];
31 mat_camera[1][2] = yaxis[2];
32 mat_camera[1][3] = -dot_product3( yaxis, camera_position );
33
34 mat_camera[2][0] = zaxis[0];
35 mat_camera[2][1] = zaxis[1];
36 mat_camera[2][2] = zaxis[2];
37 mat_camera[2][3] = -dot_product3( zaxis, camera_position );
38
39 mat_camera[3][0] = 0;
40 mat_camera[3][1] = 0;
41 mat_camera[3][2] = 0;
42 mat_camera[3][3] = 1;
43
44
45 //create fixed point camera position
46 camera_position_fixed_point[0] = float_to_int(camera_position[0]);
47 camera_position_fixed_point[1] = float_to_int(camera_position[1]);
48 camera_position_fixed_point[2] = float_to_int(camera_position[2]);
49}
50
51void move_camera(float move) {
52 //we know the cameras yaw, we can create forward/backward movement

Callers 4

logic_demoFunction · 0.85
logic_inputFunction · 0.85
logic_new_gameFunction · 0.85
logic_eventsFunction · 0.85

Calls 2

dot_product3Function · 0.85
float_to_intFunction · 0.85

Tested by

no test coverage detected