Ejemplo n.º 1
0
void Terrain::RenewNodes(const vec3& viewpoint, const QuadTree<TerrainNode>::Iterator& node)
{
	//Check if this node must be enabled using morph-factor
	float sz = static_cast<float>(node.LayerSize());
	float l = node.Offset().x / sz, r = (node.Offset().x + 1) / sz;
	float u = node.Offset().y / sz, d = (node.Offset().y + 1) / sz;
	vec3 rel_pos = vec3(inverse(GetModelMatrix()) * vec4(viewpoint, 1.0f));
	rel_pos.x = ClosestSegmentPoint(rel_pos.x, l, r);
	rel_pos.y = ClosestSegmentPoint(rel_pos.y, node->heights.x, node->heights.y);
	rel_pos.z = ClosestSegmentPoint(rel_pos.z, u, d);
	if (length(rel_pos)*length(rel_pos) / 
		(1.0f + node->heights.y - node->heights.x) / 
		(r - l) / (d - u) > 5.0f || 
		node.Level() == maxLOD)
	{
		//This node is probably enabled
	}
	else
	{
		//This node is not enabled
		//continue checking its children
		DisableNodes(node);
		RenewNodes(viewpoint, node.Child(1));
		RenewNodes(viewpoint, node.Child(0));
		RenewNodes(viewpoint, node.Child(3));
		RenewNodes(viewpoint, node.Child(2));
	}
}
Ejemplo n.º 2
0
void NLight::DrawLight(NCamera* View)
{
    //Pretty standard drawing procedures, should make sense for most people.
    GenerateLightBuffers();
    if (Texture == NULL || GetColor().w == 0 || Shader == NULL)
    {
        return;
    }
    glUseProgram(Shader->GetID());
    glActiveTexture(GL_TEXTURE0);
    if (Texture != NULL)
    {
        glBindTexture(GL_TEXTURE_2D,Texture->GetID());
    }
    glUniform1i(TextureLoc,0);
    glUniformMatrix4fv(MatrixLoc,1,GL_FALSE,glm::value_ptr(GetModelMatrix()));
    glUniform4fv(ColorLoc,1,&(GetColor()[0]));
    glEnableVertexAttribArray(Shader->GetVertexAttribute());
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
    glVertexAttribPointer(Shader->GetVertexAttribute(),2,GL_FLOAT,GL_FALSE,0,NULL);
    glEnableVertexAttribArray(Shader->GetUVAttribute());
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
    glVertexAttribPointer(Shader->GetUVAttribute(),2,GL_FLOAT,GL_FALSE,0,NULL);
    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    glDrawArrays(GL_QUADS,0,Verts.size());
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    glDisableVertexAttribArray(Shader->GetVertexAttribute());
    glDisableVertexAttribArray(Shader->GetUVAttribute());
    glUseProgram(0);
}
Ejemplo n.º 3
0
void Mesh::Draw()
{
	//if(texture)texture->Bind();
	glm::mat4 model = GetModelMatrix();
	glUniformMatrix4fv(program.model, 1, GL_FALSE, glm::value_ptr(model));
	glDrawElements(GL_TRIANGLES, faces.size(), GL_UNSIGNED_SHORT, NULL);
}
Ejemplo n.º 4
0
void MeshActor::ShadowPass()
{
	// Compute the MVP matrix from the light's point of view
	glm::mat4 depthProjectionMatrix = glm::ortho<float>(-25, 25, -25, 25, -25, 25);
	glm::mat4 depthViewMatrix = glm::lookAt(scene->light, glm::vec3(0, 0, 0), glm::vec3(0, 1, 0));
	glm::mat4 depthModelMatrix = GetModelMatrix();
	glm::mat4 depthMVP = depthProjectionMatrix * depthViewMatrix * depthModelMatrix;

	// compute depthbiasMVP for actual shading step later
	depthBiasMVP = biasMatrix*depthMVP;

	if (!castsShadow) return;	//hop off here if we don't want this to cast shadows

	glUseProgram(shadowProgram);

	// set MVP in shadow shader
	GLint depthMatrixID = glGetUniformLocation(shadowProgram, "depthMVP");
	if (depthMatrixID != -1)
	{
		glUniformMatrix4fv(depthMatrixID, 1, GL_FALSE, &depthMVP[0][0]);
	}

	FreeBuffers();

	glBindVertexArray(vao);

	// set element buffer with face indices
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, elementBuffer);
	glBufferData(
		GL_ELEMENT_ARRAY_BUFFER,
		mesh.mFaces.size() * sizeof(glm::ivec3),
		mesh.mFaces.data(),
		GL_STATIC_DRAW
		);

	// set array buffer with vertex positions
	glBindBuffer(GL_ARRAY_BUFFER, vertexBuffer);
	glBufferData(
		GL_ARRAY_BUFFER,
		mesh.mVertices.size() * sizeof(glm::vec3),
		mesh.mVertices.data(),
		GL_STATIC_DRAW
		);
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL);

	// draw by index
	glDrawElements(
		GL_TRIANGLES,
		mesh.mFaces.size() * 3,
		GL_UNSIGNED_INT,
		NULL
	);

	glDisableVertexAttribArray(0);

	FreeBuffers();
}
	void Model::Draw(Shader& shader )
	{
		shader.Use();

		this->d_model_matrix = GetModelMatrix();


		/*if (m_skeleton->getNumberOfBones()>0)
		glUniformMatrix4fv (d_bone_location[0], m_skeleton->getNumberOfBones(), GL_FALSE, glm::value_ptr(m_animation_matrix[0]));*/

		shader.SetUniform("hasTexture",Has_Texture());

		for(GLuint i = 0; i < this->d_meshes.size(); i++)
			this->d_meshes[i].Draw(shader);
	}
