Esempio n. 1
0
/************************************************
 *	Refresh view.
 ************************************************/
void CHandsImage::Refresh( bool pNow )
{
	if (mReDraw)
	{
		UpdateWeight();

		FBView::Refresh( pNow );
	}
}
AClothingItem::AClothingItem(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) {
    // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = false;
    
    static ConstructorHelpers::FObjectFinder<UTexture2D> IconObj(TEXT("/Game/HUD/DefaultIcons/ClothingItem"));
    Icon = IconObj.Object;
    
    Storage.Init(NULL, 10);
    
    Name = "Clothing";
    Description = "Is it a hat, shoes or a vest? Who cares. You should not have this...";
    BaseWeight = 0.0f;
    if(GetWorld()) {
        AddToStorage(GetWorld()->SpawnActor<AItem>());
        AddToStorage(GetWorld()->SpawnActor<AItem>());
        AddToStorage(GetWorld()->SpawnActor<AItem>());
        AddToStorage(GetWorld()->SpawnActor<AItem>());
        AddToStorage(GetWorld()->SpawnActor<AItem>());
        AddToStorage(GetWorld()->SpawnActor<AItem>());
    }
    
    
    UpdateWeight();
}
/*!
* @brief	描画。
*/
void CDofRender::Draw(LPDIRECT3DTEXTURE9 tex)
{

	if (m_isEnable) {
		UpdateWeight(200.0f);
		LPDIRECT3DSURFACE9 RenderingTarget;
		LPDIRECT3DSURFACE9 m_SavedMapZ;

		// もとのレンダリングターゲットを保存
		(*graphicsDevice()).GetRenderTarget(0, &RenderingTarget);
		(*graphicsDevice()).GetDepthStencilSurface(&m_SavedMapZ);

		m_Primitive = SINSTANCE(CRenderContext)->GetPrimitive();

		// 深度情報抽出
		{
			(*graphicsDevice()).SetRenderTarget(0, m_DepthSamplingTarget);
			(*graphicsDevice()).Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

			vector<OBJECT_DATA*> Objects = SINSTANCE(CObjectManager)->GetObjectList();
			int size = Objects.size();
			for (PRIORTY priorty = PRIORTY::PLAYER; priorty < PRIORTY::OBJECT2D; priorty = static_cast<PRIORTY>(priorty + 1)){	// 優先度の高いものから更新
				for (int idx = 0; idx < size; idx++){
					if (Objects[idx]->object->GetAlive()){
						if (Objects[idx]->priority == priorty){
							Objects[idx]->object->DrawDepth(m_pEffect,m_FarNear);
							//static_cast<C3DImage*>(Objects[idx]->object)->DrawDepth();
							//if (/*アニメーションするか*/){
							//	//(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

							//}
							//else{

							//	//(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
							//}
						}
					}
				}
			}
		}
		int w = SINSTANCE(CRenderContext)->GetWindowWidth();
		int h = SINSTANCE(CRenderContext)->GetWindowHeight();

		//XBlur
		{
			(*graphicsDevice()).SetRenderTarget(0, m_RenderTarget[0]);
			//(*graphicsDevice()).Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
			m_pEffect->SetTechnique("XBlur");
			m_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE);
			m_pEffect->BeginPass(0);
			float size[2] = {
				static_cast<float>(w),
				static_cast<float>(h)
			};
			float offset[] = {
				16.0f / static_cast<float>(w),
				0.0f
			};
			m_pEffect->SetValue("g_TexSize", size, sizeof(size));
			m_pEffect->SetValue("g_offset", offset, sizeof(offset));
			m_pEffect->SetValue("g_weight", m_weights, sizeof(m_weights));

			m_pEffect->SetTexture("g_blur", tex);
			m_pEffect->CommitChanges();

			(*graphicsDevice()).SetVertexDeclaration(m_Primitive->GetVertexDecl());
			(*graphicsDevice()).SetStreamSource(0, m_Primitive->GetVertexBuffer(), 0, sizeof(SShapeVertex_PT));
			(*graphicsDevice()).SetIndices(m_Primitive->GetIndexBuffer());

			(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

			m_pEffect->EndPass();
			m_pEffect->End();

		}
		//YBlur
		{
			(*graphicsDevice()).SetRenderTarget(0, m_RenderTarget[1]);
			//(*graphicsDevice()).Clear(0, nullptr, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);
			m_pEffect->SetTechnique("YBlur");
			m_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE);
			m_pEffect->BeginPass(0);
			float size[2] = {
				static_cast<float>(w),
				static_cast<float>(h)
			};
			float offset[] = {
				0.0f,
				16.0f / static_cast<float>(h)
			};
			m_pEffect->SetValue("g_TexSize", size, sizeof(size));
			m_pEffect->SetValue("g_offset", offset, sizeof(offset));
			m_pEffect->SetValue("g_weight", m_weights, sizeof(m_weights));

			m_pEffect->SetTexture("g_blur", m_pBlurTexture[0]);
			m_pEffect->CommitChanges();
			(*graphicsDevice()).SetVertexDeclaration(m_Primitive->GetVertexDecl());
			(*graphicsDevice()).SetStreamSource(0, m_Primitive->GetVertexBuffer(), 0, sizeof(SShapeVertex_PT));
			(*graphicsDevice()).SetIndices(m_Primitive->GetIndexBuffer());

			(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

			m_pEffect->EndPass();
			m_pEffect->End();
		}

		{
			float offset[] = {
				0.5f / static_cast<float>(w),
				0.5f / static_cast<float>(h)
			};
			//戻す。
			(*graphicsDevice()).SetRenderTarget(0, RenderingTarget);
			(*graphicsDevice()).SetDepthStencilSurface(m_SavedMapZ);

			//深度情報を参照して合成。
			m_pEffect->SetTechnique("Final");
			m_pEffect->Begin(NULL, D3DXFX_DONOTSAVESHADERSTATE);
			m_pEffect->BeginPass(0);
			m_pEffect->SetTexture("g_Texture", tex);
			m_pEffect->SetTexture("g_DepthSample", m_pDepthSamplingTexture);
			m_pEffect->SetTexture("g_blur", m_pBlurTexture[1]);
			m_pEffect->SetValue("g_offset", offset, sizeof(offset));
			m_pEffect->CommitChanges();
			(*graphicsDevice()).SetVertexDeclaration(m_Primitive->GetVertexDecl());
			(*graphicsDevice()).SetStreamSource(0, m_Primitive->GetVertexBuffer(), 0, sizeof(SShapeVertex_PT));
			(*graphicsDevice()).SetIndices(m_Primitive->GetIndexBuffer());

			(*graphicsDevice()).DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);

			m_pEffect->EndPass();
			m_pEffect->End();
		}
	}

};
Esempio n. 4
0
/************************************************
 *	CHandsImage Constructor.
 ************************************************/
