Sending full transform info (rot, scale, translation) to srender.

master
Martin Felis 2020-11-20 22:51:24 +01:00
parent 0624a7e1ac
commit e47be90fac
2 changed files with 30 additions and 7 deletions

View File

@ -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);
}
}

View File

@ -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;