コード例 #1
0
//----------------------------------------------------------------------------------
//
//----------------------------------------------------------------------------------
void ManagerImplemented::CalcCulling( const Matrix44& cameraProjMat, bool isOpenGL)
{
	if(m_cullingWorld == NULL) return;

	m_culledObjects.clear();
	m_culledObjectSets.clear();
	
	Matrix44 mat = cameraProjMat;
	mat.Transpose();

	Culling3D::Matrix44* mat_ = (Culling3D::Matrix44*)(&mat);

	m_cullingWorld->Culling(*mat_, isOpenGL);

	for(int32_t i = 0; i < m_cullingWorld->GetObjectCount(); i++)
	{
		Culling3D::Object* o = m_cullingWorld->GetObject(i);
		DrawSet* ds = (DrawSet*)o->GetUserData();

		m_culledObjects.push_back(ds);
		m_culledObjectSets.insert(ds->Self);
	}

	m_culled = true;
}
コード例 #2
0
/// Get the inverse of this matrix.
///
/// @param[out] rMatrix  Matrix inverse.
///
/// @see Invert()
void Helium::Simd::Matrix44::GetInverse( Matrix44& rMatrix ) const
{
    Register invDeterminant, detSubmat33;
    DeterminantHelper( m_matrix, invDeterminant, detSubmat33 );

    invDeterminant = Simd::InverseF32( invDeterminant );

    rMatrix.m_matrix = Simd::MultiplyF32( detSubmat33, invDeterminant );

    rMatrix.Transpose();
}
コード例 #3
0
ファイル: 01_Math.cpp プロジェクト: souxiaosou/aether3d
void TestMatrixTranspose()
{
    Matrix44 matrix;
    const float exceptedResult = 42;
    matrix.m[ 3 ] = exceptedResult;
    matrix.Transpose( matrix );
    
    if (matrix.m[ 3 * 4 ] != exceptedResult)
    {
        std::cerr << "Matrix transpose failed!" << std::endl;
    }
}
コード例 #4
0
ファイル: Matrix.cpp プロジェクト: souxiaosou/aether3d
void Matrix44::Invert( const Matrix44& matrix, Matrix44& out )
{
    float invTrans[ 16 ];
    InverseTranspose( matrix.m, invTrans );
    Matrix44 iTrans;
    iTrans.InitFrom( invTrans );
    iTrans.Transpose( out );
    
#if DEBUG
    ae3d::CheckNaN( out );
#endif
}
コード例 #5
0
ファイル: MathDef.cpp プロジェクト: mavaL/NeoEngine
	Common::Plane Transform_Plane_By_Mat44(const Plane& plane, const Matrix44& mat)
	{
		Vector4 v(plane.n, plane.d);

		// To transform normal, we can not use the matrix directly
		// See: http://www.songho.ca/opengl/gl_normaltransform.html
		Matrix44 matInvTranspose = mat.Inverse();
		matInvTranspose.Transpose();

		v = Common::Transform_Vec4_By_Mat44(v, matInvTranspose);

		Plane ret;
		ret.n = v.GetVec3();
		ret.d = v.w / ret.n.Normalize();

		return ret;
	}
