I thought about doing distance between MVP / View Matrix and Model and if it's equal to "0 + scale" / "0 - scale" it's overlapping.

but somehow it doesn't work...

Camera Update Source:

Code :

void Camera::Update(glm::vec3 const& Cube_scale,
glm::vec3 const& Cube_position)
{
Camera::computeMatricesFromInputs();
glm::mat4 Model = glm::mat4();
Model = glm::scale(Model, Cube_scale);
Model = glm::translate(Model, Cube_position);
glm::mat4 mvp = ProjectionMatrix * ViewMatrix * Model;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &mvp[0][0]);
// Overlap Detection - will moved to function
float dist = Distance3D(Model[3][0], mvp[3][0], Model[3][1], mvp[3][1], Model[3][2], mvp[3][2]);
std::cout << dist << std::endl;
}

but the values aren't correct.

by the way, I've seen something about "extracting" translation from matrices, so i guess i need to do something with that, but not sure how.

can anyone direct me to the correct path ? or give me an example ? ( it would be great ). ]]>

I am making some custom matrices with some initial instruction on the Opengl thread. Its mostly turned into a math issue, so I've placed the question here; hope that's ok. My goal was to make the Euler rotational matrices "by hand" which took some additional internet research. In most of the three Euler angle matrices, the matrix only produces identical GLM results if the "-" in front of the sine fx is

Code :

glm::mat4 rotx(float a) {
float s = std::sin(a);
float c = std::cos(a);
return glm::mat4(
1.0f,0.0f,0.0f,0.0f,
0.0f, c, -s, 0.0f,
0.0f, s, c, 0.0f,
0.0f,0.0f,0.0f,1.0f );
}
glm::mat4 roty(float a) {
float s = std::sin(a);
float c = std::cos(a);
return glm::mat4(
c, 0.0f, s, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
-s, 0.0f, c, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
};
glm::mat4 rotz(float a) {
float s = std::sin(a);
float c = std::cos(a);
return glm::mat4(
c,-s,0.0f,0.0f,
s,c,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f );
};

GLM result:

Rotate vector custom fx on x axis:vec4(4.000000, -5.156932, 5.865666, 1.000000)

Rotate vector by GLM on x axis: vec4(4.000000, 6.699447, -4.014649, 1.000000)

Rotate vector custom fx on y axis:vec4(6.545196, 5.000000, -3.026618, 1.000000)

Rotate vector by GLM on y axis: vec4(-5.311184, 5.000000, 4.877635, 1.000000)

Rotate vector custom fx on z axis:vec4(-4.323152, 4.723384, 6.000000, 1.000000)

Rotate vector by GLM on y axis: vec4(5.557164, -3.180869, 6.000000, 1.000000)

If I swap minus sign positions, GLM compares nicely.

Code :

glm::mat4 rotx(float a) {
float s = std::sin(a);
float c = std::cos(a);
return glm::mat4(
1.0f,0.0f,0.0f,0.0f,
0.0f, c, s, 0.0f,
0.0f, -s, c, 0.0f,
0.0f,0.0f,0.0f,1.0f );
}
glm::mat4 roty(float a) {
float s = std::sin(a);
float c = std::cos(a);
return glm::mat4(
c, 0.0f, -s, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
s, 0.0f, c, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f);
};
glm::mat4 rotz(float a) {
float s = std::sin(a);
float c = std::cos(a);
return glm::mat4(
c,s,0.0f,0.0f,
-s,c,0.0f,0.0f,
0.0f,0.0f,1.0f,0.0f,
0.0f,0.0f,0.0f,1.0f );
};

Rotate vector custom fx on x axis:vec4(4.000000, 6.699447, -4.014649, 1.000000)

Rotate vector by GLM on x axis: vec4(4.000000, 6.699447, -4.014649, 1.000000)

Rotate vector custom fx on y axis:vec4(-5.311184, 5.000000, 4.877635, 1.000000)

Rotate vector by GLM on y axis: vec4(-5.311184, 5.000000, 4.877635, 1.000000)

Rotate vector custom fx on z axis:vec4(5.557164, -3.180869, 6.000000, 1.000000)

Rotate vector by GLM on y axis: vec4(5.557164, -3.180869, 6.000000, 1.000000) ]]>