Example #1
0
//=============================================================================
// 描画処理
//=============================================================================
void DrawEnemy(void)
{
	LPDIRECT3DDEVICE9 pDevice = GetDevice();
	D3DXMATRIX mtxScl, mtxRot, mtxTranslate;
	D3DXMATERIAL *pD3DXMat;
	D3DMATERIAL9 matDef;

	for(int nCntEnemy = 0; nCntEnemy < MAX_ENEMY; nCntEnemy++)
	{
		if(g_enemy[nCntEnemy].bUse)
		{
			// ワールドマトリックスの初期化
			D3DXMatrixIdentity( &g_enemy[nCntEnemy].mtxWorld);
	
			// スケールを反映
			D3DXMatrixScaling( &mtxScl, g_enemy[nCntEnemy].scl.x, g_enemy[nCntEnemy].scl.y, g_enemy[nCntEnemy].scl.z);
			D3DXMatrixMultiply( &g_enemy[nCntEnemy].mtxWorld, &g_enemy[nCntEnemy].mtxWorld, &mtxScl);
	
			// 回転を反映
			D3DXMatrixRotationYawPitchRoll( &mtxRot, g_enemy[nCntEnemy].rot.y, g_enemy[nCntEnemy].rot.x, g_enemy[nCntEnemy].rot.z);
			D3DXMatrixMultiply( &g_enemy[nCntEnemy].mtxWorld, &g_enemy[nCntEnemy].mtxWorld, &mtxRot);
	
			// 移動を反映
			D3DXMatrixTranslation( &mtxTranslate, g_enemy[nCntEnemy].pos.x, g_enemy[nCntEnemy].pos.y, g_enemy[nCntEnemy].pos.z);
			D3DXMatrixMultiply( &g_enemy[nCntEnemy].mtxWorld, &g_enemy[nCntEnemy].mtxWorld, &mtxTranslate);
	
			// ワールドマトリックスの設定
			pDevice->SetTransform( D3DTS_WORLD, &g_enemy[nCntEnemy].mtxWorld);

			// 現在のマテリアルを取得
			pDevice->GetMaterial(&matDef);
	
			
			ENEMY_TYPE type = g_enemy[nCntEnemy].type;
			// マテリアル情報に対するポインタを取得
			pD3DXMat = (D3DXMATERIAL *)g_modelData[type].pD3DXBuffMat->GetBufferPointer();
			for(int nCntMat = 0; nCntMat < (int)g_modelData[type].nNumMat; nCntMat++)
			{
				// マテリアルの設定
				pDevice->SetMaterial( &pD3DXMat[nCntMat].MatD3D);
				// テクスチャの設定
				pDevice->SetTexture( 0, g_modelData[type].pD3DTexture);
				// 描画
				g_modelData[type].pD3DXMesh->DrawSubset( nCntMat);
			}

			// マテリアルをデフォルトに戻す
			pDevice->SetMaterial( &matDef);		
		}
	}

}
Example #2
0
void ToonModel::draw() {
	LPDIRECT3DDEVICE9 device = ShaderDevise::device();

	LPD3DXBUFFER materials = this->materials();
	LPD3DXMATERIAL mat = (LPD3DXMATERIAL)this->materials()->GetBufferPointer();
	std::vector<LPDIRECT3DTEXTURE9> tex = this->textures();
	device->SetTexture(1, toon);

	D3DXMATRIX world = getWorld();
	device->SetTransform(D3DTS_WORLD, &world);

	D3DMATERIAL9 tmp_mat;
	device->GetMaterial(&tmp_mat);
	device->SetFVF(D3DFVF_CUSTOMMODEL);

	D3DXMATRIX v(Camera::view()), p(Camera::projection()), wvp = (world * v * p);

	HRESULT hr;
	if(shader_pack) {
		hr = device->SetVertexShader(shader_pack->vs);
		hr = shader_pack->constant_table->SetMatrix(device, "g_world_view_projection", &wvp);
		D3DXVECTOR3 lv(ShaderDevise::getLight(0).Direction);
		hr = shader_pack->constant_table->SetVector(device, "g_light_direction", &D3DXVECTOR4(lv.x, lv.y, lv.z, 1));
		hr = shader_pack->constant_table->SetMatrix(device, "g_world", &world);
	}

	for(int i = 0, len = numMaterials(); i < len; i++) {
		hr = device->SetMaterial(&mat[i].MatD3D);
		D3DXVECTOR4 diff(mat[i].MatD3D.Diffuse.r, mat[i].MatD3D.Diffuse.g, mat[i].MatD3D.Diffuse.b, mat[i].MatD3D.Diffuse.a);
		if(shader_pack) {
			hr = shader_pack->constant_table->SetVector(device, "g_material_diffuse", &diff);
		}
		hr = device->SetTexture(0, toon);
		this->mesh()->DrawSubset(i);
	}
	if(shader_pack) {
		device->SetVertexShader(NULL);
	}
	device->SetMaterial(&tmp_mat);
}
Example #3
0
HRESULT HookIDirect3DDevice9::GetMaterial(LPVOID _this,
										  D3DMATERIAL9* pMaterial)
{
	LOG_API();
	return pD3Dev->GetMaterial(pMaterial);
}
Example #4
0
//=============================================================================
// 描画処理
//=============================================================================
void DrawModel(LPDIRECT3DDEVICE9 pDevice)
{
	//LPDIRECT3DDEVICE9 pDevice = GetDevice();
	
	D3DXMATERIAL * 	pD3DXMat;
	D3DMATERIAL9	matDef;
	
	D3DXMATRIX mtxScale,mtxRot,mtxTrans;
	
	pDevice->SetFVF(Player.pD3DXMeshModel->GetFVF());

	//ワールドマトリクスの初期化
	D3DXMatrixIdentity(&Player.mtxWorld);	// Identity:単位○○

	//現在のマテリアルを取得
	pDevice->GetMaterial(&matDef);
	
	// スケールを反映
	D3DXMatrixScaling(
		&mtxScale,		//格納先
		Player.scaleModel.x,
		Player.scaleModel.y,
		Player.scaleModel.z
	);
	D3DXMatrixMultiply(
		&Player.mtxWorld,	//格納先(A*B)
		&Player.mtxWorld,	//A
		&mtxScale		//B
	);

	// 回転を反映
	D3DXMatrixRotationYawPitchRoll(
		&mtxRot,		//格納先
		Player.rotModel.y,	//ヨー(左右)
		Player.rotModel.x,	//ピッチ(前後)
		Player.rotModel.z	//ロール(回転)
	);
	D3DXMatrixMultiply(
		&Player.mtxWorld,	//格納先(A*B)
		&Player.mtxWorld,	//A
		&mtxRot			//B
	);

	// 移動を反映
	D3DXMatrixTranslation(
		&mtxTrans,		//格納先
		Player.posModel.x,	//
		Player.posModel.y,	//
		Player.posModel.z	//
	);
	D3DXMatrixMultiply(
		&Player.mtxWorld,	//格納先(A*B)
		&Player.mtxWorld,	//A
		&mtxTrans		//B
	);

	//ワールドマトリクスの設定
	pDevice->SetTransform(D3DTS_WORLD,&Player.mtxWorld);

	//マテリアル情報に対するポインタを取得
	pD3DXMat = (D3DXMATERIAL*)Player.pD3DXBuffMatModel->GetBufferPointer();
	

	for(int nCntMat = 0; nCntMat < (int)Player.nNumMatModel; nCntMat ++){
		//マテリアルの設定
		pDevice->SetMaterial(&pD3DXMat[nCntMat].MatD3D);
		//テクスチャの設定
		pDevice->SetTexture(0, Player.pMeshTex[nCntMat]);
		//描画
		Player.pD3DXMeshModel->DrawSubset(nCntMat);
	}
	
	//マテリアルを元に戻す
	pDevice->SetMaterial(&matDef);
}