remove offsets for WMO groups

This commit is contained in:
Natsirt867
2026-01-05 18:59:51 -06:00
parent 681436ac68
commit da45ad2815
2 changed files with 48 additions and 12 deletions

View File

@@ -474,14 +474,18 @@ void init() {
float speed = 10.0f; // 1 unit per second float speed = 10.0f; // 1 unit per second
float last_position = 0.0f; float last_position = 0.0f;
float cam_speed = 10.0f; // 1 unit per sec float cam_speed = 30.0f; // 1 unit per sec
float cam_yaw_speed = 3.5f; // 3.5 degrees per second float cam_yaw_speed = 1.0f; // 3.5 degrees per second
vec3_t cam_pos = { 0.0f, 20.0f, 150.0f }; // don't start at zero, or we will be too close vec3_t cam_pos = { 0.0f, 20.0f, 150.0f }; // don't start at zero, or we will be too close
float cam_yaw = 0.0f; // y-rotation in degrees float cam_yaw = 0.0f; // y-rotation in degrees
float cam_pitch = 0.0f; float cam_pitch = 45.0f;
mat4_t T = mat4_make_translation(-cam_pos.x, -cam_pos.y, -cam_pos.z);
mat4_t R = mat4_make_rotation_y(-cam_yaw); // TODO: fix issues with initial view matrix and view_matrix when camera is moved
mat4_t view_mat = mat4_mul_mat4(R, T); //mat4_t T = mat4_make_translation(-cam_pos.x, -cam_pos.y, -cam_pos.z);
//mat4_t R = mat4_make_rotation_y(-cam_yaw);
//mat4_t view_mat = mat4_mul_mat4(R, T);
/* /*
// projection matrix variables // projection matrix variables
@@ -505,9 +509,33 @@ void init() {
0.0f, 0.0f, Pz, 0.0f 0.0f, 0.0f, Pz, 0.0f
};*/ };*/
float yaw_rad = TO_RAD(cam_yaw);
float pitch_rad = TO_RAD(cam_pitch);
vec3_t cam_front;
cam_front.x = cosf(yaw_rad) * cosf(pitch_rad);
cam_front.y = sinf(pitch_rad);
cam_front.z = sinf(yaw_rad) * cosf(pitch_rad);
vec3_normalize(&cam_front);
vec3_t world_up = { 0.0f, 1.0f, 0.0f };
vec3_t cam_right = vec3_cross(cam_front, world_up);
vec3_normalize(&cam_right);
vec3_t cam_up = vec3_cross(cam_right, cam_front);
vec3_normalize(&cam_up);
mat4_t view_mat = mat4_look_at(
cam_pos.x, cam_pos.y, cam_pos.z,
cam_pos.x + cam_front.x, cam_pos.y + cam_front.y, cam_pos.z + cam_front.z,
cam_up.x, cam_up.y, cam_up.z
);
float fov_radians = 67.0f * ONE_DEG_IN_RAD; float fov_radians = 67.0f * ONE_DEG_IN_RAD;
mat4_t projection = mat4_make_perspective(fov_radians, (float)width / (float)height, 0.1f, 1000.0f); mat4_t projection = mat4_make_perspective(fov_radians, (float)width / (float)height, 0.1f, 5000.0f);
//mat4_t rotation_correction = mat4_make_rotation_x(TO_RAD(-90.0f)); //mat4_t rotation_correction = mat4_make_rotation_x(TO_RAD(-90.0f));
@@ -566,8 +594,8 @@ void init() {
glUniformMatrix4fv(matrix_location, 1, GL_FALSE, final_matrix.m); glUniformMatrix4fv(matrix_location, 1, GL_FALSE, final_matrix.m);
}*/ }*/
float yaw_rad = TO_RAD(cam_yaw); yaw_rad = TO_RAD(cam_yaw);
float pitch_rad = TO_RAD(cam_pitch); pitch_rad = TO_RAD(cam_pitch);
vec3_t cam_front; vec3_t cam_front;
cam_front.x = cosf(yaw_rad) * cosf(pitch_rad); cam_front.x = cosf(yaw_rad) * cosf(pitch_rad);
@@ -686,8 +714,10 @@ void init() {
} }
if (glfwGetKey (window, GLFW_KEY_DOWN)) { if (glfwGetKey (window, GLFW_KEY_DOWN)) {
cam_pitch -= cam_yaw_speed * elapsed_seconds; cam_pitch -= cam_yaw_speed * elapsed_seconds;
cam_moved = true;
} }
if (cam_pitch > 89.0f) { if (cam_pitch > 89.0f) {
cam_pitch = 89.0f; cam_pitch = 89.0f;
} }

View File

@@ -27,14 +27,20 @@ GroupMesh create_mesh_from_group(const WMOGroupData* group, const WMORootData* r
const C3Vector* normals = (const C3Vector*)group->monr_data_ptr; const C3Vector* normals = (const C3Vector*)group->monr_data_ptr;
const C2Vector* texCoords = (const C2Vector*)group->motv_data_ptr; const C2Vector* texCoords = (const C2Vector*)group->motv_data_ptr;
// TODO: double check if we need the offset here, I believe its
GLfloat offset_x = group->header.boundingBox.min[0]; GLfloat offset_x = group->header.boundingBox.min[0];
GLfloat offset_y = group->header.boundingBox.min[1]; GLfloat offset_y = group->header.boundingBox.min[1];
GLfloat offset_z = group->header.boundingBox.min[2]; GLfloat offset_z = group->header.boundingBox.min[2];
for (size_t i = 0; i < num_vertices; i++) { for (size_t i = 0; i < num_vertices; i++) {
float wx = positions[i].x + offset_x; //float wx = positions[i].x + offset_x;
float wy = positions[i].y + offset_y; //float wy = positions[i].y + offset_y;
float wz = positions[i].z + offset_z; //float wz = positions[i].z + offset_z;
float wx = positions[i].x;
float wy = positions[i].y;
float wz = positions[i].z;
vertices[i].position.x = wx; vertices[i].position.x = wx;
vertices[i].position.y = wy; vertices[i].position.y = wy;