青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

天行健 君子當自強而不息

Direct3D中的繪制(5)

這個程序創建并渲染幾種不同的能夠使用D3DXCreate*函數創建的3D物體。

Uses a left-handed coordinate system to create a mesh containing an axis-aligned box.

HRESULT D3DXCreateBox(
LPDIRECT3DDEVICE9 pDevice,
FLOAT Width,
FLOAT Height,
FLOAT Depth,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created box mesh.
Width
[in] Width of the box, along the x-axis.
Height
[in] Height of the box, along the y-axis.
Depth
[in] Depth of the box, along the z-axis.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created box is centered at the origin.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Uses a left-handed coordinate system to create a mesh containing a cylinder.

HRESULT D3DXCreateCylinder(
LPDIRECT3DDEVICE9 pDevice,
FLOAT Radius1,
FLOAT Radius2,
FLOAT Length,
UINT Slices,
UINT Stacks,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created cylinder mesh.
Radius1
[in] Radius at the negative Z end. Value should be greater than or equal to 0.0f.
Radius2
[in] Radius at the positive Z end. Value should be greater than or equal to 0.0f.
Length
[in] Length of the cylinder along the z-axis.
Slices
[in] Number of slices about the main axis.
Stacks
[in] Number of stacks along the main axis.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created cylinder is centered at the origin, and its axis is aligned with the z-axis.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Uses a left-handed coordinate system to create a mesh containing a torus.

HRESULT D3DXCreateTorus(
LPDIRECT3DDEVICE9 pDevice,
FLOAT InnerRadius,
FLOAT OuterRadius,
UINT Sides,
UINT Rings,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created torus mesh.
InnerRadius
[in] Inner-radius of the torus. Value should be greater than or equal to 0.0f.
OuterRadius
[in] Outer-radius of the torus. Value should be greater than or equal to 0.0f.
Sides
[in] Number of sides in a cross-section. Value must be greater than or equal to 3.
Rings
[in] Number of rings making up the torus. Value must be greater than or equal to 3.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created torus is centered at the origin, and its axis is aligned with the z-axis. The inner radius of the torus is the radius of the cross-section (the minor radius), and the outer radius of the torus is the radius of the central hole.

This function returns a mesh that can be used later for drawing or manipulation by the application.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Uses a left-handed coordinate system to create a mesh containing a sphere.

HRESULT D3DXCreateSphere(
LPDIRECT3DDEVICE9 pDevice,
FLOAT Radius,
UINT Slices,
UINT Stacks,
LPD3DXMESH * ppMesh,
LPD3DXBUFFER * ppAdjacency
);

Parameters

pDevice
[in] Pointer to an IDirect3DDevice9 interface, representing the device associated with the created sphere mesh.
Radius
[in] Radius of the sphere. This value should be greater than or equal to 0.0f.
Slices
[in] Number of slices about the main axis.
Stacks
[in] Number of stacks along the main axis.
ppMesh
[out] Address of a pointer to the output shape, an ID3DXMesh interface.
ppAdjacency
[out] Address of a pointer to an ID3DXBuffer interface. When the method returns, this parameter is filled with an array of three DWORDs per face that specify the three neighbors for each face in the mesh. NULL can be specified.

Return Values

If the function succeeds, the return value is D3D_OK. If the function fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DXERR_INVALIDDATA, E_OUTOFMEMORY.

Remarks

The created sphere is centered at the origin, and its axis is aligned with the z-axis.

This function creates a mesh with the D3DXMESH_MANAGED creation option and D3DFVF_XYZ | D3DFVF_NORMAL flexible vertex format (FVF).

Builds a matrix using the specified offsets.

D3DXMATRIX * D3DXMatrixTranslation(
D3DXMATRIX * pOut,
FLOAT x,
FLOAT y,
FLOAT z
);

Parameters

pOut
[in, out] Pointer to the D3DXMATRIX structure that is the result of the operation.
x
[in] X-coordinate offset.
y
[in] Y-coordinate offset.
z
[in] Z-coordinate offset.

Return Values

Pointer to a D3DXMATRIX structure that contains a translated transformation matrix.

Remarks

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMATRIXTranslation can be used as a parameter for another function.

運行截圖:

源程序:

/**************************************************************************************
 Renders several D3DX shapes in wireframe mode and has the camera fly around the scene.  
 Demonstrates the D3DXCreate* functions, and demonstrates more complex transformations 
 used to position the objects in the world and move the camera around the world.
 *************************************************************************************
*/

#include 
"d3dUtility.h"

#pragma warning(disable : 
4100)

#define TEAPOT_MESH        0
#define BOX_MESH        1
#define CYLINDER_MESH    2
#define TORUS_MESH        3
#define SPHERE_MESH        4
#define NUM_MESH        5

const int WIDTH  = 640;
const int HEIGHT = 480;

IDirect3DDevice9
*    g_d3d_device = NULL;
ID3DXMesh
*            g_object_meshes[NUM_MESH];

// world matrices for each object.
// these matrices specify the location of the objects in the world.
D3DXMATRIX g_object_world_matrices[NUM_MESH];

////////////////////////////////////////////////////////////////////////////////////////////////////

bool setup()
{    
    
// create the teapot geometry
    D3DXCreateTeapot(g_d3d_device, &g_object_meshes[TEAPOT_MESH], NULL);
    D3DXCreateBox(g_d3d_device, 
2.0f2.0f2.0f&g_object_meshes[BOX_MESH], NULL);
    D3DXCreateCylinder(g_d3d_device, 
1.0f1.0f3.0f1010&g_object_meshes[CYLINDER_MESH], NULL);
    D3DXCreateTorus(g_d3d_device, 
1.0f3.0f1010&g_object_meshes[TORUS_MESH], NULL);
    D3DXCreateSphere(g_d3d_device, 
1.0f1010&g_object_meshes[SPHERE_MESH], NULL);

    
// Build world matrices - position the objects in world space.
    
// For example, g_object_world_matrices[1] will position g_object_meshes[1] at (-5, 0, 5).
    
// Likewise, g_object_world_matrices[2] will position g_object_meshes[2] at (5, 0, -5).
    D3DXMatrixTranslation(&g_object_world_matrices[TEAPOT_MESH],    0.0f0.0f0.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[BOX_MESH],       -5.0f0.0f,  5.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[CYLINDER_MESH],  5.0f0.0f,  5.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[TORUS_MESH],       -5.0f0.0f-5.0f);
    D3DXMatrixTranslation(
&g_object_world_matrices[SPHERE_MESH],    5.0f0.0f-5.0f);

    
// set the projection matrix
    D3DXMATRIX proj;
    D3DXMatrixPerspectiveFovLH(
&proj, D3DX_PI * 0.5f, (float)WIDTH/HEIGHT, 1.0f1000.0f);
    g_d3d_device
->SetTransform(D3DTS_PROJECTION, &proj);

    
// set wireframe mode render state
    g_d3d_device->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);

    
return true;
}

void cleanup()
{
    
for(int i = 0; i < NUM_MESH; i++)
        safe_release
<ID3DXMesh*>(g_object_meshes[i]);
}

bool display(float time_delta)
{
    
// Animate the camera:
    
//
    
// The camera will circle around the center of the scene.  We use the sin and cos functions 
    
// to generate points on the circle, then scale them by 10 to further the radius.  
    
// In addition the camera will move up and down as it circles about the scene.
    static float angle = (3.0f * D3DX_PI) / 2.0f;
    
static float camera_height = 0.0f;
    
static float camera_height_dir = 10.0f;

    D3DXVECTOR3 position(cosf(angle) 
* 10.0f, camera_height, sinf(angle) * 10.0f);

    
// the camera is targetted at the origin of the world
    D3DXVECTOR3 target(0.0f0.0f0.0f);

    
// the worlds up vector
    D3DXVECTOR3 up(0.0f1.0f0.0f);

    D3DXMATRIX view_matrix;
    D3DXMatrixLookAtLH(
&view_matrix, &position, &target, &up);
    g_d3d_device
->SetTransform(D3DTS_VIEW, &view_matrix);

    
// compute the position for the next frame
    angle += time_delta;
    
if(angle >= 6.28f)
        angle 
= 0.0f;

    
// compute the height of the camera for the next frame
    camera_height += camera_height_dir * time_delta;
    
if(camera_height >= 20.0f || camera_height <= -20.0f)
        camera_height_dir 
= -camera_height_dir;
    
    
// draw the scene

    g_d3d_device
->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff1.0f0);

    g_d3d_device
->BeginScene();

    
for(int i = 0; i < NUM_MESH; i++)
    {
        
// set the world matrix that positions the object
        g_d3d_device->SetTransform(D3DTS_WORLD, &g_object_world_matrices[i]);

        
// draw the object using the previously set world matrix
        g_object_meshes[i]->DrawSubset(0);
    }
    
    g_d3d_device
->EndScene();

    g_d3d_device
->Present(NULL, NULL, NULL, NULL);

    
return true;
}

LRESULT CALLBACK wnd_proc(HWND hwnd, UINT msg, WPARAM word_param, LPARAM long_param)
{
    
switch(msg)
    {
    
case WM_DESTROY:
        PostQuitMessage(
0);
        
break;

    
case WM_KEYDOWN:
        
if(word_param == VK_ESCAPE)
            DestroyWindow(hwnd);
        
break;
    }

    
return DefWindowProc(hwnd, msg, word_param, long_param);
}

int WINAPI WinMain(HINSTANCE inst, HINSTANCE, PSTR cmd_line, int cmd_show)
{
    
if(! init_d3d(inst, WIDTH, HEIGHT, true, D3DDEVTYPE_HAL, &g_d3d_device))
    {
        MessageBox(NULL, 
"init_d3d() - failed."0, MB_OK);
        
return 0;
    }

    
if(! setup())
    {
        MessageBox(NULL, 
"Steup() - failed."0, MB_OK);
        
return 0;
    }

    enter_msg_loop(display);

    cleanup();
    g_d3d_device
->Release();

    
return 0;
}

 

下載源程序


posted on 2008-03-14 18:52 lovedday 閱讀(989) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導航

統計

常用鏈接

隨筆分類(178)

3D游戲編程相關鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            久久婷婷影院| 美日韩精品视频免费看| 欧美午夜精品理论片a级大开眼界| 亚洲国产成人av| 欧美大尺度在线| 欧美精选一区| 亚洲一区二区三区高清| 亚洲一级黄色片| 国内久久精品| 亚洲激情成人在线| 欧美精品在线一区二区| 亚洲主播在线| 欧美一区二区三区四区夜夜大片| 一区二区三区在线高清| 欧美国产精品人人做人人爱| 欧美久久在线| 久久av在线| 免费在线看成人av| 亚洲男人天堂2024| 久久精品盗摄| 一区二区三区国产精品| 午夜精品美女久久久久av福利| 激情综合网址| 亚洲美女av网站| 国产一区日韩欧美| 亚洲精选91| 国产自产精品| 一本色道久久88综合亚洲精品ⅰ| 国产午夜精品一区二区三区欧美 | 国产伦精品一区二区三区高清版| 久久综合九色综合久99| 欧美日韩黄色一区二区| 欧美有码视频| 欧美视频手机在线| 欧美xxx在线观看| 国产精品视频男人的天堂 | 亚洲麻豆国产自偷在线| 亚洲欧美制服中文字幕| 99在线精品视频在线观看| 久久精品国产成人| 欧美一区二区三区播放老司机| 男女精品网站| 久久久久免费视频| 国产精品每日更新| 亚洲电影自拍| 原创国产精品91| 午夜在线视频观看日韩17c| 国产精品99久久久久久久久| 久久久久这里只有精品| 欧美在线观看视频| 国产精品狼人久久影院观看方式| 亚洲黄页一区| 亚洲国产裸拍裸体视频在线观看乱了中文| 亚洲调教视频在线观看| 一区二区毛片| 欧美高清视频| 亚洲国产精品传媒在线观看| 激情久久五月| 久久精品国产亚洲aⅴ| 久久精品官网| 国产精品一区一区| 亚洲欧美日韩国产中文| 欧美一进一出视频| 国产麻豆视频精品| 午夜精品久久久久久久| 久久福利电影| 韩日精品在线| 久久国产精品一区二区| 理论片一区二区在线| 尤物网精品视频| 麻豆乱码国产一区二区三区| 欧美国产先锋| 一区二区三区精品国产| 欧美日韩在线播放三区| 亚洲私拍自拍| 久久av二区| 136国产福利精品导航网址应用| 久久久夜夜夜| 亚洲人精品午夜| 亚洲综合首页| 国产在线欧美| 蜜臀av在线播放一区二区三区| 亚洲国产91精品在线观看| 日韩视频在线一区二区三区| 欧美日韩另类字幕中文| 国产精品99久久久久久久vr | 日韩午夜中文字幕| 国产精品久久二区二区| 午夜国产精品视频| 欧美国产激情二区三区| 亚洲图片欧美一区| 国内精品国产成人| 蜜桃av一区二区| 亚洲午夜电影在线观看| 久色成人在线| 一区二区三区欧美在线观看| 国产日韩亚洲欧美| 欧美激情国产日韩| 午夜在线精品| 亚洲精品国产精品乱码不99| 欧美在现视频| 99热精品在线| 国产亚洲高清视频| 欧美人与禽性xxxxx杂性| 性18欧美另类| 最新中文字幕亚洲| 久久久久久久久久久久久女国产乱| 亚洲国产精品视频一区| 国产欧美韩国高清| 欧美理论视频| 久久久精品国产免费观看同学| 亚洲精品黄网在线观看| 麻豆freexxxx性91精品| 亚洲在线一区二区| 亚洲日韩中文字幕在线播放| 国产乱码精品一区二区三区不卡| 欧美77777| 久久久精品tv| 欧美亚洲在线观看| 一本色道久久综合亚洲精品婷婷 | 一本大道久久a久久综合婷婷| 国产亚洲第一区| 欧美午夜寂寞影院| 欧美激情一区二区久久久| 久久国产福利| 午夜精品福利一区二区蜜股av| 亚洲免费观看高清完整版在线观看熊 | 欧美激情第五页| 久久久久久久91| 欧美自拍丝袜亚洲| 亚洲欧美日韩国产综合精品二区 | 欧美一级免费视频| 亚洲自拍电影| 亚洲视频福利| 99这里只有精品| 亚洲精品久久久久中文字幕欢迎你 | 欧美久久综合| 欧美精品aa| 欧美精品在线免费| 欧美国产乱视频| 欧美不卡一区| 欧美风情在线观看| 欧美韩国日本一区| 欧美激情日韩| 欧美日韩精品福利| 欧美日韩精品| 国产精品久久国产三级国电话系列 | 国产精品福利片| 国产精品www994| 国产嫩草一区二区三区在线观看 | 国产精品伊人日日| 国产精品亚洲综合天堂夜夜| 国产精品视频99| 国产伦精品一区二区三区四区免费 | 亚洲欧美成人综合| 亚洲欧美日韩电影| 香蕉久久夜色精品国产| 欧美制服第一页| 久久久久国产精品一区| 免费观看成人| 亚洲激情电影在线| 一区二区三区av| 午夜精品亚洲| 美女黄毛**国产精品啪啪| 欧美激情视频一区二区三区在线播放 | 国产精品高清在线| 国产手机视频一区二区| 激情视频亚洲| 一区二区激情小说| 午夜日韩视频| 欧美搞黄网站| 亚洲网站啪啪| 免费久久99精品国产| 欧美日韩另类一区| 国产亚洲欧美另类一区二区三区| 亚洲第一色在线| 99精品视频免费观看视频| 欧美一区二区三区视频| 欧美成人官网二区| 亚洲无线视频| 久久综合色影院| 国产精品爱久久久久久久| 合欧美一区二区三区| 一区二区三区精密机械公司| 久久久综合香蕉尹人综合网| 亚洲理论在线观看| 久久久久国色av免费观看性色| 欧美激情在线观看| 国产亚洲欧洲997久久综合| 99成人在线| 男女精品视频| 午夜在线不卡| 欧美偷拍另类| 在线免费观看成人网| 亚洲欧美日韩国产精品| 亚洲福利专区| 久久久九九九九| 国产欧美日韩不卡免费| 亚洲午夜三级在线| 亚洲国产欧美久久|