1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| HRESULT LayerDuelSphere::Render2( IDirect3DDevice9 *in_pd3dDevice,
const D3DXMATRIXA16 *in_pViewProjection,
const D3DXMATRIXA16 *in_pWorldProjection,
const D3DXVECTOR3 *in_EyePt,
const D3DXVECTOR3 *in_AtPt,
const RENDERING_CONTEXT *in_pStructContext)
{
HRESULT hr=S_OK;
UINT cPasses;
D3DXVECTOR3 direction(in_AtPt->x, in_AtPt->z, in_AtPt->y);
D3DXCOLOR color = WHITE;
D3DLIGHT9 light;
::ZeroMemory(&light, sizeof(light));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Ambient = color * 0.6f;
light.Diffuse = color;
light.Specular = color * 0.6f;
light.Direction = direction;
in_pd3dDevice->SetLight(0, &light);
in_pd3dDevice->LightEnable(0, true);
in_pd3dDevice->SetRenderState( D3DRS_NORMALIZENORMALS, true);
in_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, false);
in_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
in_pd3dDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_GOURAUD );
if(in_pStructContext->bRender)
{
//---Activation/Desactivation du Z Buffer----------------------------//
if(in_pStructContext->bBufZone == false)
{V(in_pd3dDevice->SetRenderState( D3DRS_ZENABLE , true ));}
else
{V(in_pd3dDevice->SetRenderState( D3DRS_ZENABLE , false ));}
//---Affichage en solide ou en file de fer---------------------------//
if(in_pStructContext->bWired == true)
{V(in_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME));}
else
{V(in_pd3dDevice->SetRenderState( D3DRS_FILLMODE, D3DFILL_SOLID));}
//in_pd3dDevice->LightEnable(0,true);
//---Matrice de taille-----------------------------------------------//
D3DXMATRIX ScaleMatrix;
D3DXMatrixScaling(&ScaleMatrix,40.f,40.f,40.0f);
//---Matrice de deplacement------------------------------------------//
D3DXMATRIX TranslationMatrix;
D3DXMatrixTranslation(&TranslationMatrix,150.0f,250.0f,80.0f);
//---Multiplication des matrice pour redimensionner et deplacer //
// l'objet---------------------------------------------------------//
D3DXMATRIX AnswerMatrix;
D3DXMatrixMultiply(&AnswerMatrix,&ScaleMatrix,&TranslationMatrix);
in_pd3dDevice->SetTransform(D3DTS_WORLD,&AnswerMatrix);
//---Couleur d'un objet via un material------------------------------//
const D3DMATERIAL9 MATERIAL_RED = InitMaterial(RED,RED,RED,BLACK,2.0f);
//*
D3DMATERIAL9 gBlueMaterial;
ZeroMemory( &gBlueMaterial, sizeof(D3DMATERIAL9) );
gBlueMaterial.Diffuse.r = gBlueMaterial.Ambient.r = 0;
gBlueMaterial.Diffuse.g = gBlueMaterial.Ambient.g = 0;
gBlueMaterial.Diffuse.b = gBlueMaterial.Ambient.b = 1.0f;
gBlueMaterial.Diffuse.a = gBlueMaterial.Ambient.a = 1.0f;
//*/
in_pd3dDevice->SetMaterial(&gBlueMaterial);
//---Affichage des faces
in_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW && D3DCULL_CCW );
in_pd3dDevice->SetRenderState( D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_COLOR1 );
in_pd3dDevice->SetFVF(m_pMesh3DText[0]->GetFVF());
m_pMesh3DText[0]->DrawSubset( 0 );
}
return hr;
} |
Partager