Ejemplo n.º 6
0
void GameObject::Render(Camera *camera)
{
	if (!renderer)
		return;

	renderer->Ready();
	ShaderProgram *program = renderer->GetProgram();
	program->SetUniform("Model", value_ptr(modelMatrix));
	mat4 VP = camera->Get();
	program->SetUniform("VP", value_ptr(VP));
	mat4 MVP = VP * GetModelMatrix();
	program->SetUniform("MVP", value_ptr(MVP));

	vec3 camPos = camera->GetPos(); 
	program->SetUniform("cameraPosition", &camPos);

	vec3 lightDir = normalize(camPos - pos);
	program->SetUniform("lightDirection", &lightDir);

	vec4 ambMatColor(1, 0, 0, 1);
	program->SetUniform("ambientMaterialColor", &ambMatColor);

	vec4 difMatColor(1, 0, 0, 1); 
	program->SetUniform("diffuseMaterialColor", &difMatColor);

	vec4 specMatColor(1, 1, 1, 1);
	program->SetUniform("specularMaterialColor", &specMatColor);

	float power = 25;
	program->SetUniform("specularPower", &power);

	vec4 ambLightColor(1, 0, 0, 1);
	program->SetUniform("ambientLightColor", &ambLightColor);

	vec4 difLightColor(1, 0, 0, 1);
	program->SetUniform("diffuseLightColor", &difLightColor);

	vec4 specLightColor(1, 1, 1, 1); 
	program->SetUniform("specularLightColor", &specLightColor);

	float heightScale = 5.0f;
	program->SetUniform("heightScale", &heightScale);

	for (auto it = components.begin(); it != components.end(); it++)
		(*(it->second)).OnRender(camera);

	renderer->Render(); 
}
Ejemplo n.º 7
0
void NText::DrawMask(NCamera* View)
{
    if (GetColor().w == 0)
    {
        return;
    }
    GenerateBuffers();
    if (MaskShader == NULL)
    {
        glEnableClientState(GL_VERTEX_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER,Buffers[2]);
        glVertexPointer(2,GL_FLOAT,0,NULL);

        glMatrixMode(GL_PROJECTION);
        glLoadMatrixf(&View->GetPerspMatrix()[0][0]);
        glMatrixMode(GL_MODELVIEW);
        glm::mat4 MVP = View->GetViewMatrix();
        glLoadMatrixf(&MVP[0][0]);

        glColor4f(1,1,1,1);
        glDrawArrays(GL_QUADS,0,Mask.size());

        glDisableClientState(GL_VERTEX_ARRAY);
        return;
    }
    glUseProgram(MaskShader->GetID());
    glm::mat4 MVP = View->GetOrthoMatrix()*View->GetViewMatrix()*GetModelMatrix();
    glUniformMatrix4fv(MMatrixLoc,1,GL_FALSE,&MVP[0][0]);
    glUniform4f(MColorLoc,0,0,0,0);
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[2]);
    glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,NULL);
    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glDrawArrays(GL_QUADS,0,Mask.size());
    glDisable(GL_BLEND);

    glDisableVertexAttribArray(0);
    glUseProgram(0);
}
Ejemplo n.º 8
0
void NButton::Draw(NCamera* View)
{
    //Make sure we have our buffers generated.
    GenerateBuffers();
    //If we don't have a texture, are invisible, or our shader doesn't exist, don't draw!
    if (Texture == NULL || GetColor().w == 0 || Shader == NULL)
    {
        return;
    }
    glUseProgram(Shader->GetID());
    glActiveTexture(GL_TEXTURE0);
    //Make sure we have a texture before we try to call a member in it.
    if (Texture != NULL)
    {
        glBindTexture(GL_TEXTURE_2D,Texture->GetID());
    }
    glUniform1i(TextureLoc,0);
    //Generate our matrix to send to the GPU.
    glm::mat4 MVP = View->GetOrthoMatrix()*View->GetViewMatrix()*GetModelMatrix();
    glUniformMatrix4fv(MatrixLoc,1,GL_FALSE,&MVP[0][0]);
    glUniform4fv(ColorLoc,1,&(GetColor()[0]));
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
    glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,NULL);
    glEnableVertexAttribArray(1);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
    glVertexAttribPointer(1,2,GL_FLOAT,GL_FALSE,0,NULL);
    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    //blahblahblah and then we finally draw using the Size of the Verts array we generated in GenerateBuffers.
    glDrawArrays(GL_QUADS,0,Verts.size());
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glUseProgram(0);
}
Ejemplo n.º 9
0
void NEntity::Draw(NCamera* View)
{
    if (GetGame()->GetMap()->GetLevel() != GetGame()->GetMap()->GetLevel(GetRealPos()))
    {
        return;
    }

    GenerateBuffers();
    //Make sure we can draw
    if (Texture == NULL || GetColor().w == 0 || Shader == NULL)
    {
        return;
    }
    glUseProgram(Shader->GetID());
    glActiveTexture(GL_TEXTURE0);
    if (Texture != NULL)
    {
        glBindTexture(GL_TEXTURE_2D,Texture->GetID());
    }
    glUniform1i(TextureLoc,0);
    glUniformMatrix4fv(MatrixLoc,1,GL_FALSE,glm::value_ptr(GetModelMatrix()));
    glUniform4fv(ColorLoc,1,&(GetColor()[0]));
    glEnableVertexAttribArray(Shader->GetVertexAttribute());
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
    glVertexAttribPointer(Shader->GetVertexAttribute(),2,GL_FLOAT,GL_FALSE,0,NULL);
    glEnableVertexAttribArray(Shader->GetUVAttribute());
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
    glVertexAttribPointer(Shader->GetUVAttribute(),2,GL_FLOAT,GL_FALSE,0,NULL);
    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    glDrawArrays(GL_QUADS,0,Verts.size());
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    glDisableVertexAttribArray(Shader->GetVertexAttribute());
    glDisableVertexAttribArray(Shader->GetUVAttribute());
    glUseProgram(0);
}
Ejemplo n.º 10
0
void MeshActor::SetUniforms()
{
	// attempt setting M, V, P, VP matrices in shader
	model = GetModelMatrix();
	GLint modelMatID = glGetUniformLocation(shaderProgram, "model");
	if (modelMatID != -1)
	{
		glUniformMatrix4fv(modelMatID, 1, GL_FALSE, glm::value_ptr(model));
	}

	GLint viewMatID = glGetUniformLocation(shaderProgram, "view");
	if (viewMatID != -1)
	{
		glUniformMatrix4fv(viewMatID, 1, GL_FALSE, glm::value_ptr(scene->camera->view));
	}

	GLint projMatID = glGetUniformLocation(shaderProgram, "projection");
	if (projMatID != -1)
	{
		glUniformMatrix4fv(projMatID, 1, GL_FALSE, glm::value_ptr(scene->camera->projection));
	}

	GLint VPMatID = glGetUniformLocation(shaderProgram, "view_projection");
	if (VPMatID != -1)
	{
		glUniformMatrix4fv(VPMatID, 1, GL_FALSE, glm::value_ptr(scene->camera->VP));
	}

	GLint lightPosLocation = glGetUniformLocation(shaderProgram, "lightPos");
	if (lightPosLocation != -1)
	{
		glUniform3fv(lightPosLocation, 1, &scene->light[0]);
	}

	GLint viewPosLocation = glGetUniformLocation(shaderProgram, "viewPos");
	if (viewPosLocation != -1)
	{
		glUniform3fv(viewPosLocation, 1, &scene->camera->position[0]);
	}

	GLint useShadowLoc = glGetUniformLocation(shaderProgram, "useShadowMapping");
	if (useShadowLoc != -1)
	{
		if (isShadowed)
		{
			glUniform1i(useShadowLoc, 1);
			
		}
		else glUniform1i(useShadowLoc, 0);
	}

	GLint depthBiasLoc = glGetUniformLocation(shaderProgram, "depthBiasMVP");
	if (depthBiasLoc != -1)
	{
		glUniformMatrix4fv(depthBiasLoc, 1, GL_FALSE, glm::value_ptr(depthBiasMVP));
	}

	GLint depthTexLocation = glGetUniformLocation(shaderProgram, "shadowMap");
	if (depthTexLocation != -1)
	{
		glUniform1i(depthTexLocation, 10);
	}
}
Ejemplo n.º 11
0
void NText::DrawText(NCamera* View)
{
    if (Face == NULL || GetColor().w == 0)
    {
        return;
    }
    GenerateBuffers();
    if (Shader == NULL)
    {
        glEnableClientState(GL_VERTEX_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
        glVertexPointer(2,GL_FLOAT,0,NULL);

        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
        glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
        glTexCoordPointer(2,GL_FLOAT,0,NULL);

        glEnable(GL_TEXTURE_2D);
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glBindTexture(GL_TEXTURE_2D,Face->GetTexture(Size));

        glMatrixMode(GL_PROJECTION);
        glLoadMatrixf(&View->GetOrthoMatrix()[0][0]);
        glMatrixMode(GL_MODELVIEW);
        glm::mat4 MVP = View->GetViewMatrix()*GetModelMatrix();
        glLoadMatrixf(&MVP[0][0]);

        glColor4fv(&(GetColor()[0]));
        glDrawArrays(GL_QUADS,0,Verts.size());
        glDisable(GL_TEXTURE_2D);
        glDisable(GL_BLEND);

        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        return;
    }
    glUseProgram(Shader->GetID());
    glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D,Face->GetTexture(Size));
    glUniform1i(TextureLoc,0);
    glm::mat4 MVP;
    if (!Persp)
    {
        MVP = View->GetOrthoMatrix()*View->GetViewMatrix()*GetModelMatrix();
    } else {
        MVP = View->GetPerspMatrix()*View->GetPerspViewMatrix()*GetModelMatrix();
    }
    glUniformMatrix4fv(MatrixLoc,1,GL_FALSE,&MVP[0][0]);
    glUniform4fv(ColorLoc,1,&(GetColor()[0]));
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[0]);
    glVertexAttribPointer(0,2,GL_FLOAT,GL_FALSE,0,NULL);
    glEnableVertexAttribArray(1);
    glBindBuffer(GL_ARRAY_BUFFER,Buffers[1]);
    glVertexAttribPointer(1,2,GL_FLOAT,GL_FALSE,0,NULL);
    
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_TEXTURE_2D);
    glDrawArrays(GL_QUADS,0,Verts.size());
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);

    glDisableVertexAttribArray(0);
    glDisableVertexAttribArray(1);
    glUseProgram(0);
}
Ejemplo n.º 12
0
/////////////////////////////////////////////////////////////////////
//USAGE: Determines the collision with an incoming object using the SAT
// ARGUMENTS :
//- MyBOClass* const a_pOther->Other object to check collision with
//OUTPUT : result of the collision
/////////////////////////////////////////////////////////////////////
bool MyBOClass::SAT(MyBOClass* const a_pOther)
{
	// Get the information of this object
	vector3 v3CenterGlobalA = GetCenterGlobal();
	matrix4 mToWorldA = GetModelMatrix();
	vector3 v3RotationA[3];
	v3RotationA[0] = vector3(mToWorldA[0][0], mToWorldA[0][1], mToWorldA[0][2]);
	v3RotationA[1] = vector3(mToWorldA[1][0], mToWorldA[1][1], mToWorldA[1][2]);
	v3RotationA[2] = vector3(mToWorldA[2][0], mToWorldA[2][1], mToWorldA[2][2]);

	//Get the information of the other object
	vector3 v3CenterGlobalB = a_pOther->GetCenterGlobal();
	matrix4 mToWorldB = a_pOther->GetModelMatrix();
	vector3 v3RotationB[3];
	v3RotationB[0] = vector3(mToWorldB[0][0], mToWorldB[0][1], mToWorldB[0][2]);
	v3RotationB[1] = vector3(mToWorldB[1][0], mToWorldB[1][1], mToWorldB[1][2]);
	v3RotationB[2] = vector3(mToWorldB[2][0], mToWorldB[2][1], mToWorldB[2][2]);

	float fCenterAToMiddle, fCenterBToMiddle;
	glm::mat3 m3Rotation, m3RotationAbs;

	// Compute rotation matrix expressing b in a's coordinate frame
	for (int i = 0; i < 3; i++)
	for (int j = 0; j < 3; j++)
		m3Rotation[i][j] = glm::dot(v3RotationA[i], v3RotationB[j]);

	// Compute translation vector v3Distance (this is the distance between both centers)
	vector3 v3Distance = v3CenterGlobalB - v3CenterGlobalA; //distance in global space
	// Bring translation into a's coordinate frame
	v3Distance = vector3(glm::dot(v3Distance, v3RotationA[0]), glm::dot(v3Distance, v3RotationA[1]), glm::dot(v3Distance, v3RotationA[2])); //distance in A's local
	// their cross product is (near) null (see the orange book for details)
	for (int i = 0; i < 3; i++)
	for (int j = 0; j < 3; j++)
		m3RotationAbs[i][j] = std::abs(m3Rotation[i][j]) + 0.0001f;

	// Test axes L = AX <- 0
	fCenterAToMiddle = m_v3HalfWidth.x;
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[0][0] + a_pOther->m_v3HalfWidth.y * m3RotationAbs[0][1] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[0][2];
	if (std::abs(v3Distance.x) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center;
		matrix4 m4WorldToLocal = glm::inverse(m_m4ToWorld);
		if (m_v3CenterG.x < a_pOther->m_v3CenterG.x)
		{
			vector3 v3OtherMinInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MinG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MaxG, 1.0f)) + v3OtherMinInA;
		}
		else
		{
			vector3 v3OtherMaxInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MaxG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MinG, 1.0f)) + v3OtherMaxInA;
		}
		v3Center /= 2.0f;

		matrix4 m4Space = glm::translate(m_m4ToWorld, v3Center) * glm::rotate(IDENTITY_M4, 90.0f, REAXISY);
		m_pMeshMngr->AddPlaneToQueue(m4Space * glm::scale(vector3(5.0f)), RERED);
