MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / GetMouseRotation

Function GetMouseRotation

editor/moveworld.cpp:68–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66#define dist_2d(x, y) sqrt((x) * (x) + (y) * (y))
67
68void GetMouseRotation(int idx, int idy, matrix *RotMat) {
69 float dr, cos_theta, sin_theta, denom, cos_theta1;
70 float Radius = 100.0;
71 float dx, dy;
72 float dxdr, dydr;
73
74 idy *= -1;
75
76 dx = idx;
77 dy = idy;
78
79 dr = dist_2d(dx, dy);
80
81 denom = dist_2d(Radius, dr);
82
83 cos_theta = Radius / denom;
84 sin_theta = dr / denom;
85
86 cos_theta1 = 1.0 - cos_theta;
87
88 dxdr = dx / dr;
89 dydr = dy / dr;
90
91 RotMat->rvec.x = cos_theta + ((dydr * dydr) * cos_theta1);
92 RotMat->uvec.x = -((dxdr * dydr) * cos_theta1);
93 RotMat->fvec.x = (dxdr * sin_theta);
94
95 RotMat->rvec.y = RotMat->uvec.x;
96 RotMat->uvec.y = cos_theta + ((dxdr * dxdr) * cos_theta1);
97 RotMat->fvec.y = (dydr * sin_theta);
98
99 RotMat->rvec.z = -RotMat->fvec.x;
100 RotMat->uvec.z = -RotMat->fvec.y;
101 RotMat->fvec.z = cos_theta;
102}
103
104// Variables for current view position and orientation
105#define DEFAULT_VIEW_DIST 500

Callers 1

MoveWorldFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected