Exemplo n.º 1
0
void LightAnimation::CreateLightsWithAnimStatic()
{
	const float3 SponzaExtentInner[] = {
		float3(750,  10, -120),
		float3(750,  10, 230),
		float3(-950, 10, 230),
		float3(-950, 10, -100) };

	SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager();

	const int NumLightX = 40;
	const int NumLightZ = 12;
	for (int i = 0; i < NumLightZ; ++i)
	{
		float t = float(i) / NumLightZ;
		float3 start = Lerp(SponzaExtentInner[0], SponzaExtentInner[1], t);
		float3 end = Lerp(SponzaExtentInner[3], SponzaExtentInner[2], t);

		for (int j = 0; j < NumLightX; ++j)
		{
			Light* light = sceneMan->CreateLight("", LT_PointLight);
			light->SetPosition(Lerp(start, end, float(j)/NumLightX));

			float3 color = IntensityDist(rng) * HueToRGB(HueDist(rng));
			light->SetLightColor(color);

			light->SetLightIntensity(1.0);
			light->SetAttenuation(1.0f, 0.0f);
			light->SetRange(25.0f);
			sceneMan->GetRootSceneNode()->AttachObject(light);

			mNumTotalLights++;
		}
	}
}
Exemplo n.º 2
0
	void LoadContent()
	{
		FileSystem& fileSys = FileSystem::GetSingleton();
		ResourceManager& resMan = ResourceManager::GetSingleton();
		SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager();
		RenderFactory* factory = Environment::GetSingleton().GetRenderFactory();
		
		LoadDudeEntity();

		mFont = resMan.GetResourceByName<Font>(RT_Font, "Consolas Regular", "General");
		auto mSDFEffect = resMan.GetResourceByName<Effect>(RT_Effect, "Font.effect.xml", "General") ;
		mSpriteBatch = sceneMan->CreateSpriteBatch(mSDFEffect);

		// Set as default camera
		auto screenFB = Environment::GetSingleton().GetRenderDevice()->GetScreenFrameBuffer();
		screenFB->SetCamera(mCamera);

		Light* mDirLight = sceneMan->CreateLight("Sun", LT_DirectionalLight);
		mDirLight->SetDirection(float3(1, -0.5, 0));
		mDirLight->SetLightColor(float3(1, 1, 1));
		mDirLight->SetLightIntensity(1.0);
		mDirLight->SetCastShadow(false);
		mDirLight->SetShadowCascades(4);
		sceneMan->GetRootSceneNode()->AttachObject(mDirLight);
	}