#endif
		return false;
	}

	// Test axes L = AY <- 1
	fCenterAToMiddle = m_v3HalfWidth.y;
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[1][0] + a_pOther->m_v3HalfWidth.y * m3RotationAbs[1][1] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[1][2];
	if (std::abs(v3Distance.y) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center;
		matrix4 m4WorldToLocal = glm::inverse(m_m4ToWorld);
		if (m_v3CenterG.y < a_pOther->m_v3CenterG.y)
		{
			vector3 v3OtherMinInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MinG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MaxG, 1.0f)) + v3OtherMinInA;
		}
		else
		{
			vector3 v3OtherMaxInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MaxG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MinG, 1.0f)) + v3OtherMaxInA;
		}
		v3Center /= 2.0f;
		matrix4 m4Space = glm::translate(m_m4ToWorld, v3Center) * glm::rotate(IDENTITY_M4, 90.0f, REAXISX);
		m_pMeshMngr->AddPlaneToQueue(m4Space * glm::scale(vector3(5.0f)), REGREEN);
#endif
		return false;
	}

	// Test axes L = AZ <- 2
	fCenterAToMiddle = m_v3HalfWidth.z;
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[2][0] + a_pOther->m_v3HalfWidth.y * m3RotationAbs[2][1] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[2][2];
	if (std::abs(v3Distance.z) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center;
		matrix4 m4WorldToLocal = glm::inverse(m_m4ToWorld);
		if (m_v3CenterG.z < a_pOther->m_v3CenterG.z)
		{
			vector3 v3OtherMinInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MinG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MaxG, 1.0f)) + v3OtherMinInA;
		}
		else
		{
			vector3 v3OtherMaxInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MaxG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MinG, 1.0f)) + v3OtherMaxInA;
		}
		v3Center /= 2.0f;
		matrix4 m4Space = glm::translate(m_m4ToWorld, v3Center);
		m_pMeshMngr->AddPlaneToQueue(m4Space * glm::scale(vector3(5.0f)), REBLUE);
