Esempio n. 1
0
	void CViewWindow::_renderLight()
	{
		Zen::sPosition p[2];
		p[0].position = _light.mPosition.getPosition();
		p[1].position = Vec3::ZERO;

		//
		Zen::Effect* fx = _material->getEffect();
		if (NULL == fx)
		{
			return;
		}
		_material->apply();
		u32 passes = 0;
		fx->begin(&passes);
		for (u32 i = 0; i != passes; ++i)
		{
			fx->beginPass(i);
			if (i == 0)
			{
				RenderEngineImp::getInstancePtr()->getRenderEngine()->getRenderSystem()->drawPrimitiveUP(Zen::ePrimitive_PointList, 2, p, sizeof(Zen::sPosition));
			}
			fx->endPass();
		}
		fx->end();
	}
Esempio n. 2
0
void Chunks::render()
{
	//
	if (NULL == mMaterial)
	{
		return;
	}
	Zen::Effect* fx = mMaterial->getEffect();
	if (NULL == fx)
	{
		return;
	}
	for (size_t i = 0; i != mChunks.size(); ++i)
	{
		Chunk* c = mChunks[i];
		if (c)
		{
			Mat4 m;
			m.makeTransform(mPosition + Vec3(scChunkSize * c->mPostion.x, 0.0f, -scChunkSize * c->mPostion.y), Vec3(scChunkSize, 1.0f, scChunkSize), Quaternion::IDENTITY);
			fx->setMatrix("g_mWorld", m);
			{
				// 用颜色来区分邻居chunk
				Vec4 p;
				if ((int)c->mPostion.x % 2 == 0)
				{
					p.x = 0.0f;
				}
				else
				{
					p.x = 1.0f;
				}
				
				//
				if ((int)c->mPostion.y % 2 == 0)
				{
					p.z = 0.0f;
				}
				else
				{
					p.z = 1.0f;
				}
				//
				p.y = 2 - (p.x + p.z);
				p.y /= 2.0f;
				//
				p.w = 1.0f;
				fx->setVector("gAmbient", &p);
			}

			mMaterial->apply();
			u32 passes = 0;
			fx->begin(&passes);
			for (u32 i = 0; i != passes; ++i)
			{
				fx->beginPass(i);
				if (i == 0)
				{
					c->render();
				}
				fx->endPass();
			}
			fx->end();
		}
	}
	
}