Exemplo n.º 3
0
void LightAnimation::CreateLightsWithAnimLine()
{
	SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager();
	
	const int NumBandLights[] = { 10, 20 };

	for (int iFloor = 0; iFloor < 2; ++iFloor)
	{
		for (int iLine = 0; iLine < 4; ++iLine)
		{
			const int NumLight = NumBandLights[iLine & 0x1];
			const float3 LeftPos = SponzaExtent[iLine];
			const float3 RightPos = SponzaExtent[(iLine+1)%4];

			for (int32_t iLight = 0; iLight <  NumLight; ++iLight)
			{
				float3 position = Lerp(LeftPos, RightPos, float(iLight) / NumLight);

				position.Y() = SponzaFloorHeightRange[iFloor][0];

				//position.Y() = Lerp(SponzaFloorHeightRange[iFloor][0], SponzaFloorHeightRange[iFloor][1], NormDist(rng));

				float3 color = IntensityDist(rng) * HueToRGB(HueDist(rng));

				Light* light = sceneMan->CreateLight("", LT_PointLight);
				light->SetPosition(position);
				light->SetLightColor(color);
				light->SetLightIntensity(1.0);
				light->SetAttenuation(1.0f, 0.0f);
				light->SetRange(100);
				sceneMan->GetRootSceneNode()->AttachObject(light);

				LineAnimatedLight aminLight;
				aminLight.Light = light;
				aminLight.LineIndex = iLine;
				aminLight.FloorIndex = iFloor;
				mLineAnimatedLights.push_back(aminLight);

				mNumTotalLights++;
			}
		}
	}
}
Exemplo n.º 4
0
void LightAnimation::CreateLightsWithAnimEllipse()
{
	SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager();

	const int NumEllipses = 10;
	const int NumLightsEllipse = 40;

	for (int i = 0; i < NumEllipses; ++i)
	{
		for (int j = 0; j < NumLightsEllipse; ++j)
		{
			EllipseAnimatedLight aminLight;

			aminLight.EllipseWidth = 950.0f;
			aminLight.EllipseHeight = 175.0f;
			aminLight.Height = Lerp(100.0f, 1000.0f, float(i) / NumEllipses);

			//aminLight.Angle = Mathf::TWO_PI / NumLightsEllipse * j;
			aminLight.Angle = AngleDist(rng);
			aminLight.AnimationSpeed = (AnimationDirection(rng) * 2 - 1) * AnimationSpeedDist(rng);

			float3 pos(aminLight.EllipseWidth * cosf(aminLight.Angle), aminLight.Height, aminLight.EllipseHeight * sinf(aminLight.Angle));
			float3 color = IntensityDist(rng) * HueToRGB(HueDist(rng));

			Light* light = sceneMan->CreateLight("", LT_PointLight);
			light->SetPosition(pos);
			light->SetLightColor(color);
			light->SetLightIntensity(1.0);
			light->SetAttenuation(1.0f, 0.0f);
			light->SetRange(100);
			sceneMan->GetRootSceneNode()->AttachObject(light);

			aminLight.Light = light;
			mEllipseAnimatedLights.push_back(aminLight);

			mNumTotalLights++;
		}
	}
}
Exemplo n.º 5
0
	void LoadDudeEntity()
	{
		SceneManager* sceneMan = Environment::GetSingleton().GetSceneManager();
		ResourceManager& resMan = ResourceManager::GetSingleton();

		/*SceneNode* sirisSceneNode = sceneMan->GetRootSceneNode()->CreateChildSceneNode("Siris");
		{
		Entity* dudeEntity = sceneMan->CreateEntity("dude", "./InfinityBlade/Siris.mesh",  "Custom");

		AnimationPlayer* animPlayer = dudeEntity->GetAnimationPlayer();

		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_big_down.anim", "Custom"));
		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_big_left.anim", "Custom"));
		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_big_center.anim", "Custom"));
		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_big_right.anim", "Custom"));
		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_small_down.anim", "Custom"));
		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_small_left.anim", "Custom"));
		animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./InfinityBlade/attack_small_right.anim", "Custom"));

		AnimationState* takeClip = animPlayer->GetClip("attack_big_down");
		takeClip->SetAnimationWrapMode(AnimationState::Wrap_Loop);
		takeClip->Play();

		sirisSceneNode->AttachObject(dudeEntity);

		mDudeEntity = dudeEntity;
		mDudeSceneNode = sirisSceneNode;
		}*/


		//SceneNode* dudeSceneNode = sceneMan->GetRootSceneNode()->CreateChildSceneNode("Dude");
		//{
		//	Entity* dudeEntity = sceneMan->CreateEntity("dude", "./Dude/dude_gpu.mesh",  "Custom");

		//	AnimationPlayer* animPlayer = dudeEntity->GetAnimationPlayer();
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./Dude/Walk.anim", "Custom"));

		//	AnimationState* takeClip = animPlayer->GetClip("Walk");
		//	takeClip->SetAnimationWrapMode(AnimationState::Wrap_Loop);
		//	takeClip->Play();

		//	dudeSceneNode->SetRotation(QuaternionFromRotationAxis(float3(0, 1, 0), Mathf::PI));
		//	dudeSceneNode->SetPosition(float3(100, 0, 0));
		//	dudeSceneNode->AttachObject(dudeEntity);

		//	mDudeEntity = dudeEntity;
		//	mDudeSceneNode = dudeSceneNode;
		//}

		//SceneNode* arthasSceneNode = sceneMan->GetRootSceneNode()->CreateChildSceneNode("Arthas");
		//{
		//	Entity* arthasEntity = sceneMan->CreateEntity("dude", "./Arthas/Arthas.mesh",  "Custom");
		//	Entity* swoardEntity = sceneMan->CreateEntity("swoard", "./Arthas/Sword.mesh",  "Custom");
		//	BoneSceneNode* weaponNode = arthasEntity->CreateBoneSceneNode("Weapon", "wepson");
		//	weaponNode->SetPosition(float3(4.2, -7.8, 0));
		//	weaponNode->AttachObject(swoardEntity);

		//	AnimationPlayer* animPlayer = arthasEntity->GetAnimationPlayer();

		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./Arthas/Walk.anim", "Custom"));
		//	//animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./Arthas/Random.anim", "Custom"));
		//	//animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./Arthas/Standby.anim", "Custom"));
		//	//animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./Arthas/Casting.anim", "Custom"));
		//	//animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./Arthas/FightingStandby.anim", "Custom"));

		//	AnimationState* takeClip = animPlayer->GetClip("Walk");
		//	takeClip->SetAnimationWrapMode(AnimationState::Wrap_Loop);
		//	takeClip->Play();

		//	arthasSceneNode->SetScale(float3(2, 2, 2));
		//	arthasSceneNode->SetPosition(float3(0, 18, 0));
		//	arthasSceneNode->AttachObject(arthasEntity);
		//}

		//SceneNode* citySceneNode = sceneMan->GetRootSceneNode()->CreateChildSceneNode("PSSMScene");
		//{
		//	Entity* arthasEntity = sceneMan->CreateEntity("dude", "./Tree/Tree.mesh",  "Custom");	
		//	//citySceneNode->SetScale(float3(10, 10, 10));
		//	citySceneNode->AttachObject(arthasEntity);
		//}

		//SceneNode* arthasSceneNode = sceneMan->GetRootSceneNode()->CreateChildSceneNode("Sinbad");
		//{
		//	Entity* arthasEntity = sceneMan->CreateEntity("Sinbad", "./Sinbad/Sinbad.mesh",  "Custom");

		//	
		//	Entity* sword1 = sceneMan->CreateEntity("Swoard", "./Sinbad/Sword.mesh",  "Custom");
		//	Entity* sword2 = sceneMan->CreateEntity("Swoard", "./Sinbad/Sword.mesh",  "Custom");

		//	BoneSceneNode* sword1Node = arthasEntity->CreateBoneSceneNode("WeaponL", "Sheath.L");
		//	BoneSceneNode* sword2Node = arthasEntity->CreateBoneSceneNode("WeaponR", "Sheath.R");
		//	sword1Node->AttachObject(sword1);
		//	sword2Node->AttachObject(sword2);

		//	AnimationPlayer* animPlayer = arthasEntity->GetAnimationPlayer();

		//	const String AnimClips[] = { 
		//		"./Sinbad/Dance.anim", 
		//	    "./Sinbad/DrawSwords.anim",
		//		"./Sinbad/JumpStart.anim",
		//		"./Sinbad/JumpLoop.anim",
		//		"./Sinbad/JumpEnd.anim",
		//		"./Sinbad/HandsClosed.anim",
		//		"./Sinbad/HandsRelaxed.anim",
		//		"./Sinbad/IdleBase.anim",
		//		"./Sinbad/IdleTop.anim",
		//		"./Sinbad/RunBase.anim",
		//		"./Sinbad/RunTop.anim",
		//		"./Sinbad/SliceHorizontal.anim",
		//		"./Sinbad/SliceVertical.anim",
		//	};

		//	for (size_t i = 0; i < ARRAY_SIZE(AnimClips); ++i)
		//	{
		//		AnimationState* animState = animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, AnimClips[i], "Custom"));
		//		animState->WrapMode = AnimationState::Wrap_Loop;
		//	}
		//	
		//	AnimationState* SliceHorizontal = animPlayer->GetClip("SliceHorizontal");
		//	SliceHorizontal->WrapMode = (AnimationState::Wrap_Once);

		//	SliceHorizontal->Play();
		//	animPlayer->PlayClip("IdleBase");

		//	/*AnimationState* takeClip = animPlayer->GetClip("DrawSwords");
		//	takeClip->SetAnimationWrapMode(AnimationState::Wrap_Loop);
		//	takeClip->Play();

		//	AnimationState* runBaseClip = animPlayer->GetClip("RunBase");
		//	runBaseClip->SetAnimationWrapMode(AnimationState::Wrap_Loop);
		//	runBaseClip->Play();*/

		//	arthasSceneNode->SetScale(float3(5, 5, 5));
		//	arthasSceneNode->SetPosition(float3(0, 50, 0));
		//	arthasSceneNode->AttachObject(arthasEntity);

		//	mDudeEntity = arthasEntity;
		//}


		//String modelName = "./LOL/blitzcrank/blitzcrank.mesh";
		////String modelName = "./LOL/Ahri/ahri.mesh";
		//SceneNode* blitzcrankSceneNode = sceneMan->GetRootSceneNode()->CreateChildSceneNode("blitzcrank");
		//{
		//	Entity* blitzcrankEntity = sceneMan->CreateEntity("blitzcrank", modelName,  "Custom");	
		//	blitzcrankSceneNode->AttachObject(blitzcrankEntity);

		//	AnimationPlayer* animPlayer = blitzcrankEntity->GetAnimationPlayer();
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/dance.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/run.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/laugh.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/idle1.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/idle2.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/idle3.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/attack1.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/attack2.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/attack3.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/death.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/windup.anim", "Custom"));
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/taunt.anim", "Custom"));
		//	
		//	animPlayer->AddClip(resMan.GetResourceByName<AnimationClip>(RT_Animation, "./LOL/blitzcrank/Take 001.anim", "Custom"));

		//	AnimationState* takeClip = animPlayer->GetClip("Take 001");
		//	takeClip->SetAnimationWrapMode(AnimationState::Wrap_Loop);
		//	takeClip->Play();

		//	blitzcrankSceneNode->SetScale(float3(0.3, 0.3, 0.3));
		//	//blitzcrankSceneNode->SetPosition(float3(0, 50, 0));

		//	mDudeEntity = blitzcrankEntity;
		//}

		Entity* sponzaEnt = sceneMan->CreateEntity("Sponza", "./Sponza/Sponza.mesh", "Custom");
		sceneMan->GetRootSceneNode()->AttachObject(sponzaEnt);
	}