MoniWiki¸Þ¸ðÀå_¼ö¾÷D3D
Login:
Password:
´ë¹®|ã±â|¹Ù²ï±Û|¸ñ·Ï|¸Þ¸ðÀå|Ã¥°¥ÇÇ|¿¬²É|¸µÅ©
Edit Diff Reload Search Print Info Mail Help RSS

@ 2004-05-24 @

  ´ÙÀÌ·ºÆ® 3D ¼ö¾÷³»¿ë (ÀÌ»ó¹® »ù °¨»ç^^)

Á¤¸®Çϸ鼭 ´À³¤Á¡; ¼ÒÇÁÆ®¿þ¾î·Î ·»´õ¸µ ÆÄÀÌÇÁ¸¦ ¸¸µé¾î ºÁ¼­ ±×·±Áö
ÁøÂ¥ ÀÏÁÖÀÏ(5ÀÏ) µ¿¾È¿¡ ±âº»ÀûÀ̶ó°í ÇÏÁö¸¸, ´ÙÀÌ·ºÆ®X¸¦ ´Ù ¹è¿î°É º¸¸é ¿ª½Ã ±âÃÊ°¡ Áß¿äÇØ¿ä!!
1 ³ëƼ(1/5): ´ÙÀÌ·ºÆ® 3D-20030901/ ±âº»Ã¢ ¶ì¿ì±â/ »ï°¢Çü ±×¸®±â
2 ³ëƼ(2/5): ´ÙÀÌ·ºÆ® 3D-20030902/ º¯È¯¸ÅÆ®¸¯½º/ (ÀçÁú) ±¤¿ø/ ¹öÅؽº, À妽º ¹öÆÛ
3 ³ëƼ(3/5): ´ÙÀÌ·ºÆ® 3D-20030903/ TextureÀû¿ë/ ¾ËÆĺ귻µù/ ÇÊÅ͸µ(ÀÚµ¿¹Ó¸Ê»ý¼º)/ ¿ÍÀ̾î...
4 ³ëƼ(4/5): ´ÙÀÌ·ºÆ® 3D-20030904/ ¸ÖƼÅؽºÃÄ.../ ¸ÅÆ®¸¯½º º¯È¯°ú ȯ°æ¸Ê
5 ³ëƼ(5/5): ´ÙÀÌ·ºÆ® 3D-20030905/ ½ºÅٽǹöÆÛ/ Data±¸¼º
{_r} ¸Þ¸ðÀåÀ¸·Î µ¹¾Æ°¡±â

1 ³ëƼ(1/5): ´ÙÀÌ·ºÆ® 3D-20030901/ ±âº»Ã¢ ¶ì¿ì±â/ »ï°¢Çü ±×¸®±â #


0901-0.DirectX¶õ
D3D´Â ±¸Á¶Ã¼¸¦ ±âº»ÀûÀ¸·Î ÀÌ¿ë, ¿Þ¼Õ ½Ã°è¹æÇâ
setting...
D3D9.lib
D3D9dt.lib

#include <d3d9.h>

Direct3D 9.0
D3D extension 3DDEX
app Wizard¿¡ µî·Ï
Çȼ¿ µî °¢Á¾ ½¦ÀÌ´õÁö¿ø
ÇÁ·Î±×·¥ °¡´ÉÇÑ ½¦ÀÌ´õ(½¦À̵ù ¾ð¾î)

±âº»ÀûÀ¸·Î <¼±¾ð> --> <·»´õ¸µ>
<ȯ°æ¼³Á¤> --> <DATA ÀÔ·Â/ ó¸®>


0901-1.±âº»Ã¢ ¶ì¿ì±â
1.À©µµ¿ì¸¦ ¸¸µç´Ù.
2.°ÔÀÓ·çÇÁ¸¦ ¸¸µç´Ù.
3.DirectCreat9 ÇÔ¼ö¸¦ ÀÌ¿ë, Com °´Ã¼¸¦ °¡Áö°í ¿Â´Ù.
4.3D->CreateDevice ¸¦ ÀÌ¿ë, Com °´Ã¼¿¡¼­ È­¸é¿¡ ´ëÇÑ ÀÎÅÍÆäÀ̽º¸¦ °¡Áö°í ¿Â´Ù.

   <¼±¾ð>
   LPDIRECT3D9             g_pD3D       = NULL; // Used to create the D3DDevice
   LPDIRECT3DDEVICE9       g_pd3dDevice = NULL; // Our rendering device

   g_pD3D = Direct3DCreate9( D3D_SDK_VERSION );
   g_pD3D->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
                         D3DCREATE_SOFTWARE_VERTEXPROCESSING,
                        &d3dpp, &g_pd3dDevice );
5.Device¿¡¼­ Clear¸¦ ½ÇÇàÇÑ´Ù.

   <·»´õ¸µ>
// Clear the backbuffer to a blue color
   g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );

     ·»´õ¸µ scene

// Present the backbuffer contents to the display
   g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
6.ÇÁ·Î±×·¥ Á¾·á Àü¿¡ ¹Ýµå½Ã »ç¿ëÁßÀÎ ÀÚ¿ø ÇØÁ¦

   <»èÁ¦> Device¸¦ ¸Þ¸ð¸®¿¡¼­ »èÁ¦
    g_pd3dDevice->Release();
    g_pD3D->Release();

0901-2.»ï°¢Çü ±×¸®±â
<¼±¾ð>
// A structure for our custom vertex type
struct D3DLVERTEX
{
FLOAT x, y, z, rhw; // The transformed position for the vertex
DWORD color; // The vertex color
};

// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_D3DLVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)

D3DLVERTEX vertices[] =
{
{ 150.0f, 50.0f, 0.5f, 1.0f, 0xffff0000, }, // x, y, z, rhw, color
{ 250.0f, 250.0f, 0.5f, 1.0f, 0xff00ff00, },
{ 50.0f, 250.0f, 0.5f, 1.0f, 0xff00ffff, },
};

<·»´õ¸µ>
g_pd3dDevice->BeginScene();
{
g_pd3dDevice->SetFVF( D3DFVF_D3DLVERTEX );
g_pd3dDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, 1, vertices, sizeof(D3DLVERTEX) );
}
g_pd3dDevice->EndScene();

2 ³ëƼ(2/5): ´ÙÀÌ·ºÆ® 3D-20030902/ º¯È¯¸ÅÆ®¸¯½º/ (ÀçÁú) ±¤¿ø/ ¹öÅؽº, À妽º ¹öÆÛ #


