18#ifndef HEADER_SP_INSTANCED_DATA_HPP
19#define HEADER_SP_INSTANCED_DATA_HPP
21#include "mini_glm.hpp"
22#include "utils/vec3.hpp"
40 memset(m_data, 0, 44);
44 float texture_trans_x,
float texture_trans_y,
float hue,
45 short skinning_offset)
47 using namespace MiniGLM;
48 float position[3] = { model_mat[12], model_mat[13], model_mat[14] };
49 core::quaternion rotation(0.0f, 0.0f, 0.0f, 1.0f);
50 core::vector3df scale = model_mat.getScale();
51 if (scale.X != 0.0f && scale.Y != 0.0f && scale.Z != 0.0f)
53 core::matrix4 local_mat = model_mat;
54 local_mat[0] = local_mat[0] / scale.X / local_mat[15];
55 local_mat[1] = local_mat[1] / scale.X / local_mat[15];
56 local_mat[2] = local_mat[2] / scale.X / local_mat[15];
57 local_mat[4] = local_mat[4] / scale.Y / local_mat[15];
58 local_mat[5] = local_mat[5] / scale.Y / local_mat[15];
59 local_mat[6] = local_mat[6] / scale.Y / local_mat[15];
60 local_mat[8] = local_mat[8] / scale.Z / local_mat[15];
61 local_mat[9] = local_mat[9] / scale.Z / local_mat[15];
62 local_mat[10] = local_mat[10] / scale.Z / local_mat[15];
63 rotation = getQuaternion(local_mat);
65 rotation.W = -rotation.W;
67 memcpy(m_data, position, 12);
68 memcpy(m_data + 12, &rotation, 16);
69 short s[4] = { toFloat16(scale.X), toFloat16(scale.Y),
70 toFloat16(scale.Z), 0 };
71 memcpy(m_data + 28, s, 8);
74 short(texture_trans_x * 32767.0f),
75 short(texture_trans_y * 32767.0f)
77 memcpy(m_data + 36, tm, 4);
78 memcpy(m_data + 40, &skinning_offset, 2);
79 short hue_packed = short(core::clamp(
int(hue * 100.0f), 0, 100));
80 memcpy(m_data + 42, &hue_packed, 2);
83 const void* getData()
const {
return m_data; }
Definition: sp_instanced_data.hpp:32