creates a new matrix4 from translation, rotation and scale * * Creates a new matrix constructed from separate * translation vector, roation quaternion and scale vector * * @name vmath.matrix4_compose * @param translation [type:vector3|vector4] translation * @param rotation [type:quaternion] rotation * @param scale [type:vector3] scale * @return matrix [
| 2426 | * ``` |
| 2427 | */ |
| 2428 | static int Matrix4_Compose(lua_State* L) |
| 2429 | { |
| 2430 | Matrix4 translation_matrix = Matrix4::identity(); |
| 2431 | void* argument = 0; |
| 2432 | const ScriptUserType translation_type = CheckUserData(L, 1, &argument); |
| 2433 | |
| 2434 | if (translation_type == SCRIPT_TYPE_VECTOR3) |
| 2435 | { |
| 2436 | Vector3* translation = (Vector3*)argument; |
| 2437 | translation_matrix.setTranslation(*translation); |
| 2438 | } |
| 2439 | else if (translation_type == SCRIPT_TYPE_VECTOR4) |
| 2440 | { |
| 2441 | Vector4* translation = (Vector4*)argument; |
| 2442 | translation_matrix.setTranslation(translation->getXYZ()); |
| 2443 | } |
| 2444 | else |
| 2445 | { |
| 2446 | return luaL_error(L, "%s.%s accepts (%s|%s) as first argument.", SCRIPT_LIB_NAME, "matrix4_compose", |
| 2447 | SCRIPT_TYPE_NAME_VECTOR3, SCRIPT_TYPE_NAME_VECTOR4); |
| 2448 | } |
| 2449 | Matrix4 rotation_matrix = Matrix4::rotation(*CheckQuat(L, 2)); |
| 2450 | Matrix4 scale_matrix = Matrix4::scale(*CheckVector3(L, 3)); |
| 2451 | Matrix4 result = translation_matrix * rotation_matrix * scale_matrix; |
| 2452 | |
| 2453 | PushMatrix4(L, result); |
| 2454 | return 1; |
| 2455 | } |
| 2456 | |
| 2457 | /*# creates a new matrix4 from scale vector |
| 2458 | * |
nothing calls this directly
no test coverage detected