0902-1.º¯È¯¸ÅÆ®¸¯½º Àû¿ë
Model --(WorldTM)--> World --(ViewTM)--> View --(ProjectTM)--> Viewport
È­¸é¿¡ ·»´õ¸µÀ» Çϱâ À§Çؼ­´Â ÆÄÀÌÇÁ¶óÀÎÀ» µû¶ó °¢°¢ÀÇ ´Ü°è º¯È¯À» À§ÇÑ ¸ÅÆ®¸¯½º°¡ Àû¿ëµÈ´Ù.
¼ÒÇÁÆ®¿þ¾î 3D¿¡ ºñ±³Çؼ­ º¯È¯ ¸ÅÆ®¸¯½º´Â ÀûÁö¸¸, ±×¸¸Å­ API¿¡ ´õ ÀÇÁ¸ÀûÀÌ´Ù.
1) Device->SetTransform(D3DTS_WORLD, &mat);
2) Device->SetTransform(D3DTS_VIEW, &mat);
3) D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f ); ¸ÅÆ®¸¯½º°ª¸¸ ¼³Á¤
Device->SetTransform(D3DTS_PROJECTION, &mat);
4) GetviewDevice->SetFVF( D3DFVF_D3DLVERTEX );
GetViewport(D3DVIEWPORT9 *pViewport ); ÀåÄ¡¿¡ ÇöÀç ¼³Á¤µÇ¾î ÀÖ´Â ºäÆ÷Æ® ÆĶó¹ÌÅ͸¦ ¾ò¾î¿Â´Ù.
SetViewport( // );

-1.º¯È¯¸ÅÆ®¸¯½º ¼ÂÆà ; ¸ÅÆ®¸¯½º¸¦ Àû¿ëÇÏ°Ô µÇ¸é ÁÖº¯°ªµéÀÌ 0.0 - 1.0 »çÀÌÀÇ °ªÀ» °¡Áö¹Ç·Î
Á¤Á¡ÀÇ ÁÂÇ¥(¸ðµ¨ÀÇ Å©±â)¸¦ ½Å°æ½á¾ßÇϸç, ±âÁØÀÌ µÇ´Â Å©±â¸¦ ¼³Á¤ÇÏ´Â °ÍÀÌ ÁÁ´Ù.

     #define D3DFVF_D3DLVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE); 
   //#define D3DFVF_D3DLVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE); - È­¸é¿¡ ¹Ù·Î Ãâ·ÂÇÒ ¶§ »ç¿ë
     RHW °ªÀÌ ÀÖÀ» °æ¿ì º¯È¯ÀÌ ³¡³­ °ÍÀ¸·Î Ãë±ÞÇϱ⠶§¹®¿¡, RHW°ªÀ» Á¦°ÅÇÑ´Ù. --> ±¸Á¶Ã¼ ¸â¹öµµ º¯°æ

     D3DXMATRIXA16 matWorld;                        // world ÁÂÇ¥ º¯È­ ¸ÅÆ®¸¯½º
     D3DXMatrixRotationY( &matWorld, fAngle );         // ¸ÅÆ®¸¯½º º¯È¯(ȸÀü, À̵¿)
     g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
// ----------> world ÁÂÇ¥·Î ÀüÈ­
     D3DXVECTOR3 vEyePt( 0.0f, 3.0f,-5.0f );
     D3DXVECTOR3 vLookatPt( 0.0f, 0.0f, 0.0f );
     D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
     D3DXMATRIXA16 matView; // view ÁÂÇ¥ º¯È­ ¸ÅÆ®¸¯½º
     D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
     g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
// ----------> view ÁÂÇ¥·Î º¯È­
     D3DXMATRIXA16 matProj; // Åõ¿µ ÁÂÇ¥ º¯È¯ ¸ÅÆ®¸¯½º
     D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
     g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
-2.Äøµ°ú ¶óÀÌÆ®ÀÇ Ãʱ⠻óÅ ; ¸éÀÌ µÚÁý¾îÁö°Å³ª ºûÀÇ ¿µÇâÀ» ¹ÞÁö¾Ê´Â ¸ð½ÀÀ» È®ÀÎÇϱâ À§ÇÑ ¼³Á¤
// Device state would normally be set here
g_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE ); // Culling ¸ðµå ²û
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, FALSE ); // Light ²û

-3.Àû¿ë ; ¹öÆÛ¸¦ clear ½ÃŲÈÄ¿¡ Àû¿ë
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
g_pd3dDevice->BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();
...
// End the scene
g_pd3dDevice->EndScene();

0902-2.ÀçÁú; ÀçÁúÀÌ ¾øÀ¸¸é ±¤¿øÈ¿°ú°¡ ³ªÅ¸³ªÁö ¾Ê´Â´Ù.
void SetupMaterial()
{
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 0.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );
}

0902-3.±¤¿ø; Á¤È®ÇÑ ±¤¿øÈ¿°ú¸¦ º¸±â À§Çؼ­´Â Á¤Á¡ÀÇ ³ë¸»º¤ÅÍ°ªÀÌ Çʼö
void SetupLight()
{
D3DXVECTOR3 vecDir; // ±¤¿øÀÇ typeÀÌ D3DLIGHT_DIRECTIONALÀ̹ǷΠ¹æÇâÀÌ ÇÊ¿ä
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(D3DLIGHT9) );
light.Type = D3DLIGHT_DIRECTIONAL; // D3DLIGHT_POINT = 1
light.Diffuse.r = 1.0f; // D3DLIGHT_SPOT = 2,
light.Diffuse.g = 1.0f; // D3DLIGHT_DIRECTIONAL = 3,
light.Diffuse.b = 1.0f;
vecDir = D3DXVECTOR3(cosf(timeGetTime()/350.0f),
1.0f,
sinf(timeGetTime()/350.0f) );
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
light.Range = 1000.0f;
g_pd3dDevice->SetLight( 0, &light );
g_pd3dDevice->LightEnable( 0, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );

// Finally, turn on some ambient light.
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, (DWORD)0x00202020 );
}

0902-3.zbuffer(±íÀÌ)/¹öÅؽº(Á¤Á¡) ¹öÆÛ
<¼±¾ð>
-0.ÇÁ·¹Á¨Å×ÀÌ¼Ç ÆĶó¹ÌÅÍ¿¡¼­ ±íÀÌ ¹öÆÛ¿¡ ´ëÇÑ Á¤º¸¸¦ Ãß°¡
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory( &d3dpp, sizeof(d3dpp) );
...
d3dpp.EnableAutoDepthStencil = true; // ±íÀÌ°ª°ú ½ºÅÙ½Ç È°¼ºÈ­
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

-1.½Ã½ºÅÛ ÃʱâÈ­ºÎºÐ¿¡¼­ ,zbuffer »ç¿ëÀ» ¼³Á¤
// Turn on the zbuffer
g_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );

D3DZB_FALSE - ±íÀÌ ¹öÆÛ¸¦ »ç¿ë ºÒ´ÉÀ¸·Î ÇÑ´Ù.
D3DZB_TRUE - z ¹öÆÛ¸¦ »ç¿ë °¡´ÉÇÏ°Ô ÇÑ´Ù.( ºñµð¿À ¸Þ¸ð¸® ºÎºÐÀ» »ç¿ë)
D3DZB_USEW - w ¹öÆÛ¸¦ »ç¿ë °¡´ÉÇÏ°Ô ÇÑ´Ù.
D3DZB_FORCE_DWORD - ÀÌ ¿­°ÅÇüÀ» °­Á¦ÀûÀ¸·Î 32 ºñÆ® »çÀÌÁî¿¡ ÄÄÆÄÀÏ ÇÑ´Ù.

-2.¹öÅؽº(Á¤Á¡)¹öÆÛ; ½Ã½ºÅÛ ¸Þ¸ð¸®¿¡ µé¾î°¡Áö¸¸ ºñµð¿À¸Þ¸ð¸®¿¡ À§Ä¡
D3D´Â Àåºñüũ°¡ ±âº»ÀûÀ¸·Î Áö¿øÇϸç, ¹öÆÛ¸¦ ÀÌ¿ëÇÏ°íÀÚ ÇÒ °æ¿ì ½Ã½ºÅÛ Áö¿ø¿©ºÎ¸¦ üũÇؾßÇÑ´Ù.!

LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; // Buffer to hold vertices
g_pd3dDevice->CreateVertexBuffer(
4*sizeof(CUSTOMVERTEX), ÃÑÅ©±â = °¹¼ö * Å©±â
0, ½ÃÀÛ
D3DFVF_CUSTOMVERTEX, Æ÷¸Ë
D3DPOOL_DEFAULT, Ç®¼³Á¤
&g_pVB, ±¸Á¶Ã¼ Æ÷ÀÎÅÍ
NULL );
  • D3DPOOL ¿­°ÅÇü; ¸®¼Ò½ºÀÇ ¹öÆÛ¸¦ º¸°ü À¯ÁöÇÏ´Â ¸Þ¸ð¸® Ŭ·¡½º¸¦ Á¤ÀÇÇÑ´Ù.
    D3DPOOL_DEFAULT - º¸Åë, ·ÎÄà ºñµð¿À ¸Þ¸ð¸®¿Í AGP (Accelerated Graphics Port)
    ¸Þ¸ð¸®ÀÇ ¾çÂÊ ¸ðµÎ¸¦ Æ÷ÇÔÇÑ, ºñµð¿À ¸Þ¸ð¸®ÀÌ´Ù
    D3DPOOL_MANAGED - ÇÊ¿ä¿¡ µû¶ó¼­, ÀåÄ¡·ÎºÎÅÍ ¾×¼¼½º ÇÒ ¼ö ÀÖ´Â ¸Þ¸ð¸®¿¡ ÀÚµ¿ÀûÀ¸·Î º¹»ç µÈ´Ù.
    °ü¸®µÇ´Â ¸®¼Ò½º´Â, ½Ã½ºÅÛ ¸Þ¸ð¸®¿¡ ¹é¾÷ µÇ¹Ç·Î, ÀåÄ¡°¡ ¼Õ½ÇÇßÀ» ¶§¿¡ »ý¼º ´Ù½Ã ÇÒ ÇÊ¿ä°¡ ¾ø´Ù
    D3DPOOL_SYSTEMMEM - º¸Åë, 3D ÀåÄ¡¿¡ ÀÇÇØ ¾×¼¼½º ÇÒ ¼ö ¾ø´Â ¸Þ¸ð¸®.
    ½Ã½ºÅÛ RAM ¸¦ »ç¿ëÇÏÁö¸¸, ÆäÀÌ¡ °¡´ÉÇÑ RAM °¡ ÁÙ¾îµé °ÍÀº ¾ø´Ù.
    ÀÌ·¯ÇÑ ¸®¼Ò½º´Â, ÀåÄ¡°¡ ¼Õ½ÇÇصµ »ý¼º ´Ù½Ã ÇÒ ÇÊ¿ä°¡ ¾ø´Ù.
    (½Ã½ºÅÛÀÌ Áö¿øÇÏ´Â ÀåºñÀÎÁö üũÇØ¾ß ÇÑ´Ù.)

  •    -.Á¤Á¡ Á¤º¸  
         vertices[0].position = D3DXVECTOR3(-1.0f,-1.0f, 0.0f);
         vertices[0].normal   = D3DXVECTOR3( -1.0f, 0.0f, 0.0f);
         vertices[0].color = 0xffff0000;
         vertices[1].position = D3DXVECTOR3( 1.0f, -1.0f, 0.0f);
         vertices[1].normal   = D3DXVECTOR3( -1.0f, 0.0f, 0.0f);
         vertices[1].color = 0xff0000ff;
         vertices[2].position = D3DXVECTOR3( 0.0f, 1.0f, 0.0f);
         vertices[2].normal   = D3DXVECTOR3( -1.0f, 0.0f, 0.0f);
         vertices[2].color = 0xffffffff;
    
         CUSTOMVERTEX* pVertices;
         g_pVB->Lock( 0, 0, (void**)&pVertices, 0 );
             DAta rkqt
             memcpy( pVertices, vertices, sizeof(vertices) ); Á¤Á¡ÀÇ Á¤º¸¸¦ ¹öÅؽº Á¤º¸¿¡ Ä«ÇÇ
         g_pVB->Unlock();
    
    <·»´õ¸µ>
    g_pd3dDevice->BeginScene(); // ·»´õ¸µ ¹öÅؽº ¹öÆÛ¸¦ ÀÌ¿ëÇÑ °ÍÀ¸·Î º¯°æ
    // Render the vertex buffer contents
    g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
    g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
    g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 );
    g_pd3dDevice->EndScene();

    0902-4.À妽º ¹öÆÛ
    Á¤Á¡Àº ¹öÅؽº ¹öÆÛ¿¡ ÀúÀåÇØ µÎ°í, ·»´õ¸µ ÇÒ ¶§´Â À妽º ÂüÁ¶ÇÏ´Â ¹æ½ÄÀ¸·Î
    Á¤Á¡¼ø¼­¸¦ ÀúÀåÇϱâ À§ÇÑ ¹è¿­(À妽º) ÇÊ¿ä

    <¼±¾ð>
    LPDIRECT3DINDEXBUFFER9 g_pIndex = NULL; // Our interface for manipulating index buffers
    ...
    WORD ver_index[] ={ 0, 1, 2};
    -1.À妽º ¹öÆÛ »ý¼º
    g_pd3dDevice->CreateIndexBuffer( sizeof(ver_index), - À妽º ÃÑÅ©±â = °¹¼ö(1) * Å©±â
    0, D3DFMT_INDEX16,
    D3DPOOL_DEFAULT, &g_pIndex, NULL );
    -2.À妽º ¹öÆÛ¿¡ Á¤º¸ ¼ÂÆÃ
    <!> g_pd3dDevice->SetIndices(g_pIndex); - À妽º¹öÆÛ ¼ÂÆÃ

    void * indices;
    g_pIndex->Lock(0,0, (void**)&indices,0);
    memcpy( indices, ver_index, sizeof(ver_index) );
    g_pIndex->Unlock();

    <·»´õ¸µ>
    g_pd3dDevice->BeginScene(); // ·»´õ¸µÀ» ÇÒ ¶§, À妽º ¹öÆÛ¸¦ ÀÌ¿ëÇÑ °ÍÀ¸·Î º¯°æ
    g_pd3dDevice->SetStreamSource( 0, g_pVB, 0, sizeof(CUSTOMVERTEX) );
    g_pd3dDevice->SetFVF( D3DFVF_CUSTOMVERTEX );
    // Render the index buffer contents
    g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,3,0,1);
    //g_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, 1 ); - ¹öÅؽº ¹öÆÛ ÀÌ¿ë

    -. Á¤Á¡ ¹è¿­À» Âü°íÇÏ´Â À妽ºÀÇ ¼ø¼­¿¡ µû¶ó, ÁöÁ¤µÈ Áö¿À¸ÞÆ®¸® ±âº»µµÇüÀ» ·»´õ¸µ ÇÑ´Ù.
  • HRESULT DrawIndexedPrimitive(
    D3DPRIMITIVETYPE Type,
    INT BaseVertexIndex,
    UINT MinIndex,
    UINT NumVertices, - Á¤Á¡ÀÇ ÃÑ°¹¼ö
    UINT StartIndex,
    UINT PrimitiveCount ); - Àоî¿Ã À妽º °¹¼ö
    À妽º°¡ 3Á¡À» Âü°íÇÏ´Â ÀϹÝÀûÀÎ °æ¿ì¿¡´Â TyteÀ» D3DPT_TRIANGLELIST·Î ÁöÁ¤.

    ¡Ø Âü°í - ¿©·¯°³ÀÇ ¹öÅؽº¹öÆÛ¿Í À妽º ¹öÆÛ°¡ ÀÖÀ» ¶§,
    ¿øÇÏ´Â ¹öÆÛ¸¦ ¼±ÅÃÇÑ ÈÄ¿¡ DrawÇÑ´Ù
    Device->SetStreamSource( 0, g_pVB_Obj01, 0, sizeof(CUSTOMVERTEX) );
    Device->SetIndices(g_pIndex_Obj01);
    Device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST,0,0,3,0,1);

  • 3 ³ëƼ(3/5): ´ÙÀÌ·ºÆ® 3D-20030903/ TextureÀû¿ë/ ¾ËÆĺ귻µù/ ÇÊÅ͸µ(ÀÚµ¿¹Ó¸Ê»ý¼º)/ ¿ÍÀ̾î... #


    0903-1.TextureÀû¿ë
    <¼±¾ð>
    -1. D3DFVF ; FVF Á¤¼ö¿¡ ÅؽºÃ³ °ü·ÃÀÇ Ç÷¡±× Ãß°¡

    FVF Á¤¼ö ; À¯¿¬ÇÑ Á¤Á¡ Æ÷¸Ë (FVF)Àº, ´ÜÀÏÀÇ µ¥ÀÌÅÍ ½ºÆ®¸²¿¡ ÀÎÅ͸®ºê µÇ¾î ÀúÀå µÇ°í ÀÖ´Â
    Á¤Á¡ÀÇ ³»¿ëÀ» ±â¼úÇϱâ À§Çؼ­ »ç¿ëµÈ´Ù. FVF ÄÚµå´Â, º¸Åë, °íÁ¤ ±â´ÉÀÇ Á¤Á¡ 󸮿¡ ÀÇÇØ
    󸮵Ǵ µ¥ÀÌÅ͸¦ ÁöÁ¤Çϱâ À§Çؼ­ »ç¿ëµÈ´Ù.

    #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1 )
    LPDIRECT3DTEXTURE9 g_pTexture1 = NULL; // Our texture
    LPDIRECT3DTEXTURE9 g_pTexture2 = NULL;

    -2.»ý¼º
    D3DXCreateTextureFromFile( g_pd3dDevice, "..\\banana.bmp", &g_pTexture1 );

    -3.´Ý±â Àü¿¡ »èÁ¦
    g_pTexture1->Release();

    <·»´õ¸µ>
    g_pd3dDevice->SetTexture( 0, g_pTexture1 );
    ¿ÀºêÁ§Æ® 1. ; ¿ÀºêÁ§Æ®1¿¡ g_pTexture1 Àû¿ë

    0903-2.Texture Addressing ; ¸ÊÀ» ºÙÄ¡´Â ¹æ½Ä¿¡ ´ëÇÑ ¼³Á¤
            -. ·»´õ¸µ Àüü¿¡ ¿µÇâÀ» ¹ÌÄ¡±â ¶§¹®¿¡ µð¹ÙÀ̽º¿¡¼­ Á¤ÀÇ.
    <¼³Á¤>
    HRESULT SetTextureStageState(
    DWORD Stage,
    D3DTEXTURESTAGESTATETYPE Type,
    DWORD Value
    );
  • Stage
    in ½ºÅ×ÀÌÆ®°ªÀ» ¼³Á¤ÇÏ´Â ÅؽºÃ³ÀÇ ½ºÅ×ÀÌÁö ½Äº°ÀÚ. ½ºÅ×ÀÌÁö ½Äº°ÀÚ´Â 0 À¸·ÎºÎÅÍ ½ÃÀ۵ȴÙ.
    ÀåÄ¡´Â ÃÖ´ë 8 ¼¼Æ®±îÁö ÅؽºÃ³¸¦ °¡Áú ¼ö°¡ ÀÖÀ¸¹Ç·Î,Stage ·Î ÁöÁ¤ÇÒ ¼ö ÀÖ´Â ÃÖ´ëÄ¡´Â 7 ÀÌ´Ù.
  • D3DSAMPLERSTATETYPE ¿­°ÅÇü
    D3DSAMP_ADDRESSU = 1, u ÁÂÇ¥·Î »ç¿ëÇÏ´Â ÅؽºÃ³¾îµå·¹½Ì¸ðµå. µðÆúÆ®´Â D3DTADDRESS_WRAP
    D3DSAMP_ADDRESSV = 2, v ÁÂÇ¥·Î »ç¿ëÇÏ´Â ÅؽºÃ³¾îµå·¹½Ì¸ðµå. µðÆúÆ®´Â D3DTADDRESS_WRAP
    ...
  • D3DTEXTUREADDRESS ¿­°ÅÇü - Áö¿øµÇ´Â ÅؽºÃ³ ¾îµå·¹½Ì¸ðµå¸¦ ±â¼úÇÏ´Â Á¤¼ö¸¦ Á¤ÀÇ
    typedef enum _D3DTEXTUREADDRESS {
    D3DTADDRESS_WRAP = 1,
    D3DTADDRESS_MIRROR = 2,
    D3DTADDRESS_CLAMP = 3,
    D3DTADDRESS_BORDER = 4,
    D3DTADDRESS_MIRRORONCE = 5,
    D3DTADDRESS_FORCE_DWORD = 0x7fffffff
    } D3DTEXTUREADDRESS;
    <Àû¿ë¿¹>
    Device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_MIRROR );
    Device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP );

  • 0903-3.¾ËÆĺ귻µù
    ¡Ý Z-buffer°¡ ¸ÔÁö ¾Ê±â ¶§¹®¿¡ ¿øÇÏ´Â °á°ú°¡ ³ª¿Àµµ·Ï Àû¿ë ¼ø¼­¿¡ Á¶½ÉÇØ¾ß Çϸç,
    ºÎÇÏ°¡ ¸¹ÀÌ °É¸®±â ¶§¹®¿¡ Àû¿ëÇÒ ¿ÀºêÁ§Æ® ¾Õ¿¡¼­ ÄÑÁÖ°í ²¸ÁØ´Ù.
    <¼³Á¤>
    Device->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
  • D3DSAMPLERSTATETYPE ¿­°ÅÇü
    D3DRS_SRCBLEND = 19, D3DBLEND ¿­°ÅÇüÀÇ ¸â¹öÁß ÇϳªÀÌ´Ù. µðÆúÆ®°ªÀº D3DBLEND_ONE
    D3DRS_DESTBLEND = 20, D3DBLEND ¿­°ÅÇüÀÇ ¸â¹öÁß ÇϳªÀÌ´Ù. µðÆúÆ®°ªÀº D3DBLEND_ZERO
    D3DRS_ALPHABLENDENABLE = 27, ¾ËÆÄ ºí·»µå¿¡ ÀÇÇÑ Åõ¸íÈ­(TRUE¸¦ ¼³Á¤), µðÆúÆ®°ªÀº FALSE
    ¾ËÆÄ È¥ÇÕÀÇ Å¸ÀÔÀº, D3DRS_SRCBLEND ¿Í D3DRS_DESTBLEND ÀÇ ·»´õ¸µ ½ºÅ×ÀÌÆ®¿¡ ÀÇÇØ Á¤ÇØÁø´Ù.
    ...
  • D3DBLEND ¿­°ÅÇü - Áö¿ø µÇ°í ÀÖ´ÂÈ¥ÇÕ ¸ðµå¸¦ Á¤ÀÇ
    typedef enum _D3DBLEND {
    D3DBLEND_ZERO = 1, - È¥ÇÕ °è¼ö´Â, (0, 0, 0, 0)
    D3DBLEND_ONE = 2, - È¥ÇÕ °è¼ö´Â, (1, 1, 1, 1)
    D3DBLEND_SRCCOLOR = 3, - È¥ÇÕ °è¼ö´Â, (Rs, Gs, Bs, As)
    D3DBLEND_INVSRCCOLOR = 4, - È¥ÇÕ °è¼ö´Â, (1 - Rs, 1 - Gs, 1 - Bs, 1 - As)
    ...
    } D3DBLEND
    <Àû¿ë¿¹>
    Device->SetRenderState( D3DRS_ALPHABLENDENABLE, true ); ¾ËÆĺ귣µù

  • 0903-4.ÇÊÅ͸µ; ±ÙÁ¢Á¡, ¼±Çü, À̹漺(³ôÀÌ¿Í ³ÐÀÌÀÇ ºñ¸¦ °í·Á), ¹Ó¸Ê µîÀ» ÀÌ¿ë
    <¼³Á¤>
    Device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT );
  • D3DSAMPLERSTATETYPE ¿­°ÅÇü
    D3DSAMP_MAGFILTER = 5, D3DTEXTUREFILTERTYPE ÇüÀÇ È®´ë ÇÊÅÍ. µðÆúÆ®°ªÀº D3DTEXF_POINT
    D3DSAMP_MINFILTER = 6, D3DTEXTUREFILTERTYPE ÇüÀÇ Ãà¼Ò ÇÊÅÍ. µðÆúÆ®°ªÀº D3DTEXF_POINT
    D3DSAMP_MIPFILTER = 7, Ãà¼Ò½Ã¿¡ »ç¿ëÇÏ´Â ¹Ó¸Ê ÇÊÅÍ. µðÆúÆ®°ªÀº D3DTEXF_NONE
    ...
  • D3DTEXTUREFILTERTYPE ¿­°ÅÇü
    typedef enum _D3DTEXTUREFILTERTYPE {
    D3DTEXF_NONE = 0, - ¹Ó¸Ê 󸮸¦ ¹«È¿·Î ÇÑ´Ù. ·¡½ºÅͶóÀÌÀú´Â ´ë½Å¿¡ È®´ë ÇÊÅ͸¦ »ç¿ë
    D3DTEXF_POINT = 1, - ÅؽºÃ³ÀÇ È®´ë ÇÊÅÍ ¶Ç´Â Ãà¼Ò ÇÊÅͷμ­ »ç¿ëµÇ´Â Á¡ÇÊÅ͸µ.
    ¸ñÀûÀÇ Çȼ¿°ª¿¡ °¡Àå °¡±î¿î ÁÂÇ¥¸¦ °¡Áö´Â Åؼ¿À» »ç¿ëÇÑ´Ù. ¹Ó¸Ê ·¹º§°£¿¡ »ç¿ëµÇ´Â ÅؽºÃ³ ÇÊÅÍ´Â,
    ÃÖ±ÙÁ¡¹Ó¸Ê ÇÊÅÍÀÌ´Ù. ·¡½ºÅͶóÀÌÀú´Â °¡Àå °¡±î¿î ¹Ó¸Ê ÅؽºÃ³ÀÇ Åؼ¿·ÎºÎÅÍÀÇ »öÀ» »ç¿ëÇÑ´Ù
    D3DTEXF_LINEAR = 2, - ÅؽºÃ³ÀÇ È®´ë ÇÊÅÍ ¶Ç´Â Ãà¼Ò ÇÊÅͷμ­ »ç¿ëµÇ´Â ¹ÙÀ̸®´Ï¾Æ º¸°£ ÇÊÅ͸µ.
    ¸ñÀûÀÇ Çȼ¿À» µÑ·¯½Î´Â 2 ¡¿ 2 ¿µ¿ªÀÇ Åؼ¿ÀÇ Áß·®°¨ ÷ºÎ Æò±ÕÀ» »ç¿ëÇÑ´Ù. ¹Ó¸Ê ·¹º§°£¿¡ »ç¿ëµÇ´Â
    ÅؽºÃ³ ÇÊÅÍ´Â, Æ®¶óÀÌ ¸®´Ï¾î ¹Ó¸Ê º¸°£ÀÌ´Ù. ·¡½ºÅͶóÀÌÀú´Â, °¡Àå °¡±î¿î ¹Ó¸Ê ÅؽºÃ³ 2 Á¡À¸·ÎºÎÅÍÀÇ
    Åؼ¿À» »ç¿ëÇØ, Çȼ¿»öÀ» ¼±Çü º¸°£ ÇÑ´Ù. (°ÔÀÓ¿¡¼­ ±âº»ÀûÀ¸·Î »ç¿ë)
    D3DTEXF_ANISOTROPIC = 3, - ÅؽºÃ³ÀÇ È®´ë ÇÊÅÍ ¶Ç´Â Ãà¼Ò ÇÊÅͷμ­ »ç¿ëµÇ´Â ºñµî¹æ¼º ÅؽºÃ³ ÇÊÅ͸µ.
    ÅؽºÃ³ ´Ù°¢Çü°ú ½ºÅ©¸° Æò¸é°£ÀÇ °¢µµÀÇ »óÀ§¿¡ ÀÇÇØ ÀϾ´Â Àϱ׷¯ÁüÀ» º¸Á¤ÇÑ´Ù.
    D3DTEXF_PYRAMIDALQUAD = 6, - ÅؽºÃ³ÀÇ È®´ë ÇÊÅÍ ¶Ç´Â Ãà¼Ò ÇÊÅͷμ­ »ç¿ëÇÏ´Â 4 »ùÇÃÀÇ ÅÙÆ® ÇÊÅÍ
    D3DTEXF_GAUSSIANQUAD = 7, - ÅؽºÃ³ÀÇ È®´ë ÇÊÅÍ ¶Ç´Â Ãà¼Ò ÇÊÅͷμ­ »ç¿ëÇÏ´Â 4 »ùÇÃÀÇ Gauss ÇÊÅÍ.
    D3DTEXF_FORCE_DWORD = 0x7fffffff
    ÀÌ ¿­°ÅÇüÀ» °­Á¦ÀûÀ¸·Î 32 ºñÆ® »çÀÌÁî¿¡ ÄÄÆÄÀÏ ÇÑ´Ù. ÀÌ °ªÀº »ç¿ëµÇÁö ¾Ê¾Ò´Ù.
    } D3DTEXTUREFILTERTYPE;

    -1.ÀÚµ¿¹Ó¸Ê»ý¼º
  • HRESULT CreateTexture( UINT Width, - in ÃÖ»óÁ¤µµÀÇ ÅؽºÃ³ÀÇ Æø (Çȼ¿ ´ÜÀ§).
    UINT Height, - in ÃÖ»óÁ¤µµÀÇ ÅؽºÃ³ÀÇ ³ôÀÌ (Çȼ¿ ´ÜÀ§)
    UINT Levels, - in ÅؽºÃ³¿¡ ÀÖ´Â ·¹º§ÀÇ ¼ö. 0 À» ÁöÁ¤ Çϸé, ¹Ó¸ÊÈ­ ÅؽºÃ³¸¦
    Áö¿øÇÏ´Â Çϵå¿þ¾î¿¡ ´ëÇØ, 1 ¡¿ 1 Çȼ¿±îÁöÀÇ ¸ðµç ÅؽºÃ³ ¼­ºê ·¹º§À» »ý¼ºÇÑ´Ù.
    DWORD Usage,
    D3DFORMAT Format, - in D3DFORMAT ¿­°ÅÇüÀÇ ¸â¹ö. ÅؽºÃ³ÀÇ Àü·¹º§ÀÇ Æ÷¸ËÀ» ±â¼ú
    D3DPOOL Pool, - D3DPOOL_MANAGED; S/W·Î »ç¿ëÇÒ °ÇÁö, H/W·Î »ç¿ëÇÒ °ÇÁö ÀÚµ¿ ¼³Á¤À¸·Î
    °ü¸®µÇ´Â ¸®¼Ò½º´Â, ½Ã½ºÅÛ ¸Þ¸ð¸®¿¡ ¹é¾÷ µÇ¹Ç·Î, ÀåÄ¡°¡ ¼Õ½ÇÇßÀ» ¶§¿¡ »ý¼º ´Ù½Ã ÇÒ ÇÊ¿ä°¡ ¾ø´Ù
    IDirect3DTexture9** ppTexture,
    - [out, retval] »ý¼º µÈ ÅؽºÃ³ ¼Ò½º¸¦ ³ªÅ¸³»´Â IDirect3DTexture9 ÀÎÅÍÆäÀ̽ºÀÇ Æ÷ÀÎÅÍ
    HANDLE* pHandle ); -in ¿¹¾àÀÌ ³¡³­ »óÅÂ. ÀÌ ÆĶó¹ÌÅÍ´Â NULL ·Î ¼³Á¤
  • D3DFORMAT ¿­°ÅÇü Áß ºÎÈ£ ¾øÀ½ Æ÷¸Ë - Çȼ¿ ¼ÎÀÌ´õ¿¡ ´ëÇÑ ÅؽºÃ³ ÁÖ¼Ò ¸í·ÉÀÇ ÀÛµ¿Äڵ带 ÂüÁ¶ÇÑ´Ù.
    D3DFMT_R8G8B8 / °ª20/ 24 ºñÆ®ÀÇ RGB Çȼ¿ Æ÷¸ËÀ¸·Î, ä³Î ±Ùó 8 ºñÆ®¸¦ »ç¿ë
    D3DFMT_A8R8G8B8 / °ª21/ 32 ºñÆ®ÀÇ ¾ËÆÄ Ã·ºÎ ARGB Çȼ¿ Æ÷¸ËÀ¸·Î, ä³Î ±Ùó 8 ºñÆ®¸¦ »ç¿ë
    D3DFMT_R5G6B5 / °ª23/ 16 ºñÆ®ÀÇ RGB Çȼ¿ Æ÷¸ËÀ¸·Î, »¡°­ 5 ºñÆ®, ÃÊ·Ï 6 ºñÆ®, ÆĶû 5 ºñÆ®¸¦ »ç¿ë
    ...
    <Àû¿ë¿¹>
    Device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
    Device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
    Device->CreateTexture(256, 256, 5, 0, D3DFMT_R8G8B8, D3DPOOL_MANAGED, &g_pTexture1, NULL);

  • 0903-5.¿ÍÀ̾îÇÁ·¹ÀÓ·»´õ¸µ
    <¼³Á¤>
    Device->SetRenderState( D3DRS_FILLMODE, D3DFILL_WIREFRAME);
  • D3DFILLMODE ¿­°ÅÇü - ÀüºÎ Ä¥ÇØ ¸ðµå¸¦ ±â¼úÇÏ´Â Á¤¼ö¸¦ Á¤ÀÇÇÑ´Ù.
    typedef enum _D3DFILLMODE {
    D3DFILL_POINT = 1, - Á¡À» ÀüºÎ Ä¥ÇÑ´Ù.
    D3DFILL_WIREFRAME = 2, - ¿ÍÀ̾î ÇÁ·¹ÀÓÀ» ÀüºÎ Ä¥ÇÑ´Ù.
    D3DFILL_SOLID = 3, - ¸éÀ» ÀüºÎ Ä¥ÇÑ´Ù.
    D3DFILL_FORCE_DWORD = 0x7fffffff
    } D3DFILLMODE;
  • 4 ³ëƼ(4/5): ´ÙÀÌ·ºÆ® 3D-20030904/ ¸ÖƼÅؽºÃÄ.../ ¸ÅÆ®¸¯½º º¯È¯°ú ȯ°æ¸Ê #


    0904-1.¸ÖƼÅؽºÃÄ
    <¼³Á¤> Àû¿ëÇÏ´Â À§Ä¡´Â texture¸¦ ºÒ·¯¿Â ´ÙÀ½¿¡¼­ À§Ä¡Çϸç,
    ¿øÇÏ´Â ¿ÀºêÁ§Æ®ÀÇ texture¸¦ »Ñ¸®±â Àü¿¡ À§Ä¡ÇÑ´Ù.
    0.HRESULT SetTexture( DWORD Stage, - in ÅؽºÃ³¸¦ ¼³Á¤ÇÏ´Â ½ºÅ×ÀÌÁö ½Äº°ÀÚ
    IDirect3DBaseTexture9 *pTexture ); - in IDirect3DBaseTexture9 ÀÎÅÍÆäÀ̽ºÀÇ ÅؽºÃÄ Æ÷ÀÎÅÍ

    0.HRESULT SetTextureStageState( DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value );
    - ÇöÀç ÇÒ´çÇÒ ¼ö ÀÖ´Â ÅؽºÃ³¿¡ ½ºÅ×ÀÌÆ®°ªÀ» ¼³Á¤

  • D3DTEXTURESTAGESTATETYPE ¿­°ÅÇü - ÅؽºÃ³ ½ºÅ×ÀÌÁö ½ºÅ×ÀÌÆ®¸¦ Á¤ÀÇ
    D3DTSS_COLOROP = 1,
    D3DTSS_COLORARG1 = 2,
    D3DTSS_COLORARG2 = 3,
    D3DTSS_ALPHAOP = 4,
    D3DTSS_ALPHAARG1 = 5,
    D3DTSS_ALPHAARG2 = 6,
    D3DTSS_BUMPENVMAT00 = 7,
    D3DTSS_BUMPENVMAT01 = 8,
    D3DTSS_BUMPENVMAT10 = 9,
    D3DTSS_BUMPENVMAT11 = 10,
    D3DTSS_TEXCOORDINDEX = 11,
    ...
    D3DTA (ÅؽºÃ³ Àμö Á¤¼ö) - ÀåÄ¡¿¡ ´ëÀÀÇÏ´Â °¢°¢ÀÇ ÅؽºÃ³ ½ºÅ×ÀÌÁö´Â 2 °³ÀÇ ÅؽºÃ³ Àμö¸¦
    °¡Áö¸ç ÀÌ·¯ÇÑ Àμö´Â ÅؽºÃ³ÀÇ »ö°ú ¾ËÆÄ Ã¤³Î¿¡ ¿µÇâÀ» ÁØ´Ù.
    D3DTA_CURRENT - ÅؽºÃ³ Àμö´Â ÀüÀÇ È¥ÇÕ ½ºÅ×ÀÌÁöÀÇ °á°úÀÌ´Ù.
    ÃÖÃÊÀÇ ÅؽºÃ³ ½ºÅ×ÀÌÁö (½ºÅ×ÀÌÁö 0)¿¡¼­´Â, ÀÌ Àμö´Â D3DTA_DIFFUSE ¿Í °°´Ù.
    D3DTA_DIFFUSE - gouraud shading ó¸®Áß¿¡ Á¤Á¡ÀÇ ¼ººÐÀ¸·ÎºÎÅÍ º¸°£ ÇØ ¾òÀ» ¼ö
    ÀÖ´ø µðÇ»Áî»ö
    D3DTA_TEXTURE - ÅؽºÃ³ ½ºÅ×ÀÌÁöÀÇ ÅؽºÃ³ Ä÷¯ÀÌ´Ù. Çã°¡´Â Àбâ Àü¿ëÀÌ´Ù.
    D3DTA_SPECULAR - gouraud shading ó¸®Áß¿¡ Á¤Á¡ÀÇ ¼ººÐÀ¸·ÎºÎÅÍ º¸°£ µÈ ½ºÆåÅ¥·¯»öÀÌ´Ù.

  • D3DTEXTUREOP ¿­°ÅÇü - ½ºÅ×ÀÌÁö¸¶´Ù ÅؽºÃ³ È¥ÇÕ Ã³¸®¸¦ Á¤ÀÇ
    typedef enum _D3DTEXTUREOP {
    D3DTOP_DISABLE = 1,
    D3DTOP_SELECTARG1 = 2, - ½ºÅ×ÀÌÁöÀÇ ÃÖÃÊÀÇ »ö, ¶Ç´Â ¾ËÆÄ Àμö¸¦ º¯°æÇÏÁö ¾Ê°í Ãâ·ÂÀ¸·Î¼­ »ç¿ë
    D3DTOP_SELECTARG2 = 3, - ½ºÅ×ÀÌÁöÀÇ 2¹ø° »ö, ¶Ç´Â ¾ËÆÄ Àμö¸¦ º¯°æÇÏÁö ¾Ê°í Ãâ·ÂÀ¸·Î¼­ »ç¿ë
    D3DTOP_MODULATE = 4, - ÀμöÀÇ ¼ººÐÀ» °ö¼ÀÇÑ´Ù.
    D3DTOP_MODULATE2X = 5,
    D3DTOP_MODULATE4X = 6,
    D3DTOP_ADD = 7, - ÀμöÀÇ ¼ººÐÀ» µ¡¼À ÇÑ´Ù.
    D3DTOP_ADDSIGNED = 8,
    D3DTOP_ADDSIGNED2X = 9,
    D3DTOP_SUBTRACT = 10,
    D3DTOP_ADDSMOOTH = 11,
    ...
    } D3DTEXTUREOP;

  •    <Àû¿ë>
          Device->SetRenderState( D3DRS_COLORVERTEX, false );
          Device->SetTexture(0, g_pTexture1);
          Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, 0);
          Device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
          Device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
    	
          Device->SetTexture(1, g_pTexture3);
          Device->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
          Device->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
          Device->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
          Device->SetTextureStageState(1, D3DTSS_COLOROP,   D3DTOP_MODULATE);
    
       Âü°í -  ·»´õ¸µ½Ã, vertexÀÇ »ö»ó¿µÇâÀ» ¹ÞÁö ¾ÊÀ»·Á¸é false·Î ¼ÂÆÃÇÑ´Ù.
          (ÁÖÀÇ, false·Î ¼³Á¤½Ã ´Ù¸¥ ¿É¼Ç¿¡µµ ¿µÇâÀ» ¹ÌÄ£´Ù.)  
          Device->SetRenderState( D3DRS_COLORVERTEX, TRUE );
    

    0904-2.¶óÀÌÆ®¸Ê; ±âº»ÀûÀ¸·Î ¸ÖƼÅؽºÃĸ¦ ÀÀ¿ë(±Û·Î¿ì·Î È°¿ë)¸ÖƼÅؽºÃÄ
    Device->SetTextureStageState(1, D3DTSS_COLOROP, MODULATE2X); - ( A*B ) <<1 (¹à¾ÆÁü)
    Device->SetTextureStageState(1, D3DTSS_COLOROP, MODULATE4X); - ( A*B ) <<2 (´õ¿í ¹à¾ÆÁü)

    0904-3.Á¤Á¡ÀÇ »ö°úÀÇ È¥ÇÕ
    Device->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
    Device->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); - ½ºÅ×ÀÌÁö2¿¡ Á¤Á¡»öÀ» ÀÌ¿ë
    Device->SetTextureStageState(0, D3DTSS_COLOROP, D3DTEXTUREOP ¿­°ÅÇü);

    0904-4.µðÅ×ÀϸÊ; º®À̳ª ¹Ù´Ú¿¡ °¡±õ°Ô Á¢±ÙÇßÀ» ¶§, º¸´Ù ¼±¸íÇÏ°Ô ·»´õ¸µ
    D3DTEXTUREOP ¿­°ÅÇüÀ» D3DTOP_ADDSIGNED¸¦ »ç¿ë ( (A+B)-0.5 )
    D3DTOP_ADDSIGNED2X ( (A+B)-0.5 ) << 1

    0904-5.¾ËÆÄ¿¬»ê; Åõ¸íµµ¿¡¸¸ ¿µÇâÀ» ¹ÌÄ£´Ù. Èæ¹éÀÌ ¸íÈ®ÇÒ¼ö·Ï ¼±¸íÇÏ°Ô ºüÁü
    <¼³Á¤>
    // Alphablendging È°¼ºÈ­°¡ ÇÊ¿ä
    pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, true );
    pd3dDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_ONE ) ;
    pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCALPHA );

    0904-6.¸ÅÆ®¸¯½º º¯È¯°ú ȯ°æ¸Ê
    <¼³Á¤>
    0.HRESULT SetTransform( D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix );
    - ´ÜÀÏ ÀåÄ¡ÀÇ º¯È¯ °ü·Ã ½ºÅ×ÀÌÆ®¸¦ ¼³Á¤
  • D3DTRANSFORMSTATETYPE ¿­°ÅÇü - º¯È¯ ½ºÅ×ÀÌÆ®ÀÇ °ªÀ» ±â¼úÇÏ´Â Á¤¼ö¸¦ Á¤ÀÇ
    D3DTS_VIEW = 2, - ºä º¯È¯ Çà·Ä·Î¼­ ¼³Á¤µÇ´Â º¯È¯ Çà·ÄÀ» ½Äº°, µðÆúÆ®°ªÀº NULL(´ÜÀ§Çà·Ä)
    D3DTS_PROJECTION = 3, - Åõ¿µ º¯È¯ Çà·Ä·Î¼­ ¼³Á¤µÇ´Â º¯È¯ Çà·ÄÀ» ½Äº°, µðÆúÆ®°ªÀº NULL(´ÜÀ§Çà·Ä)
    D3DTS_TEXTURE0 = 16, - ÁöÁ¤µÈ ÅؽºÃ³ ½ºÅ×ÀÌÁö·Î ¼³Á¤µÇ´Â º¯È¯ Çà·ÄÀ» ½Äº°
    D3DTS_TEXTURE1 = 17, - ÁöÁ¤µÈ ÅؽºÃ³ ½ºÅ×ÀÌÁö·Î ¼³Á¤µÇ´Â º¯È¯ Çà·ÄÀ» ½Äº°
    ...

    0.HRESULT SetTextureStageState( DWORD Stage, D3DTEXTURESTAGESTATETYPE Type, DWORD Value );
  • D3DTEXTURETRANSFORMFLAGS ¿­°ÅÇüÀÇ ¸â¹ö.
    D3DTSS_TEXTURETRANSFORMFLAGS = 24,
    ÀÌ ÅؽºÃ³ ½ºÅ×ÀÌÁöÀÇ ÅؽºÃ³ ÁÂÇ¥ÀÇ º¯È¯À» Á¦¾îÇÑ´Ù. µðÆúÆ®°ªÀº, D3DTTFF_DISABLE

  • D3DTEXTURETRANSFORMFLAGS ¿­°ÅÇü - ÅؽºÃ³ ½ºÅ×ÀÌÁö ½ºÅ×ÀÌÆ®ÀÇ °ªÀ» Á¤ÀÇ
    typedef enum _D3DTEXTURETRANSFORMFLAGS {
    D3DTTFF_DISABLE = 0, - ÅؽºÃ³ ÁÂÇ¥´Â ·¡½ºÅͶóÀÌÀú¿¡ Á÷Á¢ °Ç³×¹Þ´Â´Ù.
    D3DTTFF_COUNT1 = 1, - ·¡½ºÅͶóÀÌÀú´Â, 1D ÀÇ ÅؽºÃ³ ÁÂÇ¥¸¦ »óÁ¤ÇÑ´Ù.
    D3DTTFF_COUNT2 = 2, - 2D ÀÇ ÅؽºÃ³ ÁÂÇ¥¸¦ »óÁ¤ÇÑ´Ù.
    D3DTTFF_COUNT3 = 3, - 3D ÀÇ ÅؽºÃ³ ÁÂÇ¥¸¦ »óÁ¤ÇÑ´Ù.
    D3DTTFF_COUNT4 = 4, - 4D ÀÇ ÅؽºÃ³ ÁÂÇ¥¸¦ »óÁ¤ÇÑ´Ù.
    D3DTTFF_PROJECTED = 256, - ÅؽºÃ³ ÁÂÇ¥´Â, ·¡½ºÅͶóÀÌÀú¿¡°Ô °Ç³×Áö±â Àü¿¡ ¸¶Áö¸· ¿ä¼Ò·Î ¸ðµÎ ºÐÇÒ
    ¿¹¸¦ µé¾î, ÀÌ Ç÷¡±×°¡ D3DTTFF_COUNT3 ¿Í ÇÔ²² ÁöÁ¤µÇ°í ÀÖ´Â °æ¿ì,
    1¹ø° ¹× 2¹ø°ÀÇ ÅؽºÃ³ ÁÂÇ¥´Â, ·¡½ºÅͶóÀÌÀú¿¡°Ô °Ç³×Áö±â Àü¿¡, 3¹ø°ÀÇ ÁÂÇ¥·Î ºÐÇҵȴÙ.
    D3DTTFF_FORCE_DWORD = 0x7fffffff - ÀÌ ¿­°ÅÇüÀ» °­Á¦ÀûÀ¸·Î 32 ºñÆ® »çÀÌÁî¿¡ ÄÄÆÄÀÏ
    } D3DTEXTURETRANSFORMFLAGS;

    0.D3DTEXTURESTAGESTATETYPE ¿­°ÅÇü
    D3DTSS_TEXCOORDINDEX = 11, - ÀÌ ÅؽºÃ³ ½ºÅ×ÀÌÁö¿¡¼­ »ç¿ëÇϱâ À§ÇØ ¼³Á¤µÈ ÅؽºÃ³ ÁÂÇ¥ÀÇ À妽º.
    Á¤Á¡ 1 °³¿¡ ´ëÇؼ­ ÃÖ´ë 8 ¼¼Æ®±îÁöÀÇ ÅؽºÃ³ ÁÂÇ¥¸¦ ¼³Á¤ÇÒ ¼ö ÀÖ´Ù.
    Á¤Á¡ÀÌ, ÁöÁ¤µÈ À妽ºÀÇ ÅؽºÃ³ ÁÂÇ¥ ¼¼Æ®¸¦ Æ÷ÇÔÇÏÁö ¾ÊÀº °æ¿ì´Â, u ¹× v ÁÂÇ¥ µðÆúÆ®(0,0)

    0.D3DTSS_TCI - µå¶óÀ̹ö ÅؽºÃ³ ÁÂÇ¥ÀÇ ´É·Â Ç÷¡±×(ÅؽºÃ³ º¯È¯¿ëÀÇ ÀÔ·Â ÅؽºÃ³ ÁÂÇ¥¸¦ ÀÚµ¿ÀûÀ¸·Î »ý¼º)
    #define/ °ª / ¼³¸í
    D3DTSS_TCI_PASSTHRU / 0x00000000L / Á¤Á¡ Æ÷¸Ë³»ÀÇ ÁöÁ¤µÈ ÅؽºÃ³ ÁÂÇ¥¸¦ »ç¿ë, °ªÀº Á¦·Î
    D3DTSS_TCI_CAMERASPACENORMAL / 0x00010000L / ½ºÅ×ÀÌÁöÀÇ ÅؽºÃ³ º¯È¯¿¡ ´ëÇÑ
    ÀÔ·Â ÅؽºÃ³ ÁÂÇ¥·Î¼­ Ä«¸Þ¶ó °ø°£¿¡ º¯È¯ µÈ Á¤Á¡ ¹ý¼±À» »ç¿ë
    D3DTSS_TCI_CAMERASPACEPOSITION / 0x00020000L / Ä«¸Þ¶ó °ø°£¿¡ º¯È¯ µÈ Á¤Á¡ À§Ä¡¸¦ »ç¿ë
    D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR/ 0x00030000L /
    Ä«¸Þ¶ó °ø°£¿¡ º¯È¯ µÈ ¹Ý»ç º¤Å͸¦ »ç¿ëÇϸç,
    ¹Ý»ç º¤ÅÍ´Â, ÀÔ·Â Á¤Á¡ À§Ä¡ ÁÂÇ¥¿Í ¹ý¼± º¤ÅͷκÎÅÍ °è»êµÈ´Ù.
    D3DTSS_TCI_SPHEREMAP / 0x00040000L / ÁöÁ¤µÈ ÅؽºÃ³ ÁÂÇ¥¸¦ ±¸¸éÀÇ ¸ÊÇο¡ »ç¿ëÇÑ´Ù.

  •    <Àû¿ë>
       -1.¸ÊÁÂÇ¥ º¯È¯
          D3DXMATRIXA16 mat;          - ¸ÅÆ®¸¯½º ¼±¾ð
          D3DXMatrixIdentity( &mat);  - ÃʱâÈ­(±¸Á¶Ã¼ÀÇ ¸â¹ö¸¦ Á÷Á¢ ¼ÂÆÃÇÒ ¼ö ÀÖ´Ù.)
          D3DXMatrixRotationY( &mat, 5.0f);  - º¯È¯(SRT); °¢°¢ÀÇ º¯È¯ Àû¿ëÈÄ ¸ÅÆ®¸¯½º¸¦ °öÇØÁØ´Ù.
          Device->SetTransform( D3DTS_TEXTURE0, &mat);  - Çà·ÄÀ» D3DTS_TEXTURE0¿¡ Àû¿ë
          Device->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );  
                - D3DTS_TEXTURE0·Î ºÎÅÍ º¯È¯µÈ uv °ªÀ» °¡Áö°í ¿Â´Ù
       -2.ȯ°æ¸Ê»ý¼º
          Device->SetTextureStageState(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION);  
    

    5 ³ëƼ(5/5): ´ÙÀÌ·ºÆ® 3D-20030905/ ½ºÅٽǹöÆÛ/ Data±¸¼º #


    0905-1.½ºÅĽǹöÆÛ; Çʿ俵¿ª¿¡¸¸ ·»´õ¸µ ÁöÁ¤(Ŭ¸®ÇÎ)
    • D3DPRESENT_PARAMETERS d3dpp;
      d3dpp.EnableAutoDepthStencil = true; // ±íÀÌ°ª°ú ½ºÅÙ½Ç È°¼ºÈ­
      d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8; // ±íÀÌ 24, ½ºÅÄ½Ç 8bit »ç¿ë
      ...

    0905-2.Data±¸¼º
    -1.¸ðµç Data´Â ·Îµù½Ã ÃʱâÈ­ µÇ¸ç,
    Data¸¦ ¹ÙÅÁÀ¸·Î ±¸¼ºµÈ Index¿Í flag¿¡ ÀÇÇØ Á¶À۵ȴÙ.
    ==> °á°úÀûÀ¸·Î ¸ðµç °á°ú´Â IndexÀÇ Á¶ÇÕÀÇ »ê¹°(ÀÚ·á ÀÌ¿ëÀÇ È¿À²¼º ³ôÀÓ)
    -2.ij¸¯ÅÍ
    ¸Þ½¬¸â¹ö(ÃʱâData¸¦ ¸Å½¬·Î À籸¼º)
    -.Vertex List ; Á¤Á¡ÀÇ ±¸¼º -> ±¸Á¶Ã¼ Çü½ÄÀ¸·Î ÁÂÇ¥¿Í ³ë¸», Ä÷¯µî Á¤Á¡¸¸ÀÇ ¿ä¼Ò·Î ±¸¼º
    -.Index List
    -.VerNum
    -.IndexNum
    -.¸Þ½¬À̸§
    -.¸Þ½¬ID
    ¾Ö´Ï¸ÞÀ̼Ǹâ¹ö
    Texture
    Material
    ÇൿÁ¤º¸(À§Ä¡, ÀΰøÁö´É ÆÐÅÏ)
    °¢Á¾flag
    ...
    -3.Vertex List µîÀ» Æ÷ÀÎÅÍ·Î ¹ÞÀ» °æ¿ì´Â µ¿ÀûÇÒ´çÀÌ ÇÊ¿ä

    {_r} ¸Þ¸ðÀåÀ¸·Î µ¹¾Æ°¡±â

    December, 2024
    1234567
    891011121314
    15161718192021
    22232425262728
    293031 

    ¿À´ÃÀÇ ½ÇÆд Áö³­³¯ÀÇ ÇãºñÇÑ ½Ã°£µéÀÇ º¹¼ö´Ù(³ªÆú·¹¿Ë)

    Ã¥°¥ÇÇ_Nidec
    InterMap
    Ã¥°¥ÇÇ_EffectiveC_03
    µüÁö_±Û·Î¹ú°ÔÀÓ»ê¾÷Trend_2011
    last modified 2004-06-16 16:47:26
    °íÄ¡±â|ã±â|ÂÊ Áö¿ì±â|ºñ½ÁÇÑ ÂÊ Valid XHTML 1.0! Valid CSS! powerd by MoniWiki
    0.2538 sec