Пример #1
0
//----------------------------------------------------------------------------
void CullerSorting::Insert(Object* pObject, Transformation* pTransformation,
	const Vector3F& rPosition)
{
	WIRE_ASSERT(mVisibleSets.GetQuantity() >= 2);

	RenderObject* pRenderObject = DynamicCast<RenderObject>(pObject);
	if (!pRenderObject)
	{
		GetVisibleSet(0)->Insert(pObject, NULL);
		GetVisibleSet(1)->Insert(pObject, NULL);
		return;
	}

	UInt64 key = GetKey(pRenderObject, pTransformation, rPosition);
	StateAlpha* pAlpha = StaticCast<StateAlpha>(pRenderObject->GetStates()[
		State::ALPHA]);
	if (pAlpha)
	{
		if (pAlpha->BlendEnabled)
		{
			GetVisibleSet(1)->Insert(pObject, pTransformation, key);
		}
		else
		{
			GetVisibleSet(0)->Insert(pObject, pTransformation, key);
		}
	}
	else
	{
		GetVisibleSet(0)->Insert(pObject, pTransformation, key);
	}
}
Пример #2
0
//----------------------------------------------------------------------------
RenderObject* Sample5::CreatePlane()
{
	const UInt tileXCount = 30;
	const UInt tileYCount = 20;
	const Float xSizeTotal = 12.0F;
	const Float ySizeTotal = 8.0F;
	RenderObject* pPlane = StandardMesh::CreatePlane(tileXCount, tileYCount,
		xSizeTotal, ySizeTotal, 0, 1, true);
	pPlane->GetMesh()->GenerateNormals();

	Texture2D* pTexture = CreateTexture();
	pTexture->SetWrapType(0, Texture2D::WT_REPEAT);
	pTexture->SetWrapType(1, Texture2D::WT_REPEAT);
	Material* pMaterial = WIRE_NEW Material;
	pMaterial->AddTexture(pTexture, Material::BM_MODULATE);
	pPlane->SetMaterial(pMaterial);

	// attach a material state and a light to the plane geometry directly
	StateMaterial* pStateMaterial = WIRE_NEW StateMaterial;
	pStateMaterial->Ambient = ColorRGBA(1, 1, 1, 1);
	pPlane->GetStates()[State::MATERIAL] = pStateMaterial;

	mspSpotLight = WIRE_NEW Light(Light::LT_SPOT);
	mspSpotLight->Position = Vector3F(0, 0, 10);
	mspSpotLight->Direction = Vector3F(0, 0, -1);
	mspSpotLight->Angle = 0.5F;
	mspSpotLight->Ambient = ColorRGB(0.2F, 0.2F, 0.2F);
	return pPlane;
}