Ejemplo n.º 1
0
void NzGenerateBox(const NzVector3f& lengths, const NzVector3ui& subdivision, const NzMatrix4f& matrix, const NzRectf& textureCoords, NzMeshVertex* vertices, NzIndexIterator indices, NzBoxf* aabb, unsigned int indexOffset)
{
	unsigned int xIndexCount, yIndexCount, zIndexCount;
	unsigned int xVertexCount, yVertexCount, zVertexCount;

	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount);
	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount);
	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision.x, subdivision.y), &zIndexCount, &zVertexCount);

	NzMatrix4f transform;
	NzVector3f halfLengths = lengths/2.f;

	// Face +X
	transform.MakeTransform(NzVector3f::UnitX() * halfLengths.x, NzEulerAnglesf(-90.f, 0.f, -90.f));
	NzGeneratePlane(NzVector2ui(subdivision.z, subdivision.y), NzVector2f(lengths.z, lengths.y), NzMatrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertices, indices, nullptr, indexOffset);
	indexOffset += xVertexCount;
	indices += xIndexCount;
	vertices += xVertexCount;

	// Face +Y
	transform.MakeTransform(NzVector3f::UnitY() * halfLengths.y, NzEulerAnglesf(0.f, 0.f, 0.f));
	NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), NzVector2f(lengths.x, lengths.z), NzMatrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertices, indices, nullptr, indexOffset);
	indexOffset += yVertexCount;
	indices += yIndexCount;
	vertices += yVertexCount;

	// Face +Z
	transform.MakeTransform(NzVector3f::UnitZ() * halfLengths.z, NzEulerAnglesf(-90.f, 90.f, 90.f));
	NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), NzVector2f(lengths.x, lengths.y), NzMatrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertices, indices, nullptr, indexOffset);
	indexOffset += zVertexCount;
	indices += zIndexCount;
	vertices += zVertexCount;

	// Face -X
	transform.MakeTransform(-NzVector3f::UnitX() * halfLengths.x, NzEulerAnglesf(-90.f, 0.f, 90.f));
	NzGeneratePlane(NzVector2ui(subdivision.z, subdivision.y), NzVector2f(lengths.z, lengths.y), NzMatrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertices, indices, nullptr, indexOffset);
	indexOffset += xVertexCount;
	indices += xIndexCount;
	vertices += xVertexCount;

	// Face -Y
	transform.MakeTransform(-NzVector3f::UnitY() * halfLengths.y, NzEulerAnglesf(0.f, 0.f, 180.f));
	NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.z), NzVector2f(lengths.x, lengths.z), NzMatrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertices, indices, nullptr, indexOffset);
	indexOffset += yVertexCount;
	indices += yIndexCount;
	vertices += yVertexCount;

	// Face -Z
	transform.MakeTransform(-NzVector3f::UnitZ() * halfLengths.z, NzEulerAnglesf(-90.f, -90.f, 90.f));
	NzGeneratePlane(NzVector2ui(subdivision.x, subdivision.y), NzVector2f(lengths.x, lengths.y), NzMatrix4f::ConcatenateAffine(matrix, transform), textureCoords, vertices, indices, nullptr, indexOffset);
	indexOffset += zVertexCount;
	indices += zIndexCount;
	vertices += zVertexCount;

	if (aabb)
	{
		aabb->Set(-halfLengths, halfLengths);
		aabb->Transform(matrix, false);
	}
}
Ejemplo n.º 2
0
void NzComputeBoxIndexVertexCount(const NzVector3ui& subdivision, unsigned int* indexCount, unsigned int* vertexCount)
{
	unsigned int xIndexCount, yIndexCount, zIndexCount;
	unsigned int xVertexCount, yVertexCount, zVertexCount;

	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision.y, subdivision.z), &xIndexCount, &xVertexCount);
	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision.x, subdivision.z), &yIndexCount, &yVertexCount);
	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision.x, subdivision.y), &zIndexCount, &zVertexCount);

	if (indexCount)
		*indexCount = xIndexCount*2 + yIndexCount*2 + zIndexCount*2;

	if (vertexCount)
		*vertexCount = xVertexCount*2 + yVertexCount*2 + zVertexCount*2;
}
Ejemplo n.º 3
0
void NzComputeCubicSphereIndexVertexCount(unsigned int subdivision, unsigned int* indexCount, unsigned int* vertexCount)
{
	// Comme tous nos plans sont identiques, on peut optimiser un peu
	NzComputePlaneIndexVertexCount(NzVector2ui(subdivision), indexCount, vertexCount);

	if (indexCount)
		*indexCount *= 6;

	if (vertexCount)
		*vertexCount *= 6;
}
void NzDeferredRenderTechnique::SetPass(nzRenderPassType relativeTo, int position, NzDeferredRenderPass* pass)
{
	if (pass)
	{
		pass->Initialize(this);
		if (m_GBufferSize != NzVector2ui(0U))
			pass->Resize(m_GBufferSize);

		m_passes[relativeTo][position].reset(pass);
	}
	else
		m_passes[relativeTo].erase(position);
}
NzVector2ui NzGuillotineBinPack::GetSize() const
{
	return NzVector2ui(m_width, m_height);
}