#endif
		return false;
	}

	// Test axes L = BX <- 3
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[0][0] + m_v3HalfWidth.y * m3RotationAbs[1][0] + m_v3HalfWidth.z * m3RotationAbs[2][0];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x;
	if (std::abs(v3Distance.x * m3Rotation[0][0] + v3Distance.y * m3Rotation[1][0] + v3Distance.z * m3Rotation[2][0]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		matrix4 m4Space = glm::translate(IDENTITY_M4, a_pOther->m_v3CenterG) * glm::rotate(IDENTITY_M4, 90.0f, REAXISY);
		m_pMeshMngr->AddPlaneToQueue(m4Space * glm::scale(vector3(5.0f)), RERED * 0.33f);
#endif
		return false;
	}

	// Test axes L = BY <- 4
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[0][1] + m_v3HalfWidth.y * m3RotationAbs[1][1] + m_v3HalfWidth.z * m3RotationAbs[2][1];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.y;
	if (std::abs(v3Distance.x * m3Rotation[0][1] + v3Distance.y * m3Rotation[1][1] + v3Distance.z * m3Rotation[2][1]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		matrix4 m4Space = glm::translate(IDENTITY_M4, a_pOther->m_v3CenterG) * glm::rotate(IDENTITY_M4, 90.0f, REAXISX);
		m_pMeshMngr->AddPlaneToQueue(m4Space * glm::scale(vector3(5.0f)), REGREEN * 0.33f);
#endif
		return false;
	}

	// Test axes L = BZ <- 5
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[0][2] + m_v3HalfWidth.y * m3RotationAbs[1][2] + m_v3HalfWidth.z * m3RotationAbs[2][2];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.z;
	if (std::abs(v3Distance.x * m3Rotation[0][2] + v3Distance.y * m3Rotation[1][2] + v3Distance.z * m3Rotation[2][2]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		matrix4 m4Space = glm::translate(IDENTITY_M4, a_pOther->m_v3CenterG);
		m_pMeshMngr->AddPlaneToQueue(m4Space * glm::scale(vector3(5.0f)), REBLUE * 0.33f);
#endif
		return false;
	}

	// Test axis L = AX x BX <- 6
	fCenterAToMiddle = m_v3HalfWidth.y * m3RotationAbs[2][0] + m_v3HalfWidth.z * m3RotationAbs[1][0];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.y * m3RotationAbs[0][2] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[0][1];
	if (std::abs(v3Distance.z * m3Rotation[1][0] - v3Distance.y * m3Rotation[2][0]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center;
		matrix4 m4WorldToLocal = glm::inverse(m_m4ToWorld);
		if (m_v3CenterG.z < a_pOther->m_v3CenterG.z)
		{
			vector3 v3OtherMinInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MinG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MaxG, 1.0f)) + v3OtherMinInA;
		}
		else
		{
			vector3 v3OtherMaxInA = vector3(m4WorldToLocal * vector4(a_pOther->m_v3MaxG, 1.0f));
			v3Center = vector3(m4WorldToLocal * vector4(m_v3MinG, 1.0f)) + v3OtherMaxInA;
		}
		v3Center /= 2.0f;
		matrix4 m4Space = glm::translate(m_m4ToWorld, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AX x BY <- 7
	fCenterAToMiddle = m_v3HalfWidth.y * m3RotationAbs[2][1] + m_v3HalfWidth.z * m3RotationAbs[1][1];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[0][2] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[0][0];
	if (std::abs(v3Distance.z * m3Rotation[1][1] - v3Distance.y * m3Rotation[2][1]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AX x BZ <- 8
	fCenterAToMiddle = m_v3HalfWidth.y * m3RotationAbs[2][2] + m_v3HalfWidth.z * m3RotationAbs[1][2];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[0][1] + a_pOther->m_v3HalfWidth.y * m3RotationAbs[0][0];
	if (std::abs(v3Distance.z * m3Rotation[1][2] - v3Distance.y * m3Rotation[2][2]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AY x BX <- 9
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[2][0] + m_v3HalfWidth.z * m3RotationAbs[0][0];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.y * m3RotationAbs[1][2] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[1][1];
	if (std::abs(v3Distance.x * m3Rotation[2][0] - v3Distance.z * m3Rotation[0][0]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AY x BY <- 10
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[2][1] + m_v3HalfWidth.z * m3RotationAbs[0][1];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[1][2] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[1][0];
	if (std::abs(v3Distance.x * m3Rotation[2][1] - v3Distance.z * m3Rotation[0][1]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AY x BZ <- 11
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[2][2] + m_v3HalfWidth.z * m3RotationAbs[0][2];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[1][1] + a_pOther->m_v3HalfWidth.y * m3RotationAbs[1][0];
	if (std::abs(v3Distance.x * m3Rotation[2][2] - v3Distance.z * m3Rotation[0][2]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AZ x BX <- 12
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[1][0] + m_v3HalfWidth.y * m3RotationAbs[0][0];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.y * m3RotationAbs[2][2] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[2][1];
	if (std::abs(v3Distance.y * m3Rotation[0][0] - v3Distance.x * m3Rotation[1][0]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AZ x BY <- 13
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[1][1] + m_v3HalfWidth.y * m3RotationAbs[0][1];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[2][2] + a_pOther->m_v3HalfWidth.z * m3RotationAbs[2][0];
	if (std::abs(v3Distance.y * m3Rotation[0][1] - v3Distance.x * m3Rotation[1][1]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Test axis L = AZ x BZ <- 14
	fCenterAToMiddle = m_v3HalfWidth.x * m3RotationAbs[1][2] + m_v3HalfWidth.y * m3RotationAbs[0][2];
	fCenterBToMiddle = a_pOther->m_v3HalfWidth.x * m3RotationAbs[2][1] + a_pOther->m_v3HalfWidth.y * m3RotationAbs[2][0];
	if (std::abs(v3Distance.y * m3Rotation[0][2] - v3Distance.x * m3Rotation[1][2]) > fCenterAToMiddle + fCenterBToMiddle)
	{
#ifdef SHOWPLANES
		vector3 v3Center = (m_v3CenterG + a_pOther->m_v3CenterG) / 2.0f;
		matrix4 m4Space = glm::translate(IDENTITY_M4, v3Center);
		m_pMeshMngr->AddSphereToQueue(m4Space * glm::scale(vector3(0.10f)), REYELLOW, SOLID);
#endif
		return false;
	}

	// Since no separating axis found, the OBBs must a_pOther->m_v3HalfWidth intersecting
	return true;
}