本文整理汇总了C++中LPD3DXMESH::DrawSubset方法的典型用法代码示例。如果您正苦于以下问题:C++ LPD3DXMESH::DrawSubset方法的具体用法?C++ LPD3DXMESH::DrawSubset怎么用?C++ LPD3DXMESH::DrawSubset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPD3DXMESH
的用法示例。
在下文中一共展示了LPD3DXMESH::DrawSubset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: render
void render()
{
assert(g_pd3dDevice);
camera();
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(255, 0, 0), 1.0f, 0);
g_pd3dDevice->BeginScene();
{
switch(g_object) {
case sphere:
g_pSphereMesh->DrawSubset(0);
break;
case cube:
g_pCubeMesh->DrawSubset(0);
break;
case torus:
g_pTorusMesh->DrawSubset(0);
break;
default:
assert(!"Invalid object");
break;
}
}
g_pd3dDevice->EndScene();
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
g_rotation += ROTATION_DELTA;
}
示例2: render
VOID render(){
g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(192, 192, 192), 1.0f, 0);
if(SUCCEEDED(g_pDevice->BeginScene())){
setWorldMatrix();
//First, Render the not transparent part
for(DWORD i=0; i<g_dwNumMaterials; ++i){
if(g_pMeshMaterials[i].Diffuse.a == 1.0f){
g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}
}
//Second , Render the transparent part
for(DWORD i=0; i<g_dwNumMaterials; ++i){
if(g_pMeshMaterials[i].Diffuse.a != 1.0f){
g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}
}
g_pDevice->EndScene();
}
g_pDevice->Present(NULL, NULL, NULL, NULL);
}
示例3: RenderScene
//*************************************************************************************************************
void RenderScene(LPD3DXEFFECT effect, int what)
{
D3DXMATRIX inv;
D3DXVECTOR4 uv(1, 1, 1, 1);
D3DXVECTOR4 spec(1, 1, 1, 1);
for( int i = 0; i < numobjects; ++i )
{
SceneObject& obj = objects[i];
if( obj.behavior == what )
{
D3DXMatrixInverse(&inv, 0, &obj.world);
effect->SetMatrix("matWorld", &obj.world);
effect->SetMatrix("matWorldInv", &inv);
if( obj.type == FLOOR )
{
uv.x = uv.y = 3;
spec = D3DXVECTOR4(0.2f, 0.2f, 0.2f, 20.0f);
effect->SetVector("uv", &uv);
effect->SetVector("matSpecular", &spec);
effect->CommitChanges();
device->SetTexture(0, texture2);
box->DrawSubset(0);
}
else if( obj.type == CRATE )
{
uv.x = uv.y = 1;
spec = D3DXVECTOR4(0.2f, 0.2f, 0.2f, 20.0f);
effect->SetVector("uv", &uv);
effect->SetVector("matSpecular", &spec);
effect->CommitChanges();
device->SetTexture(0, texture3);
box->DrawSubset(0);
}
else if( obj.type == SKULL )
{
uv.x = uv.y = 1;
spec = D3DXVECTOR4(0.75f, 0.75f, 0.75f, 80.0f);
effect->SetVector("uv", &uv);
effect->SetVector("matSpecular", &spec);
effect->CommitChanges();
device->SetTexture(0, texture1);
skull->DrawSubset(0);
}
}
}
}
示例4: Render
void Render(HWND hWnd)
{
g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
g_pDevice->BeginScene();
SetMatrix();
if (::GetAsyncKeyState(0x31) & 0x8000f)
g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
if (::GetAsyncKeyState(0x32) & 0x8000f)
g_pDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
if (::GetAsyncKeyState(0x51) & 0x8000f)
SetLight(g_pDevice, 1);
if (::GetAsyncKeyState(0x57) & 0x8000f)
SetLight(g_pDevice, 2);
if (::GetAsyncKeyState(0x45) & 0x8000f)
SetLight(g_pDevice, 3);
D3DXMatrixTranslation(&g_WorldMatrix[0], -3.0f, -3.0f, 0.0f);
g_WorldMatrix[0] = g_WorldMatrix[0] * R;
g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[0]);
g_pTeapot->DrawSubset(0);
D3DXMatrixTranslation(&g_WorldMatrix[1], 3.0f, -3.0f, 0.0f);
g_WorldMatrix[1] = g_WorldMatrix[1] * R;
g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[1]);
g_pCube->DrawSubset(0);
D3DXMatrixTranslation(&g_WorldMatrix[2], 3.0f, 3.0f, 0.0f);
g_WorldMatrix[2] = g_WorldMatrix[2] * R;
g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[2]);
g_pTorus->DrawSubset(0);
D3DXMatrixTranslation(&g_WorldMatrix[3], -3.0f, 3.0f, 0.0f);
g_WorldMatrix[3] = g_WorldMatrix[3] * R;
g_pDevice->SetTransform(D3DTS_WORLD, &g_WorldMatrix[3]);
g_pSphere->DrawSubset(0);
RECT rect;
GetClientRect(hWnd, &rect);
int count = _stprintf_s(g_strFPS, 20, TEXT("FPS : %0.3f"), GetFPS());
g_pFont->DrawText(NULL, g_strFPS, count, &rect, DT_TOP | DT_RIGHT, D3DCOLOR_XRGB(255, 239, 136));
g_pDevice->EndScene();
g_pDevice->Present(NULL, NULL, NULL, NULL);
}
示例5: render_1
//-----------------------------------------------------------------------------
// Name: render_1()
// Desc:
//-----------------------------------------------------------------------------
void render_1( void )
{
D3DXMATRIX matView;
D3DXMATRIX matWorld;
D3DXMATRIX matRotation;
D3DXMATRIX matTranslation;
// Now we can clear just view-port's portion of the buffer to green...
g_pd3dDevice_1->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_COLORVALUE( 0.0f, 1.0f, 0.0f, 1.0f ), 1.0f, 0 );
g_pd3dDevice_1->BeginScene();
// For the left view-port, leave the view at the origin...
D3DXMatrixIdentity( &matView );
g_pd3dDevice_1->SetTransform( D3DTS_VIEW, &matView );
// ... and use the world matrix to spin and translate the teapot
// out where we can see it...
D3DXMatrixRotationYawPitchRoll( &matRotation, D3DXToRadian(g_fSpinX), D3DXToRadian(g_fSpinY), 0.0f );
D3DXMatrixTranslation( &matTranslation, 0.0f, 0.0f, 5.0f );
matWorld = matRotation * matTranslation;
g_pd3dDevice_1->SetTransform( D3DTS_WORLD, &matWorld );
g_pd3dDevice_1->SetMaterial( &g_teapotMtrl );
g_pTeapotMesh_1->DrawSubset(0);
g_pd3dDevice_1->EndScene();
// We're done! Now, we just call Present()
g_pd3dDevice_1->Present( NULL, NULL, NULL, NULL );
}
示例6: DrawMeshContainer
void XEnitity::DrawMeshContainer(LPD3DXMESHCONTAINER pMeshContainerBase, LPD3DXFRAME pFrameBase) const
{
CUSTOM_FRAME* pFrame = (CUSTOM_FRAME*)pFrameBase;
CUSTOM_MESHCONTAINER* pMeshContainer = (CUSTOM_MESHCONTAINER*)pMeshContainerBase;
if(pMeshContainer->pSkinInfo){
D3DXMATRIX Ident;
D3DXMatrixIdentity(&Ident);
m_d3ddev->SetTransform(D3DTS_WORLD, &Ident);
}
else{
m_d3ddev->SetTransform(D3DTS_WORLD, &pFrame->exCombTransformationMatrix);
}
unsigned int NumMaterials = pMeshContainer->NumMaterials;
for(unsigned int i = 0; i < NumMaterials; ++i){
m_d3ddev->SetMaterial(&pMeshContainer->pExMaterials[i]);
m_d3ddev->SetTexture(0, pMeshContainer->pExTextures[i]);
LPD3DXMESH pMeshToDraw = (pMeshContainer->pSkinInfo) ? pMeshContainer->pExSkinMesh : pMeshContainer->MeshData.pMesh;
pMeshToDraw->DrawSubset(i);
}
return;
}
示例7: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render(bool b_AutoRotation, bool b_WireframeMode)
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Setup the world, view, and projection matrices
// SetupMatrices();
if (b_AutoRotation) SetupMatrices();
g_pd3dDevice->SetRenderState(D3DRS_FILLMODE, (b_WireframeMode) ? D3DFILL_WIREFRAME : D3DFILL_SOLID);
g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, (b_WireframeMode) ? D3DCULL_NONE : D3DCULL_CCW);
// D3DRenderer are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i = 0; i < g_dwNumMaterials; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
// End the scene
g_pd3dDevice->EndScene();
}
// Present the backbuffer contents to the display
// g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例8: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
// Begin the scene
g_pd3dDevice->BeginScene();
// Setup the world, view, and projection matrices
SetupMatrices();
// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i=0; i<g_dwNumMaterials; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
// End the scene
g_pd3dDevice->EndScene();
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例9: Render
void Render()
{
g_pd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0);
g_pd3dDevice->BeginScene();
D3DXMATRIXA16 matWorld;
D3DXMatrixRotationY(&matWorld, timeGetTime() / 1000.0f);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
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;
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);
D3DXMATRIXA16 matProj;
D3DXMatrixPerspectiveFovLH(&matProj, D3DX_PI / 4, 1.0f, 1.0f, 100.0f);
g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &matProj);
for (DWORD i = 0; i < g_dwNumMaterials; i++)
{
g_pd3dDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pd3dDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}
g_pd3dDevice->EndScene();
g_pd3dDevice->Present(0, 0, 0, 0);
}
示例10: Render
//-----------------------------------------------------------------------------
// Desc: 渲染场景
//-----------------------------------------------------------------------------
VOID Render()
{
// 清除缓冲区
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(0,0,255), 1.0f, 0 );
//开始渲染场景
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
SetWorldMatrix(); //设置世界矩阵
//逐块渲染网格模型
for( DWORD i=0; i<g_dwNumMaterials; i++ )
{
//设置材料和纹理
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
//渲染模型
g_pMesh->DrawSubset( i );
}
//场景渲染结束
g_pd3dDevice->EndScene();
}
//在屏幕上显示场景
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例11: Game_Run
void Game_Run(HWND window)
{
if (!d3ddev) return;
DirectInput_Update();
d3ddev->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0,0,100), 1.0f, 0);
// slow rendering to approximately 60 fps
if (timeGetTime() > screentimer + 14)
{
screentimer = GetTickCount();
//start rendering
if (d3ddev->BeginScene())
{
//rotate the view
D3DXMATRIX matWorld;
D3DXMatrixRotationY(&matWorld, timeGetTime()/1000.0f);
d3ddev->SetTransform(D3DTS_WORLD, &matWorld);
//draw the mesh
mesh->DrawSubset(0);
//stop rendering
d3ddev->EndScene();
d3ddev->Present(NULL, NULL, NULL, NULL);
}
}
//exit with escape key or controller Back button
if (KEY_DOWN(VK_ESCAPE)) gameover = true;
if (controllers[0].wButtons & XINPUT_GAMEPAD_BACK) gameover = true;
}
示例12: render
VOID render(){
g_pDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB(192, 192, 192), 1.0f, 0);
if(SUCCEEDED(g_pDevice->BeginScene())){
//Render the Shutter
g_pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
g_pDevice->SetTransform(D3DTS_WORLD, &g_matShutter);
g_pDevice->SetStreamSource(0, g_pShutter, 0, sizeof(CUSTOMVERTEX));
g_pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
g_pDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2);
//Render the Mesh
g_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
g_pDevice->SetTransform(D3DTS_WORLD, &g_matTank);
for(DWORD i=0; i<g_dwNumMaterials; ++i){
g_pDevice->SetMaterial(&g_pMeshMaterials[i]);
g_pDevice->SetTexture(0, g_pMeshTextures[i]);
g_pMesh->DrawSubset(i);
}//Render the Mesh
g_pDevice->EndScene();
}
g_pDevice->Present(NULL, NULL, NULL, NULL);
}
示例13: Render
//랜더
void Render(int timeDelta)
{
//화면 청소
if (SUCCEEDED(g_pDevice->Clear(
0, //청소할 영역의 D3DRECT 배열 갯수 ( 전체 클리어 0 )
NULL, //청소할 영역의 D3DRECT 배열 포인터 ( 전체 클리어 NULL )
D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL, //청소될 버퍼 플레그 ( D3DCLEAR_TARGET 컬러버퍼, D3DCLEAR_ZBUFFER 깊이버퍼, D3DCLEAR_STENCIL 스텐실버퍼
D3DCOLOR_XRGB(0,0,0), //컬러버퍼를 청소하고 채워질 색상( 0xAARRGGBB )
1.0f, //깊이버퍼를 청소할값 ( 0 ~ 1 0 이 카메라에서 제일가까운 1 이 카메라에서 제일 먼 )
0 //스텐실 버퍼를 채울값
)))
{
//화면 청소가 성공적으로 이루어 졌다면... 랜더링 시작
g_pDevice->BeginScene();
//r.SetTranslate(Vector3(0, 0, -498)); // teapot
g_pDevice->SetTransform(D3DTS_WORLD, (D3DXMATRIX*)&g_LocalTm);
g_pDevice->SetMaterial(&g_Mtrl);
if (g_Mesh)
g_Mesh->DrawSubset(0);
//랜더링 끝
g_pDevice->EndScene();
//랜더링이 끝났으면 랜더링된 내용 화면으로 전송
g_pDevice->Present( NULL, NULL, NULL, NULL );
}
}
示例14: Render
//-----------------------------------------------------------------------------
// Name: Render()
// Desc: Draws the scene
//-----------------------------------------------------------------------------
VOID Render()
{
// Clear the backbuffer and the zbuffer
g_pd3dDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER,
D3DCOLOR_XRGB( 0, 0, 0 ), 1.0f, 0 );
// Begin the scene
if( SUCCEEDED( g_pd3dDevice->BeginScene() ) )
{
// Setup the world, view, and projection matrices
SetupMatrices();
SetupLights();
// Meshes are divided into subsets, one for each material. Render them in
// a loop
for( DWORD i = 0; i < g_dwNumMaterials; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &g_pMeshMaterials[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
D3DXMATRIXA16 mat;
D3DXMatrixTranslation( &mat, 1,0,0 );
g_pd3dDevice->SetTransform( D3DTS_WORLD, &mat );
for( DWORD i = 0; i < g_dwNumMaterials2; i++ )
{
// Set the material and texture for this subset
g_pd3dDevice->SetMaterial( &g_pMeshMaterials2[i] );
g_pd3dDevice->SetTexture( 0, g_pMeshTextures2[i] );
// Draw the mesh subset
g_pMesh->DrawSubset( i );
}
// End the scene
g_pd3dDevice->EndScene();
}
LPDIRECT3DTEXTURE9* pTemp = g_pMeshTextures;
g_pMeshTextures = g_pMeshTextures2;
g_pMeshTextures2 = pTemp;
// Present the backbuffer contents to the display
g_pd3dDevice->Present( NULL, NULL, NULL, NULL );
}
示例15: RenderScene
// 3D 물체등을 그린다.
void RenderScene()
{
// 뷰 행렬을 만든다.
D3DXMATRIXA16 matView;
D3DXVECTOR3 vEyePt(gWorldCameraPosition.x, gWorldCameraPosition.y, gWorldCameraPosition.z);
D3DXVECTOR3 vLookatPt(0.0f, 0.0f, 0.0f);
D3DXVECTOR3 vUpVec(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&matView, &vEyePt, &vLookatPt, &vUpVec);
// 투영행렬을 만든다.
D3DXMATRIXA16 matProjection;
D3DXMatrixPerspectiveFovLH(&matProjection, FOV, ASPECT_RATIO, NEAR_PLANE, FAR_PLANE);
// 프레임마다 0.4도씩 회전을 시킨다.
gRotationY += 0.4f * PI / 180.0f;
if (gRotationY > 2 * PI)
{
gRotationY -= 2 * PI;
}
// 월드행렬을 만든다.
D3DXMATRIXA16 matWorld;
D3DXMatrixRotationY(&matWorld, gRotationY);
// 월드/뷰/투영행렬을 미리 곱한다.
D3DXMATRIXA16 matWorldView;
D3DXMATRIXA16 matWorldViewProjection;
D3DXMatrixMultiply(&matWorldView, &matWorld, &matView);
D3DXMatrixMultiply(&matWorldViewProjection, &matWorldView, &matProjection);
// 쉐이더 전역변수들을 설정
gpEnvironmentMappingShader->SetMatrix("gWorldMatrix", &matWorld);
gpEnvironmentMappingShader->SetMatrix("gWorldViewProjectionMatrix", &matWorldViewProjection);
gpEnvironmentMappingShader->SetVector("gWorldLightPosition", &gWorldLightPosition);
gpEnvironmentMappingShader->SetVector("gWorldCameraPosition", &gWorldCameraPosition);
gpEnvironmentMappingShader->SetVector("gLightColor", &gLightColor);
gpEnvironmentMappingShader->SetTexture("DiffuseMap_Tex", gpStoneDM);
gpEnvironmentMappingShader->SetTexture("SpecularMap_Tex", gpStoneSM);
gpEnvironmentMappingShader->SetTexture("NormalMap_Tex", gpStoneNM);
gpEnvironmentMappingShader->SetTexture("EnvironmentMap_Tex", gpSnowENV);
// 쉐이더를 시작한다.
UINT numPasses = 0;
gpEnvironmentMappingShader->Begin(&numPasses, NULL);
{
for (UINT i = 0; i < numPasses; ++i)
{
gpEnvironmentMappingShader->BeginPass(i);
{
// 구체를 그린다.
gpTeapot->DrawSubset(0);
}
gpEnvironmentMappingShader->EndPass();
}
}
gpEnvironmentMappingShader->End();
}