🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

DirectxTK, FrustumcuLL and BoundingBox

Started by
1 comment, last by MJP 2 years, 5 months ago

Hi Guys!

I am using directxTK's frustum and Bundingbox APIs.

I am Initializing Frustum with

m_FrustumDefault = BoundingFrustum(Projection);

where

Projection = XMMatrixPerspectiveFovLH(XM_PIDIV4, m_aspectRatio, 0.1f, 10000.0f)

I am using Assimp to load FBX model with meshes in hierarchy, I am also transforming viertices manually instead of aiProcess_PreTransformVertices. Like …


//transforming boudingboxes
	aiVector3D vmin = matrix * mesh->mAABB.mMin;
	aiVector3D vmax = matrix * mesh->mAABB.mMax;
	
	//transforming vertices
for (UINT i = 0; i < mesh->mNumVertices; i++)
	{
		VERTEX vertex;
		mesh->mVertices[i] = matrix * mesh->mVertices[i];
		vertex.Position.x = mesh->mVertices[i].x;
		vertex.Position.y = mesh->mVertices[i].y;
		vertex.Position.z = mesh->mVertices[i].z;
		vertex.Position.w = 1.0f;
		...

and

void DX12Model::processNode(aiNode* node, const aiScene* scene)
{
	for (UINT i = 0; i < node->mNumMeshes; i++)
	{
		aiMesh* mesh = scene->mMeshes[node->mMeshes[i]];
		m_Meshes.push_back(this->processMesh(mesh, scene, node->mTransformation));
	}

	for (UINT i = 0; i < node->mNumChildren; i++)
	{
		node->mChildren[i]->mTransformation = node->mChildren[i]->mParent->mTransformation * node->mChildren[i]->mTransformation;
		this->processNode(node->mChildren[i], scene);
	}
}

I am also updating frustum with ViewMatrix …

	m_FrustumDefault.Transform(m_Frustum, GetViewMatrix());

where m_FrustumDefault is default frustum with projection matrix only.

and i return

m_Frustum

How should i frustum Cull these Bounding Boxes …

i Am not able to get good result from Contain and Intersect mathod of directxTK, should i transform Bounding box with WorldViewProjection matrix.

thanks…

Advertisement

You want to transform the frustum by the camera's transformation matrix, not the view matrix. The view matrix is the inverse of the camera's transform matrix: the camera's transform goes from camera-local space to world space, while the view matrix does the opposite.

This topic is closed to new replies.

Advertisement