コード例 #1
0
ファイル: PX2Scene.cpp プロジェクト: ascetic85/Phoenix3d
//-----------------------------------------------------------------------------
void Scene::Update (double appSeconds, double elapsedSeconds)
{
	// Ambient
	PX2::Light *light = mDefaultLight;

	AmbientRegionActor *curARActor = mTwoAmbientRigion[1];
	AmbientRegionActor *pastARActor = mTwoAmbientRigion[0];
	curARActor = mDefaultARActor;
	pastARActor = mDefaultARActor;

	mAmbientBlend = 1.0f;
	light->Ambient = Interpolate::LinearFloat4(
		pastARActor->mAmbientColor, curARActor->mAmbientColor, 
		mAmbientBlend);
	light->Diffuse = Interpolate::LinearFloat4(
		pastARActor->mDirLightDiffColor, curARActor->mDirLightDiffColor,
		mAmbientBlend);
	light->Specular = Interpolate::LinearFloat4(
		pastARActor->mDirLightSpecColor, curARActor->mDirLightSpecColor,
		mAmbientBlend);
	float horAngle = Interpolate::LinearFloat(
		pastARActor->mHorAngle, curARActor->mHorAngle,
		mAmbientBlend);
	float verAngle = Interpolate::LinearFloat(
		pastARActor->mVerAngle, curARActor->mVerAngle,
		mAmbientBlend);
	AVector dir = AnglesToDirection(Mathf::DEG_TO_RAD*horAngle, 
		Mathf::DEG_TO_RAD*verAngle);
	light->SetDirection(dir);

	// Scene
	mSceneNode->Update(appSeconds);
}
コード例 #2
0
//----------------------------------------------------------------------------
void RawTerrainPage::CreateEditMtlInstPerVertex (EditTerrainMaterial *material, 
	Shine *shine)
{
	PX2::Light *light = 0;
	for (int i=0; i<(int)mInfulencedLights.size(); i++)
	{
		Light *lit = mInfulencedLights[i];
		if (lit->GetType() == Light::LT_DIRECTIONAL)
		{
			light = lit;
			break;
		}
	}

	if (light == 0)
	{
		light = new0 Light(Light::LT_DIRECTIONAL);
		light->Ambient = Float4(1.0f, 0.8f, 0.8f, 1.0f);
		light->Diffuse = Float4(1.0f, 0.8f, 0.6f, 1.0f);
		light->Intensity = 1.0f;
		light->SetDirection(AVector(-1.0f, -1.0f, -1.0f));
	}

	mMtlInst = new0 MaterialInstance(material, 0);
	mMtlInst->SetVertexConstant(0, "gPVWMatrix", new0 PVWMatrixConstant());

	mMtlInst->SetVertexConstant(0, "gShineEmissive",
		new0 ShineEmissiveConstant(shine));
	mMtlInst->SetVertexConstant(0, "gShineAmbient",
		new0 ShineAmbientConstant(shine));
	mMtlInst->SetVertexConstant(0, "gShineDiffuse",
		new0 ShineDiffuseConstant(shine));
	mMtlInst->SetVertexConstant(0, "gLightModelDirection",
		new0 LightModelDVectorConstant(light));
	mMtlInst->SetVertexConstant(0, "gLightColour",
		new0 LightDiffuseConstant(light));
	mMtlInst->SetVertexConstant(0, "gLightAttenuation",
		new0 LightAttenuationConstant(light));

	mMtlInst->SetPixelConstant(0, "UVScale01", mUV01Float);
	mMtlInst->SetPixelConstant(0, "UVScale23", mUV23Float);
	mMtlInst->SetPixelConstant(0, "UVScale4", mUV4Float);

	SetTexture0(mTextureDefaultFilename);
	SetTextureAlpha(mTextureAlpha);
	SetTexture1(mTextureDefaultFilename);
	SetTexture2(mTextureDefaultFilename);
	SetTexture3(mTextureDefaultFilename);
	SetTexture4(mTextureDefaultFilename);

	SetMaterialInstance(mMtlInst);
}