æç»ç³»ã®ã¯ã©ã¹è¨è¨ãé£ãããã
ã¨ãããå
¨è²ãããããªãããè¨è¨ãããããªãã
ããåãã¨ãããä½å¹´ãä½ãç´ãç¶ãã¦ãæ°ãããã
ãã¬ã¬ã
ãã£ã¦ãorããããã²ã¼ã ã¨ã
è¿æ³ã¡ã¢
ä»ãã£ã¦ãä½å
ã¼ã«ãã®ä¼èª¬ 夢幻ã®ç æè¨ (DS)ããã£ããã¼ã«ããã¦ã¦é¢ç½ã
罪ã¨ç½° (Wii)ããªã¡ã¬ãã¼ã¹ãç³»ãé£ãã
ã¹ããªã¼ããã¡ã¤ã¿ã¼4 (PC)
ã¹ã«ãããã³ãã¼ãº (Wii)
ä»å¾ããããä½å
ãã¨ããã¿ (360)
ã¢ãµã·ã³ã¯ãªã¼ã2 (PS3)
ãã¹ããã©ããã2 (PS3)
æ§ææ£ (Wii)
ã¹ã¼ãã¼ãã¼ãã¼ããªãª (Wii)
ã¼ã«ãã®ä¼èª¬ 大å°ã®æ±½ç¬ (DS)
ã²ã¼ã çºæã¬ãã¥ã¼ç¬¬4å¼¾ãã¤ã¼ã¹7ã
ã©ãã©ãã²ã¼ã ãã£ã¦é¢ç½ãã®ãè¦ã¤ãããä¼ç»ã
ã¤ã¼ã¹ã·ãªã¼ãºã¯åãã¬ã¤ã
ãã£ã¦ãorããããã²ã¼ã ã¨ã
è¿æ³ã¡ã¢
ä»ãã£ã¦ãä½å
ã¤ã¼ã¹7 (PSP)ãããããã
ã¹ããªã¼ããã¡ã¤ã¿ã¼4 (PC)ããªããªãä¸éããªã
ã¹ã«ãããã³ãã¼ãº (Wii)ãããæ¾ç½®ä¸
ä»å¾ããããä½å
罪ã¨ç½°(Wii)
ãã¨ããã¿(360)
ã¢ãµã·ã³ã¯ãªã¼ã2(PS3)
ãã¹ããã©ããã2(PS3)
æ§ææ£(Wii)
ã¹ã¼ãã¼ãã¼ãã¼ããªãª(Wii)
DrawPrimitiveå¨ã
ãDrawPrimitiveç³»ã¯é ãã®ã§å¼ã³åºãåæ°ãæ¸ãããã¨ããè¨èãããè³ã«ããã
DrawPrimitiveç³»ã¨ã¯è¨ãããããªDirectXã®ä»£è¡¨çãªæç»é¢æ°ã§ãé ç¹ãã¼ã¿ããç·ãããªã´ã³ãæç»ãããç³»ã®ä»²éã¨ã㦠DrawPrimitive / DrawIndexedPrimitive / DrawPrimitiveUP / DrawIndexedPrimitiveUP ãããã
Indexedãä»ãã¦ãæ¹ã¯ã¤ã³ããã¯ã¹ãããã¡ãç¨ãããã®ãåãé ç¹ãå ±æããããªã´ã³ãæãã¨ãã«é ç¹ãããã¡å ã§åããã¼ã¿ãéè¤ããã®ã¯ã ããªã®ã§ã使ããã¼ã¿ãã¤ã³ããã¯ã¹ãããã¡ã§æå®ããã
UPãä»ãã¦ããªãæ¹ã¯é ç¹ãããã¡ã¨ã¤ã³ããã¯ã¹ãããã¡ãã°ã©ãã£ãã¯ã¹ã«ã¼ãã管çããé åã«ç½®ããUPãä»ãã¦ããæ¹ã¯ã¢ããªã±ã¼ã·ã§ã³å´ã§ç¢ºä¿ãããã®ããã®ã¾ã¾ä½¿ãã
DrawPrimitiveã使ã£ã¦æ¿ããªããã£ã±ãæç»ãããããªããã°ã©ã ãä½ãç解ããã«æ¸ãã¨æ¬¡ã®ãããªæãã«ãªãã
struct CUSTOMVERTEX { float x,y,z; DWORD dwColor; float u1,v1; }; struct DRAWINFO { LPDIRECT3DVERTEXBUFFER9 pVB_; // é ç¹ãããã¡ï¼è¨å®æ¸ã¿ï¼ LPDIRECT3DVERTEXDECLARATION9 pVD_; // é ç¹å®£è¨ LPDIRECT3DTEXTURE9 pTexture_; // ãã¯ã¹ã㣠D3DXMATRIX worldMatrix_; // å¤æè¡å }; LPDIRECT3DDEVICE9 pDevice; CEffect* pEffect; // ID3DXEffectã®ã©ããã¼ã ã¨æã£ã¦ãã D3DXMATRIX view, proj; vector<DRAWINFO> drawList; pEffect->Begin(); pEffect->SetViewMatrix(&view); pEffect->SetProjMatrix(&proj); for(int i=0; i<drawList.size(); i++){ pEffect->SetTexture(drawList[i].pTexture_); pEffect->SetWorldMatrix(&(drawList[i].worldMatrix_)); pDevice->SetStreamSource(0, drawList[i].pVB_, 0, sizeof(CUSTOMVERTEX)); pDevice->SetVertexDeclaration(drawList[i].pVD_); pEffect->BeginPass(); pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); pEffect->EndPass(); } pEffect->End();
ã覧ã®ã¨ãããæ¿ããªã®æ°ã ãDrawPrimitiveãå¼ã°ãã¦ããã
ããããã£ã¦ããªãã®ã ããDrawPrimitiveã¯æºã¾ã£ã¦ããããªããã£ããã¼ã¿ã®æç»éå§ãåå³ããé¢æ°ãªã®ã§ã1åå¼ãã§ãã¾ãã¨å¸°ã£ã¦ããã¾ã§æ¬¡ã®æç»ãéå§ã§ããªãããªã®ã§ããªã´ã³1æã¨ãã®å°ãªããã¼ã¿ãæç»ããã ãã§1åå¼ãã§ãã¾ãã¨ãªã¼ãã¼ãããã大ãããã¦é
ããªãããã ã
ããã§è¤æ°ã®ããªã´ã³ãã¼ã¿ã1ã¤ã®é ç¹ãããã¡ã«ã¾ã¨ãã¦ãã¾ãã1åã®DrawPrimitiveã§ãã¾ããã
struct DRAWINFO { CUSTOMVERTEX pVertex_[4]; D3DXMATRIX worldMatrix_; }; CUSTOMVERTEX pAllVertex[VERTEX_MAX]; // ã¾ã¨ãã¦è»¢éããããã®å ãããã¡ LPDIRECT3DVERTEXBUFFER9 pVB; LPDIRECT3DVERTEXDECLARATION9 pVD; LPDIRECT3DTEXTURE9 pTexture; for(int i=0; i<drawList.size(); i++){ // ãããããªãã®ã§èªåã§åº§æ¨å¤æãã¦ãã CUSTOMVERTEX* p = drawList[i].pVertex_; D3DXVECTOR4 pos[] = { D3DXVECTOR4(p[0].x, p[0].y, p[0].z, 1.0f), D3DXVECTOR4(p[1].x, p[1].y, p[1].z, 1.0f), D3DXVECTOR4(p[2].x, p[2].y, p[2].z, 1.0f), D3DXVECTOR4(p[3].x, p[3].y, p[3].z, 1.0f) }; D3DXVECTOR4 trans[4]; for(int j=0; j<4; j++){ D3DXVec4Transform(&(trans[j]), &(pos[j]), &(drawList[i].worldMatrix_)); } // ä¸è§å½¢ãªã¹ãã®é ç¹é ã«ãããã¡ãæ§æ CUSTOMVERTEX tempVertex[] = { { trans[0].x, trans[0].y, trans[0].z, p[0].dwColor, p[0].u1, p[0].v1 }, { trans[1].x, trans[1].y, trans[1].z, p[1].dwColor, p[1].u1, p[1].v1 }, { trans[2].x, trans[2].y, trans[2].z, p[2].dwColor, p[2].u1, p[2].v1 }, { trans[3].x, trans[3].y, trans[3].z, p[3].dwColor, p[3].u1, p[3].v1 }, { trans[2].x, trans[2].y, trans[2].z, p[2].dwColor, p[2].u1, p[2].v1 }, { trans[1].x, trans[1].y, trans[1].z, p[1].dwColor, p[1].u1, p[1].v1 } }; memcpy(pAllVertex + i*6, tempVertex, sizeof(CUSTOMVERTEX)*6); } void* pData; pVB->Lock(0, 0, (void**)&pData, 0); memcpy(pData, pAllVertex, sizeof(CUSTOMVERTEX) * 6 * drawList.size()); pVB->Unlock(); pEffect->Begin(); pEffect->SetViewMatrix(&view); pEffect->SetProjMatrix(&proj); pEffect->SetTexture(pTexture); pDevice->SetStreamSource(0, pVB, 0, sizeof(CUSTOMVERTEX)); pDevice->SetVertexDeclaration(pVD); pEffect->BeginPass(); pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, drawList.size() * 2); // ä¸è§å½¢ãªã¹ãã使ã£ã¦ã°ãã°ãã«æç» pEffect->EndPass(); pEffect->End();
ãã®ããæ¹ã«ããã¾ããããããªãç¹ãããã
æç»ã1åã¨ãããã¨ã¯ãªãã¸ã§ã¯ããã¨ã«åå¥ã®å¤æè¡åãæå®ãããã¨ãã§ããªãã®ã§ããã¼ã«ã«é ç¹åº§æ¨ãç´æ¥æ¸ãæããªããã°ãªããªãã®ã§ããã
å
ã«æ¸ããããã«DrawPrimitiveã§ã¯é ç¹ãããã¡ã¯ã°ã©ãã£ãã¯ã¹ã«ã¼ãã管çããé åã«ç½®ãããããããããæ¸ãæããããã«ã¯ããã¯ããªããã°ãªããããããããªãéãï¼ãããï¼ã
ããã§ä»åº¦ã¯ã¦ã¼ã¶ã¼é åã®é ç¹ãããã¡ãç´æ¥è»¢éã§ããDrawPrimitiveUPã使ãã
pEffect->Begin(); pEffect->SetViewMatrix(&view); pEffect->SetProjMatrix(&proj); pEffect->SetTexture(pTexture); pEffect->BeginPass(); pDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST, drawList.size() * 2, pAllVertex, sizeof(CUSTOMVERTEX) ); pEffect->EndPass(); pEffect->End();
ãããããã¨ã«ãã£ã¦ããããé«éåããããRADEON HD 4850ã§ã20%ãããéããªã£ããå¤ãã«ã¼ãã ã¨ãã£ã¨æ©æµããããããããªãã
ãããã§è¦ã¦ãã¨DrawPrimitiveUPã使ã£ã¦ãã人ãå¤ãå°è±¡ããã£ãã®ã¯ããããäºæ
ãªã®ãã¨æ³åãããã
ããã¡ãã£ã¨å¾ ã¦ããã¨æã£ãæ¹ãããã ããã
ããã ã¨ãã¯ã¹ãã£ã¨ã1ã¤ãã使ããªããããï¼
ãããªã®ã ã
æç»å¼ã³åºãã1åã«ãããããªãã¸ã§ã¯ããã¨ã®å¤æè¡åãè¨å®ã§ããªããªã£ãã®ã¨åæ§ã«ããã¯ã¹ãã£ã®åå¥è¨å®ãã§ããªãã®ã§ããã
ã¤ã¾ãä¸åº¦ã«å©ãæç»ãªã¹ãã®ä¸ã§ã¯ãã¯ã¹ãã£ãªã©ã®æç»ãã©ã¡ã¼ã¿ãå
±éãã¦ããå¿
è¦ãããã¨ãããã¨ããããããªãã£ã©ã®ãã¯ã¹ãã£ã§ããªãã¹ã1æã«ã¾ã¨ãã¦ãããã»ããããã®ã¯ãããããçç±ã®ããã ï¼èªã¿è¾¼ãã¨ãã«1åã§ããããã¨ããã®ããããï¼ã
ã¨ãããããªã®ã§ãå ¨ãå¥åã®ãã¯ã¹ãã£ã使ãã¡ãã·ã¥ã¨ããä»ã«ãã¢ã«ãã¡å¤ãããªãããã®ãã©ã¡ã¼ã¿ãåå¥ã«è¨å®ãããã¨ããå ´åã«ã¯ãããããå¥ã®æç»ãªã¹ããç¨æããªããã°ãªããªãã
ãããã»ã»ã»ãªããªããã¾ããããªãããã ãªã
ã¾ã¨ãã
- DrawPrimitive
é ç¹ãã¼ã¿ããã£ã±ããã£ã¦å¼ã³åºããªã¼ãã¼ããããç¡è¦ã§ãããã¯ã¹ãã£ã¨ãã®ãã©ã¡ã¼ã¿ãåå¥ã«ããã¡ãã·ã¥ã®æç»ã«ä½¿ãã
- DrawPrimitiveUP
é ç¹ãã¼ã¿ã®æ¸ãæããæ¯è¼ç容æã§ãã¯ã¹ãã£ãªã©ã®ãã©ã¡ã¼ã¿ãå ±éããããæ¿ããªç³»ã«ä½¿ãã
- æç»ãªã¹ã
ç°ãªãæç»ãã©ã¡ã¼ã¿ãã¨ã«å¥ã ã®æç»ãªã¹ããä½ããæç»æ å ±ããããã¡ãªã³ã°ãã¦ããã¦ãå¾ã§è©²å½ããæç»ãªã¹ãã«æ¯ãåãã¦ã¾ã¨ãã¦æç»ããã¨ãã¶ãå¹çãããã
ã²ã¼ã çºæã¬ãã¥ã¼ç¬¬3å¼¾ããã©ã¸ã¼ã« ããããªãæã®å»å¢ãã
ã©ãã©ãã²ã¼ã ãã£ã¦é¢ç½ãã®ãè¦ã¤ãããä¼ç»ã
ä»åã¯ããªããã¿ãã¬ãããã®ã§æ³¨æã