コード例 #6
0
ファイル: mesh.cpp プロジェクト: gdijaejung/Common
void cMesh::RenderShadow(cRenderer &renderer, cShader &shader, const Matrix44 &parentTm)
{
	RET(!IsRender());
	RET(!m_buffers);

	if (m_buffers->GetAttributes().empty())
	{
		const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		shader.SetMatrix("mWorld", tm);

		Matrix44 wit = tm.Inverse();
		wit.Transpose();
		shader.SetMatrix("mWIT", wit);

		//const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		//shader.SetMatrix("mWorld", tm);
		//Matrix44 wit = tm.Inverse();
		//wit.Transpose();
		//shader.SetMatrix("mWIT", wit);
		//if (!m_mtrls.empty())
		//	m_mtrls[ 0].Bind(shader);
		//if (!m_textures.empty())
		//	m_textures[ 0]->Bind(shader, "colorMapTexture");

		m_buffers->Bind(renderer);

		shader.Begin();
		shader.BeginPass();

		renderer.GetDevice()->DrawIndexedPrimitive( 
			D3DPT_TRIANGLELIST, 0, 0, 
			m_buffers->GetVertexBuffer().GetVertexCount(), 0, 
			m_buffers->GetIndexBuffer().GetFaceCount());

		shader.End();
		shader.EndPass();
	}
	else
	{
		const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		shader.SetMatrix("mWorld", tm);

		Matrix44 wit = tm.Inverse();
		wit.Transpose();
		shader.SetMatrix("mWIT", wit);

		//const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		//shader.SetMatrix("mWorld", tm);
		//Matrix44 wit = tm.Inverse();
		//wit.Transpose();
		//shader.SetMatrix("mWIT", wit);

		shader.Begin();
		m_buffers->Bind(renderer);
		//m_vtxBuff.Bind();
		//m_idxBuff.Bind();

		for (u_int i=0; i < m_buffers->GetAttributes().size(); ++i)
		{
			const int mtrlId = m_buffers->GetAttributes()[ i].attribId;
			if ((int)m_mtrls.size() <= mtrlId)
				continue;

			//m_mtrls[ mtrlId].Bind(shader);
			//if (m_textures[ mtrlId])
			//	m_textures[ mtrlId]->Bind(shader, "colorMapTexture");

			shader.BeginPass();

			renderer.GetDevice()->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 
				m_buffers->GetVertexBuffer().GetVertexCount(), 
				m_buffers->GetAttributes()[ i].faceStart*3, 
				m_buffers->GetAttributes()[ i].faceCount);

			shader.EndPass();
		}

		shader.End();
	}
}
コード例 #7
0
ファイル: mesh.cpp プロジェクト: gdijaejung/Common
// 그림자 출력.
void cMesh::RenderShadow(cRenderer &renderer, const Matrix44 &viewProj,
	const Vector3 &lightPos, const Vector3 &lightDir, const Matrix44 &parentTm)
{
	RET(!IsRender());
	RET(!m_shader);
	RET(!m_buffers);

	const cLight &mainLight = cLightManager::Get()->GetMainLight();
	mainLight.Bind(*m_shader);

	m_shader->SetMatrix( "mVP", viewProj);
	m_shader->SetVector( "vEyePos", lightPos);

	if (m_buffers->GetAttributes().empty())
	{
		const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		m_shader->SetMatrix("mWorld", tm);

		Matrix44 wit = tm.Inverse();
		wit.Transpose();
		m_shader->SetMatrix("mWIT", wit);

		m_buffers->Bind(renderer);

		m_shader->Begin();
		m_shader->BeginPass(1);

		renderer.GetDevice()->DrawIndexedPrimitive(
			D3DPT_TRIANGLELIST, 0, 0, 
			m_buffers->GetVertexBuffer().GetVertexCount(), 0, 
			m_buffers->GetIndexBuffer().GetFaceCount());

		m_shader->End();
		m_shader->EndPass();
	}
	else
	{
		const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		m_shader->SetMatrix("mWorld", tm);

		Matrix44 wit = tm.Inverse();
		wit.Transpose();
		m_shader->SetMatrix("mWIT", wit);

		m_shader->Begin();

		m_buffers->Bind(renderer);

		for (u_int i=0; i < m_buffers->GetAttributes().size(); ++i)
		{
			const int mtrlId = m_buffers->GetAttributes()[ i].attribId;
			if ((int)m_mtrls.size() <= mtrlId)
				continue;

			m_shader->BeginPass(1);

			renderer.GetDevice()->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0,
				m_buffers->GetVertexBuffer().GetVertexCount(), 
				m_buffers->GetAttributes()[ i].faceStart*3, 
				m_buffers->GetAttributes()[ i].faceCount);

			m_shader->EndPass();
		}

		m_shader->End();
	}

}
コード例 #8
0
ファイル: mesh.cpp プロジェクト: gdijaejung/Common
// 셰이더를 통해 화면을 그린다.
void cMesh::RenderShader(cRenderer &renderer, cShader &shader, const Matrix44 &parentTm)
{
	RET(!IsRender());
	RET(!m_buffers);

	const cLight &mainLight = cLightManager::Get()->GetMainLight();
	mainLight.Bind(shader);

	shader.SetMatrix( "mVP", cMainCamera::Get()->GetViewProjectionMatrix());
	shader.SetVector( "vEyePos", cMainCamera::Get()->GetEyePos());

	if (m_buffers->GetAttributes().empty())
	{
		const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		shader.SetMatrix("mWorld", tm);
		
		Matrix44 wit = tm.Inverse();
		wit.Transpose();
		shader.SetMatrix("mWIT", wit);

		const bool isNormalMapping = (!m_normalMap.empty()) && 
			(m_normalMap[ 0] && m_normalMap[ 0]->GetTexture());

		const bool isSpecularMapping = (!m_specularMap.empty()) && 
			(m_specularMap[ 0] && m_specularMap[ 0]->GetTexture());

		const bool isSelfIllumMapping = (!m_selfIllumMap.empty()) && 
			(m_selfIllumMap[ 0] && m_selfIllumMap[ 0]->GetTexture());

		if (!m_mtrls.empty())
			m_mtrls[ 0].Bind(shader);
		if (!m_colorMap.empty())
			m_colorMap[ 0]->Bind(shader, "colorMapTexture");
		if (isNormalMapping)
			m_normalMap[ 0]->Bind(shader, "normalMapTexture");
		if (isSpecularMapping)
			m_specularMap[ 0]->Bind(shader, "specularMapTexture");
		if (isSelfIllumMapping)
			m_selfIllumMap[ 0]->Bind(shader, "selfIllumMapTexture");

		shader.SetRenderPass(isNormalMapping? 4 : 0);

		m_buffers->Bind(renderer);

		shader.Begin();
		shader.BeginPass();

		renderer.GetDevice()->DrawIndexedPrimitive( 
			D3DPT_TRIANGLELIST, 0, 0, 
			m_buffers->GetVertexBuffer().GetVertexCount(), 0, 
			m_buffers->GetIndexBuffer().GetFaceCount());

		shader.End();
		shader.EndPass();
	}
	else
	{
		const Matrix44 tm = m_localTM * m_aniTM * m_TM * parentTm;
		shader.SetMatrix("mWorld", tm);

		Matrix44 wit = tm.Inverse();
		wit.Transpose();
		shader.SetMatrix("mWIT", wit);

		shader.Begin();

		m_buffers->Bind(renderer);

		for (u_int i=0; i < m_buffers->GetAttributes().size(); ++i)
		{
			const int mtrlId = m_buffers->GetAttributes()[ i].attribId;
			if ((int)m_mtrls.size() <= mtrlId)
				continue;

			const bool isNormalMapping = m_normalMap[ mtrlId] && 
				m_normalMap[ mtrlId]->GetTexture();

			const bool isSpecularMapping = m_specularMap[ mtrlId] && 
				m_specularMap[ mtrlId]->GetTexture();

			const bool isSelfIllumMapping = m_selfIllumMap[ mtrlId] && 
				m_selfIllumMap[ mtrlId]->GetTexture();

			m_mtrls[ mtrlId].Bind(shader);
			if (m_colorMap[ mtrlId])
				m_colorMap[ mtrlId]->Bind(shader, "colorMapTexture");
			if (isNormalMapping)
				m_normalMap[ mtrlId]->Bind(shader, "normalMapTexture");
			if (isSpecularMapping)
				m_specularMap[ mtrlId]->Bind(shader, "specularMapTexture");
			if (isSelfIllumMapping)
				m_selfIllumMap[ mtrlId]->Bind(shader, "selfIllumMapTexture");

			shader.SetRenderPass(isNormalMapping? 4 : 0);

			shader.BeginPass();

			renderer.GetDevice()->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, 
				m_buffers->GetVertexBuffer().GetVertexCount(), 
				m_buffers->GetAttributes()[ i].faceStart*3, 
				m_buffers->GetAttributes()[ i].faceCount);

			shader.EndPass();
		}

		shader.End();
	}
}
コード例 #9
0
ファイル: Vec4.cpp プロジェクト: hsdxpro/ExcessiveTeam
Vec4 operator*(Matrix44 m, const Vec4& v) {
	m.Transpose();
	return v*m;
}