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

天行健 君子當自強而不息

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>
            午夜精品福利视频| 久久福利影视| 日韩一区二区精品视频| 欧美日韩国产首页| 亚洲图片在线| 亚洲永久字幕| 黑人极品videos精品欧美裸| 久久久午夜电影| 老司机午夜精品视频在线观看| 在线成人www免费观看视频| 欧美电影在线播放| 欧美精品一区二区三| 亚洲男女自偷自拍| 欧美自拍偷拍午夜视频| 亚洲黑丝在线| 亚洲天堂男人| 经典三级久久| 一本到12不卡视频在线dvd| 国产精自产拍久久久久久| 老司机亚洲精品| 欧美激情第9页| 欧美一级电影久久| 免费短视频成人日韩| 亚洲一区国产视频| 久久久亚洲欧洲日产国码αv | 久久久久久穴| 一本色道久久综合精品竹菊| 亚洲伊人第一页| 亚洲人体影院| 欧美一级片久久久久久久| 亚洲精品视频啊美女在线直播| 亚洲视频在线观看| 91久久黄色| 午夜亚洲性色视频| 这里只有视频精品| 久久手机免费观看| 小黄鸭精品密入口导航| 欧美福利一区| 久久综合九九| 国产精品主播| 在线视频一区观看| 亚洲六月丁香色婷婷综合久久| 欧美亚洲三区| 午夜精品免费在线| 欧美精品一区二区三区视频 | 亚洲人成精品久久久久| 亚欧美中日韩视频| 亚洲综合好骚| 欧美日韩亚洲综合| 亚洲人成啪啪网站| 影音先锋日韩精品| 性娇小13――14欧美| 亚洲综合欧美日韩| 欧美日韩免费观看一区二区三区| 欧美高清一区| 激情五月婷婷综合| 欧美在线看片| 久久久蜜桃精品| 国产亚洲精品自拍| 亚洲欧美视频在线| 欧美一区二区三区播放老司机| 欧美日韩www| 亚洲精选在线观看| 一个色综合av| 欧美日韩第一页| 亚洲国产天堂网精品网站| 亚洲国产精品激情在线观看| 久久九九国产| 欧美国产精品久久| 亚洲日本黄色| 欧美日本在线视频| 亚洲久久在线| 亚洲综合电影| 国产欧美一区二区三区在线老狼| 亚洲欧美国产日韩中文字幕| 先锋资源久久| 国产一区二区你懂的| 欧美中文字幕在线| 另类尿喷潮videofree| 亚洲国产精品成人综合| 欧美肥婆在线| 一本久久综合| 久久九九99| 亚洲国产老妈| 欧美日韩在线不卡| 欧美一区二区黄色| 欧美激情一区二区久久久| 99国内精品久久| 国产精品另类一区| 久久久国产成人精品| 亚洲国产精品成人精品 | 国产精品萝li| 久久国产精品高清| 91久久综合亚洲鲁鲁五月天| 亚洲欧美美女| 精品不卡一区| 欧美视频免费| 久久久蜜桃精品| 日韩午夜黄色| 久久综合影视| 亚洲一级二级| 亚洲国产裸拍裸体视频在线观看乱了中文 | 亚洲欧美另类在线观看| 国产在线视频欧美| 欧美片第1页综合| 欧美专区亚洲专区| 日韩亚洲国产精品| 免费久久久一本精品久久区| 亚洲夜间福利| 亚洲三级影院| 国产一区二区看久久| 欧美日韩亚洲网| 毛片精品免费在线观看| 亚洲天堂av综合网| 亚洲国产精品久久久久婷婷老年| 欧美在线播放高清精品| 99视频在线精品国自产拍免费观看 | 一区二区三区产品免费精品久久75 | 亚洲无玛一区| 91久久线看在观草草青青| 国产日产精品一区二区三区四区的观看方式 | 久久一区二区精品| 亚洲欧美影院| 一道本一区二区| 最近中文字幕日韩精品| 毛片一区二区| 久久婷婷av| 久久久久久**毛片大全| 亚洲欧美国产va在线影院| 亚洲免费不卡| 亚洲欧洲日韩在线| 亚洲高清不卡av| 黄色在线一区| 国模 一区 二区 三区| 国产农村妇女精品一区二区| 欧美视频四区| 欧美日韩一区二区三区视频| 欧美sm视频| 欧美aaaaaaaa牛牛影院| 免费成人性网站| 老司机午夜精品视频| 美女精品国产| 毛片基地黄久久久久久天堂| 久久婷婷激情| 蘑菇福利视频一区播放| 免费日韩成人| 欧美精品电影在线| 欧美精品一区在线播放| 欧美日韩大片一区二区三区| 欧美日韩国产成人高清视频| 欧美欧美全黄| 欧美性猛交99久久久久99按摩| 欧美性生交xxxxx久久久| 国产精品久久久久av免费| 国产精品扒开腿爽爽爽视频| 国产精品人成在线观看免费 | 欧美日韩成人激情| 欧美日韩视频专区在线播放 | 亚洲大胆视频| 亚洲精品乱码久久久久久| 99亚洲视频| 欧美亚洲免费高清在线观看| 久久成人亚洲| 欧美福利一区二区三区| 亚洲精品久久久久久久久久久久| 日韩香蕉视频| 欧美一级视频免费在线观看| 久久久精品国产免费观看同学| 欧美1区2区3区| 欧美午夜精品久久久久免费视| 国产欧美精品一区aⅴ影院| 激情偷拍久久| 亚洲视频一区在线观看| 久久国产加勒比精品无码| 女女同性精品视频| 999在线观看精品免费不卡网站| 亚洲一区二区三区中文字幕| 久久久噜噜噜| 国产精品二区在线| 精品69视频一区二区三区| 99亚洲伊人久久精品影院红桃| 午夜精品视频| 亚洲福利视频在线| 午夜精品福利在线| 欧美第十八页| 韩国精品在线观看| 亚洲午夜免费视频| 欧美aaa级| 欧美一级一区| 欧美日韩免费精品| 18成人免费观看视频| 午夜精品久久久久久久蜜桃app| 欧美成人综合在线| 亚洲欧美久久久| 欧美人成网站| 亚洲国产日韩欧美在线图片| 欧美综合国产| 一区二区高清在线观看| 欧美成人午夜| 在线观看福利一区|