diff --git a/src/simulator.cc b/src/simulator.cc index a110aa7..fa069c8 100644 --- a/src/simulator.cc +++ b/src/simulator.cc @@ -238,14 +238,37 @@ void simulator_draw(srcmdbuf* cmdbuf) { gLog("Error: cannot render shape of type %d", cinfo.second.mType); } - rcmd.mat = simd4x4f_create( + simd4x4f trans = simd4x4f_create ( // clang-format off - simd4f_create(cinfo.second.scale[0] * 0.5f, 0.f, 0.f, 0.f), - simd4f_create(0.f, cinfo.second.scale[1] * 0.5f, 0.f, 0.f), - simd4f_create(0.f, 0.f, cinfo.second.scale[2] * 0.5f, 0.f), + simd4f_create(1.f, 0.f, 0.f, 0.f), + simd4f_create(0.f, 1.f, 0.f, 0.f), + simd4f_create(0.f, 0.f, 1.f, 0.f), simd4f_create(cinfo.second.pos[0], cinfo.second.pos[1], cinfo.second.pos[2], 1.f) // clang-format on + ); + + simd4x4f scale = simd4x4f_create( + // clang-format off + simd4f_create(cinfo.second.scale[0], 0.f, 0.f, 0.f), + simd4f_create(0.f, cinfo.second.scale[1], 0.f, 0.f), + simd4f_create(0.f, 0.f, cinfo.second.scale[2], 0.f), + simd4f_create(0.f, 0.f, 0.f, 1.f) + // clang-format on ); + + Matrix3d R = cinfo.second.orientation.toMatrix(); + simd4x4f rot = simd4x4f_create( + // clang-format off + simd4f_create(R(0,0), R(0,1), R(0,2), 0.f), + simd4f_create(R(1,0), R(1,1), R(1,2), 0.f), + simd4f_create(R(2,0), R(2,1), R(2,2), 0.f), + simd4f_create(0.f, 0.f, 0.f, 1.f) + // clang-format on + ); + + simd4x4f rot_scale; + simd4x4f_matrix_mul(&rot, &scale, &rot_scale); + simd4x4f_matrix_mul(&trans, &rot_scale, &rcmd.mat); srcmdbuf_add(cmdbuf, &rcmd); } } diff --git a/src/srender.h b/src/srender.h index 8be6797..004f334 100644 --- a/src/srender.h +++ b/src/srender.h @@ -554,9 +554,9 @@ void init_debug_meshes() { // gLog ("idx: %d # phi: %f, theta %f, p = %f, %f, %f", vert_index, phi * 180 / M_PI, theta * 180 / M_PI, x, y, z); srvrtxdata* vertex = &uvsphere_vertices[vert_index++]; - vertex->x = x; - vertex->y = y; - vertex->z = z; + vertex->x = x * 0.5; + vertex->y = y * 0.5; + vertex->z = z * 0.5; vertex->w = 1.0f; vertex->nx = x;