Пример #1
0
	// IRenderable
	void PreRender(const RenderParam& param, RenderParamOut* paramOut){
		if (mSelf->HasObjFlag(SceneObjectFlag::Hide))
			return;

		if (mLastPreRendered == gpTimer->GetFrame())
			return;
		mLastPreRendered = gpTimer->GetFrame();

		if (mBlendingSkySphere && mBlendingSkySphere->GetAlpha() == 1.0f){
			mBlendingSkySphere->PreRender(param, paramOut);
			return;
		}

		if (mInterpolating)
		{
			mCurInterpolationTime += gpTimer->GetDeltaTime();
			float normTime = mCurInterpolationTime / mInterpolationTime;
			if (normTime >= 1.0f)
			{
				normTime = 1.0f;
				mInterpolating = false;
				if (!mUseAlphaBlend)
				{
					SceneObjectFactory::GetInstance().UpdateEnvMapInNextFrame(mSelfPtr.lock());
				}
			}

			for (int i = 0; i < 5; i++)
			{
				mMaterial->SetMaterialParameter(i, Lerp(mMaterialParamCur[i], mMaterialParamDest[i], normTime));
				if (mMaterialOCC)
				{
					mMaterialOCC->SetMaterialParameter(i, Lerp(mMaterialParamCur[i], mMaterialParamDest[i], normTime));
				}
			}
		}

		if (mBlendingSkySphere && mBlendingSkySphere->GetAlpha() != 0.f){
			mBlendingSkySphere->PreRender(param, paramOut);
		}
	}
Пример #2
0
	void PreRender(const RenderParam& renderParam, RenderParamOut* renderParamOut){
		mRenderPass = (RENDER_PASS)renderParam.mRenderPass;
		if (!mSkipSpatialObjects)
		{
			auto cam = renderParam.mCamera;
			assert(cam);

			auto it = mLastPreRenderFramePerCam.Find(cam);
			if (it != mLastPreRenderFramePerCam.end() && it->second == gpTimer->GetFrame())
				return;
			mLastPreRenderFramePerCam[cam] = gpTimer->GetFrame();

			MakeVisibleSet(renderParam, renderParamOut);

			auto objIt = mPreRenderList[cam].begin(), objItEnd = mPreRenderList[cam].end();
			for (; objIt != objItEnd; objIt++)
			{
				// Only objects that have a valid renderable is in the render lists.
				(*objIt)->PreRender(renderParam, renderParamOut);				
			}
		}

		if (mSkyRendering)
		{
			if (mSkySphere)
			{
				mSkySphere->PreRender(renderParam, renderParamOut);
			}
		}

		for (auto it = mObjects.begin(); it != mObjects.end(); /**/){
			auto obj = it->lock();
			if (!obj){
				it = mObjects.erase(it);
				continue;
			}
			++it;
			obj->PreRender(renderParam, renderParamOut);			
		}
	}