CHandsImage::CHandsImage(void)
{
	FBStringList list;
	FBString appPath = mSystem.ApplicationPath;
	SplitPath( appPath, list );

	appPath = "";
	for (int i=0; i<list.GetCount(); ++i)
	{
		appPath = appPath + list[i];
		appPath = appPath + "\\";
		if (strcmp(list[i], "bin") == 0) break;
	}

	FBString		szFullFilePath( appPath, HANDS_CTRL_IMAGE );
	FBString		szRegionDropPath( appPath, FINGER_CTRL_IMAGE );
	FBString		szRegionDropPath25( appPath, FINGER_CTRL_IMAGE_25 );
	FBString		szRegionDropPath50( appPath, FINGER_CTRL_IMAGE_50 );
	FBString		szRegionDropPath75( appPath, FINGER_CTRL_IMAGE_75 );
	FBString		szRegionDropPath100( appPath, FINGER_CTRL_IMAGE_100 );
	FBString		szRegionSelPath( appPath, SELECTED_CTRL_IMAGE );

	mHandsId = LoadTGA( szFullFilePath );
	mRegionDropId = LoadTGA( szRegionDropPath );
	mRegionDropId25		= LoadTGA( szRegionDropPath25 );
	mRegionDropId50		= LoadTGA( szRegionDropPath50 );
	mRegionDropId75		= LoadTGA( szRegionDropPath75 );
	mRegionDropId100	= LoadTGA( szRegionDropPath100 );
	mRegionSelectedId = LoadTGA( szRegionSelPath );

	mSelected = false;
	mReDraw = true;

	//-------------------
	//-- LEFT HAND
	FillHandLeftFinger( 0,	15, 95 );

	//-- index
	FillHandLeftFinger( 1,	50, 53 );
	FillHandLeftFinger( 2,	58, 43 );
	FillHandLeftFinger( 3,	68, 32 );
	//-- middle
	FillHandLeftFinger( 4,	36, 49 );
	FillHandLeftFinger( 5,	41, 35 );
	FillHandLeftFinger( 6,	45, 21 );
	//-- ring
	FillHandLeftFinger( 7,	25, 52 );
	FillHandLeftFinger( 8,	25, 38 );
	FillHandLeftFinger( 9,	25, 25 );
	//-- pinky
	FillHandLeftFinger( 10,		14, 57 );
	FillHandLeftFinger( 11,		10, 45 );
	FillHandLeftFinger( 12,		6, 34 );

	//-- thumb
	FillHandLeftFinger( 13,		58, 80 );
	FillHandLeftFinger( 14,		66, 74 );
	FillHandLeftFinger( 15,		76, 65 );

	//------------------------
	//-- RIGHT HAND
	FillHandRightFinger( 0,	15, 95 );

	//-- index
	FillHandRightFinger( 1,	50, 53 );
	FillHandRightFinger( 2,	58, 43 );
	FillHandRightFinger( 3,	68, 32 );
	//-- middle
	FillHandRightFinger( 4,	36, 49 );
	FillHandRightFinger( 5,	41, 35 );
	FillHandRightFinger( 6,	45, 21 );
	//-- ring
	FillHandRightFinger( 7,	25, 52 );
	FillHandRightFinger( 8,	25, 38 );
	FillHandRightFinger( 9,	25, 25 );
	//-- pinky
	FillHandRightFinger( 10,		14, 57 );
	FillHandRightFinger( 11,		10, 45 );
	FillHandRightFinger( 12,		6, 34 );

	//-- thumb
	FillHandRightFinger( 13,		58, 80 );
	FillHandRightFinger( 14,		66, 74 );
	FillHandRightFinger( 15,		76, 65 );

	//-- try to load finger position's from config file
	FBString		szConfigPath( appPath, CONFIG_FILENAME );
	LoadFingerConfig( szConfigPath );

	UpdateWeight();
}