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

天行健 君子當自強而不息

Timing in Animation and Movement(6)

Creating In−Game Cinematic Sequences

Using time−based animation is crucial to achieving smooth playback, but what good could using time−based movement possibly do? Sure, moving a few objects around a set path is neat, but is that all you can do? The answer is a resounding no! There's much more you can do with time−based movement, including creating in−game cinematic sequences, like those from games such as Silicon Knights' Eternal Darkness: Sanity's Requiem In Eternal Darkness, the player is treated to animation sequences that play out using the game's 3D engine.

To use a cinematic camera, you can rely on the techniques you read about earlier in this chapter, and you can use the pre−calculated animation sequences, it's only a matter of plotting out the path that your camera will follow over time. Mix that with a complete
pre−calculated animation, and you've got yourself a complete in−game cinematic engine!

Rather than reiterate what you already saw in this chapter, I'll leave it up to you to check out the Cinematic demo, which shows a small cinematic sequence. In a nutshell, the demo merely loads a series of keys (using the .X path parser class) that represent the paths the camera follows. In every frame, the position of the camera is calculated using the keys, and the viewport is oriented. Then the pre−calculated animation is updated and the entire scene is rendered.

As shown in Figure 2.12, you get to see how complex routes can be applied to cameras in order to traverse a 3D scene in real time. This technique of moving a camera is perfect to use for an in−game cinematic system.

Figure 2.12: The cinematic camera demo adds a moving camera to the Route demo.

 

Route.x:

xof 0303txt 0032
template Path {
<F8569BED-53B6-4923-AF0B-59A09271D556>
DWORD Type; // 0=straight, 1=curved
Vector Start;
Vector Point1;
Vector Point2;
Vector End;
}
template Route {
<18AA1C92-16AB-47a3-B002-6178F9D2D12F>
DWORD NumPaths;
array Path Paths[NumPaths];
}
Route Robot {
5; // 5 paths
  0; // Straight path type
0.0, 10.0, 0.0; // Start
0.0, 0.0, 0.0; // Unused
0.0, 0.0, 0.0; // Unused
0.0, 10.0, 150.0;, // End
  1; // Curved path type
0.0, 10.0, 150.0; // Start
75.0, 10.0, 150.0; // Point1
150.0, 10.0, 75.0; // Point2
150.0, 10.0, 0.0;, // End
  1; // Curved path type
150.0, 10.0, 0.0; // Start
150.0, 10.0, -75.0; // Point1
75.0, 10.0, -150.0; // Point2
0.0, 10.0, -150.0;, // End
  0; // Straight path type
0.0, 10.0, -150.0; // Start
0.0, 0.0, 0.0; // Unused
0.0, 0.0, 0.0; // Unused
-150.0, 10.0, 75.0;, // End
  0; // Straight path type
-150.0, 10.0, 75.0; // Start
0.0, 10.0, 0.0; // Unused
0.0, 10.0, 0.0; // Unused
0.0, 10.0, 0.0;; // End
}
Route Camera {
4; // 4 paths
  1;  // Curved path type
0.0, 80.0, 300.0; // Start
150.0, 80.0, 300.0; // Point1
300.0, 80.0, 150.0; // Point2
300.0, 80.0, 0.0;, // End
  1;  // Curved path type
300.0, 80.0, 0.0; // Start
300.0, 80.0, -150.0; // Point1
151.0, 80.0, -300.0; // Point2
0.0, 80.0, -300.0;, // End
  1;  // Curved path type
0.0, 80.0, -300.0; // Start
-150.0, 80.0, -300.0; // Point1
-300.0, 80.0, -150.0; // Point2
-300.0, 80.0, 0.0;, // End
  1;  // Curved path type
-300.0, 80.0, 0.0; // Start
-300.0, 80.0, 150.0; // Point1
-150.0, 80.0, 300.0; // Point2
0.0, 80.0, 300.0;; // End
}
Route Target {
5; // 5 paths
  0; // Straight path type
0.0, 10.0, 0.0; // Start
0.0, 0.0, 0.0; // Unused
0.0, 0.0, 0.0; // Unused
0.0, 10.0, 150.0;, // End
  1; // Curved path type
0.0, 10.0, 150.0; // Start
75.0, 10.0, 150.0; // Point1
150.0, 10.0, 75.0; // Point2
150.0, 10.0, 0.0;, // End
  1; // Curved path type
150.0, 10.0, 0.0; // Start
150.0, 10.0, -75.0; // Point1
75.0, 10.0, -150.0; // Point2
0.0, 10.0, -150.0;, // End
  0; // Straight path type
0.0, 10.0, -150.0; // Start
0.0, 0.0, 0.0; // Unused
0.0, 0.0, 0.0; // Unused
-150.0, 10.0, 75.0;, // End
  0; // Straight path type
-150.0, 10.0, 75.0; // Start
0.0, 10.0, 0.0; // Unused
0.0, 10.0, 0.0; // Unused
0.0, 10.0, 0.0;; // End
}

WinMain.cpp:

#include <windows.h>
#include 
<d3d9.h>
#include 
<d3dx9.h>
#include 
"Direct3D.h"
#include 
"route.h"

struct sBackdropVertex
{
    
float x, y, z, rhw;
    
float u, v;        
};

#define BACKDROP_FVF (D3DFVF_XYZRHW | D3DFVF_TEX1)

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

IDirect3D9
*                g_d3d;
IDirect3DDevice9
*        g_device;
IDirect3DVertexBuffer9
*    g_backdrop_vb;
IDirect3DTexture9
*        g_backdrop_texture;
D3DXMESHCONTAINER_EX
*    g_robot_mesh_container;
D3DXMESHCONTAINER_EX
*    g_ground_mesh_container;

cXRouteParser            g_route_parser;

D3DXVECTOR3 g_robot_pos, g_robot_last_pos;    

const char CLASS_NAME[] = "CinematicClass";
const char CAPTION[]    = "Cinematic Demo";

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

LRESULT FAR PASCAL window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

bool do_init(HWND hwnd);
void do_shutdown();
void do_frame();


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

int PASCAL WinMain(HINSTANCE inst, HINSTANCE, LPSTR, int cmd_show)
{      
    CoInitialize(NULL);    
// Initialize the COM system

    
// Create the window class here and register it

    WNDCLASSEX win_class;  

    win_class.cbSize        
= sizeof(win_class);
    win_class.style         
= CS_CLASSDC;
    win_class.lpfnWndProc   
= window_proc;
    win_class.cbClsExtra    
= 0;
    win_class.cbWndExtra    
= 0;
    win_class.hInstance     
= inst;
    win_class.hIcon         
= LoadIcon(NULL, IDI_APPLICATION);
    win_class.hCursor       
= LoadCursor(NULL, IDC_ARROW);
    win_class.hbrBackground 
= NULL;
    win_class.lpszMenuName  
= NULL;
    win_class.lpszClassName 
= CLASS_NAME;
    win_class.hIconSm       
= LoadIcon(NULL, IDI_APPLICATION);

    
if(!RegisterClassEx(&win_class))
        
return -1;

    
// Create the main window
    HWND hwnd = CreateWindow(CLASS_NAME, CAPTION, WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
                             
00640480, NULL, NULL, inst, NULL);

    
if(hwnd == NULL)
        
return -1;

    ShowWindow(hwnd, cmd_show);
    UpdateWindow(hwnd);

    
// Call init function and enter message pump
    if(do_init(hwnd)) 
    {
        MSG msg;    
        ZeroMemory(
&msg, sizeof(MSG));

        
// Start message pump, waiting for user to exit
        while(msg.message != WM_QUIT) 
        {
            
if(PeekMessage(&msg, NULL, 00, PM_REMOVE)) 
            {
                TranslateMessage(
&msg);
                DispatchMessage(
&msg);
            }
      
            do_frame();    
// Render a single frame
        }
    }
  
    do_shutdown();
    UnregisterClass(CLASS_NAME, inst);
    CoUninitialize();

    
return 0;
}

LRESULT FAR PASCAL window_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    
// Only handle window destruction messages
    switch(msg) 
    {
    
case WM_DESTROY:
        PostQuitMessage(
0);
        
break;

    
case WM_KEYDOWN:
        
if(wParam == VK_ESCAPE)
            DestroyWindow(hwnd);

        
break;
    }

    
return DefWindowProc(hwnd, msg, wParam, lParam);
}

bool do_init(HWND hwnd)
{
    init_d3d(
&g_d3d, &g_device, hwnd, falsefalse);

    
if(FAILED(load_mesh(&g_robot_mesh_container, g_device, "..\\Data\\robot.x""..\\Data\\"00)))
        
return false;

    
if(FAILED(load_mesh(&g_ground_mesh_container, g_device, "..\\Data\\ground.x""..\\Data\\"00)))
        
return false;

    
// create the backdrop

    sBackdropVertex backdrop_verts[
4= 
    {
        {   
0.0f,   0.01.01.0f0.0f0.0f },
        { 
640.0f,   0.01.01.0f1.0f0.0f },
        {   
0.0f480.01.01.0f0.0f1.0f },
        { 
640.0f480.01.01.0f1.0f1.0f }            
    };

    g_device
->CreateVertexBuffer(sizeof(backdrop_verts), D3DUSAGE_WRITEONLY, BACKDROP_FVF, D3DPOOL_DEFAULT,
                                 
&g_backdrop_vb, NULL);

    
char* ptr;

    g_backdrop_vb
->Lock(00, (void**)&ptr, 0);
    memcpy(ptr, backdrop_verts, 
sizeof(backdrop_verts));
    g_backdrop_vb
->Unlock();

    D3DXCreateTextureFromFile(g_device, 
"..\\Data\\Backdrop.bmp"&g_backdrop_texture);

    
// setup a directional light

    D3DLIGHT9 light;
    ZeroMemory(
&light, sizeof(D3DLIGHT9));

    light.Type 
= D3DLIGHT_DIRECTIONAL;
    light.Diffuse.r 
= light.Diffuse.g = light.Diffuse.b = light.Diffuse.a = 1.0f;
    light.Direction 
= D3DXVECTOR3(0.0f-0.5f0.5f);

    g_device
->SetLight(0&light);
    g_device
->LightEnable(0, TRUE);

    
if(! g_route_parser.load("..\\Data\\Route.x"))
        
return false;

    
return true;
}

void do_shutdown()
{
    
// free mesh data
    delete g_robot_mesh_container;    g_robot_mesh_container  = NULL;
    delete g_ground_mesh_container;    g_ground_mesh_container 
= NULL;

    release_com(g_backdrop_vb);
    release_com(g_backdrop_texture);

    
// release D3D objects
    release_com(g_device);
    release_com(g_d3d);
}

void do_frame()
{
    
static DWORD start_time = timeGetTime();
    DWORD curr_time 
= timeGetTime();

    
// calculate the position in which to place the robot along the path based on time and robot_route_length of route.
    float robot_route_length = g_route_parser.get_length("Robot");
    DWORD robot_dist 
= (curr_time - start_time) / 10;
    robot_dist 
%= ((DWORD)robot_route_length + 1);

    
// get the camera's position
    float camera_route_length = g_route_parser.get_length("Camera");
    DWORD camera_dist 
= (curr_time - start_time) / 20;
    camera_dist 
%= ((DWORD) camera_route_length + 1);

    
// get the target's position
    float target_route_length = g_route_parser.get_length("Target");
    DWORD target_dist 
= (curr_time - start_time) / 10;
    target_dist 
%= ((DWORD) target_route_length + 1);

    
// update the positions of the robot
    g_robot_last_pos = g_robot_pos;
    g_route_parser.locate(
"Robot", (float)robot_dist, &g_robot_pos);

    
// get camera and target position
    D3DXVECTOR3 camera_pos, target_pos;
    g_route_parser.locate(
"Camera", (float)camera_dist, &camera_pos);
    g_route_parser.locate(
"Target", (float)target_dist, &target_pos);

    
// set a view transformation matrix
    D3DXMATRIX  mat_view;    
    D3DXVECTOR3 up(
0.0f1.0f0.0f);
    D3DXMatrixLookAtLH(
&mat_view, &camera_pos, &target_pos, &up);
    g_device
->SetTransform(D3DTS_VIEW, &mat_view);

    
// clear the device and start drawing the scene

    g_device
->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_RGBA(000255), 1.0f0);

    g_device
->BeginScene();

    
// draw the backdrop
    g_device->SetFVF(BACKDROP_FVF);
    g_device
->SetStreamSource(0, g_backdrop_vb, 0sizeof(sBackdropVertex));
    g_device
->SetTexture(0, g_backdrop_texture);
    g_device
->DrawPrimitive(D3DPT_TRIANGLESTRIP, 02);

    g_device
->SetRenderState(D3DRS_LIGHTING, TRUE);

    
// draw the ground mesh
    D3DXMATRIX mat_world;
    D3DXMatrixIdentity(
&mat_world);
    g_device
->SetTransform(D3DTS_WORLD, &mat_world);
    draw_mesh(g_ground_mesh_container);

    
// calculate the rotation of the robots based on last known position, and update last position once done.
    D3DXVECTOR3 diff = g_robot_pos - g_robot_last_pos;
    
float rot_x =  atan2(diff.y, diff.z);
    
float rot_y = -atan2(diff.z, diff.x);

    
// rotate the robot to point in direction of movement
    D3DXMatrixRotationYawPitchRoll(&mat_world, rot_y, rot_x, 0.0f);

    
// position the robot by setting the coordinates directly in the world transformation matrix
    mat_world._41 = g_robot_pos.x;
    mat_world._42 
= g_robot_pos.y;
    mat_world._43 
= g_robot_pos.z;
    g_device
->SetTransform(D3DTS_WORLD, &mat_world);

    draw_mesh(g_robot_mesh_container);

    g_device
->SetRenderState(D3DRS_LIGHTING, FALSE);

    g_device
->EndScene();

    g_device
->Present(NULL, NULL, NULL, NULL);
}

download source file


posted on 2008-04-21 18:23 lovedday 閱讀(369) 評論(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>
            日韩一二三区视频| 欧美三级电影精品| 亚洲夜晚福利在线观看| 久久国产视频网| 亚洲一区欧美激情| 欧美精品久久久久久久免费观看 | 中日韩男男gay无套| 久久亚洲欧洲| 久久久91精品| 国产女优一区| 亚洲一区国产一区| 亚洲午夜精品久久久久久浪潮| 美日韩免费视频| 欧美成va人片在线观看| 好男人免费精品视频| 亚洲欧美视频在线观看| 午夜精品久久久久久99热| 欧美日韩国产首页在线观看| 91久久精品国产91性色tv| 在线免费一区三区| 久久亚洲国产精品日日av夜夜| 久久久国产成人精品| 国产色产综合色产在线视频| 午夜视频一区| 久久激五月天综合精品| 国产一区二区精品丝袜| 欧美一区久久| 美女视频黄免费的久久| 在线观看欧美一区| 免费观看久久久4p| 亚洲国产欧美不卡在线观看| 亚洲狼人综合| 欧美少妇一区二区| 亚洲在线一区二区| 久久精品夜色噜噜亚洲a∨| 国产亚洲成年网址在线观看| 欧美在线视频免费观看| 欧美成人精品在线| 亚洲毛片在线看| 国产精品久久久久91| 午夜精品福利在线| 美国成人直播| 一本色道久久加勒比精品| 欧美性猛交xxxx乱大交蜜桃| 亚洲欧美日韩国产综合在线| 久久天堂成人| 夜夜嗨av一区二区三区中文字幕| 欧美视频精品在线| 久久国产福利| 亚洲人成在线观看一区二区| 亚洲欧美在线观看| 狠狠色丁香婷综合久久| 欧美精品二区| 欧美一区二区日韩一区二区| 欧美激情导航| 午夜激情综合网| 亚洲高清不卡| 国产精品久久97| 久久精品成人| 日韩视频在线观看免费| 久久久91精品国产| 一区二区精品| 一区二区三区在线免费观看| 欧美人成网站| 久久久久久免费| 一区二区三区视频在线播放| 另类成人小视频在线| 制服丝袜激情欧洲亚洲| 有码中文亚洲精品| 欧美视频一区二区在线观看| 久久久久久久久岛国免费| 日韩一区二区精品葵司在线| 久久亚裔精品欧美| 亚洲一区二区三区在线| 亚洲高清网站| 国产在线一区二区三区四区 | 久久大香伊蕉在人线观看热2| 亚洲国产小视频| 国产午夜精品美女视频明星a级| 欧美www视频在线观看| 午夜伦欧美伦电影理论片| 亚洲精品乱码久久久久久按摩观| 久久久之久亚州精品露出| 亚洲一区影音先锋| 日韩一级视频免费观看在线| 精品动漫3d一区二区三区免费版| 国产精品久久久久天堂| 欧美极品在线观看| 久久一区二区视频| 久久国产精品久久久久久电车| 一本色道久久综合亚洲精品高清| 欧美激情va永久在线播放| 久久久免费av| 久久精品一区二区三区不卡牛牛| 亚洲一区视频在线观看视频| 一本一本久久a久久精品牛牛影视| 在线精品一区二区| 激情久久中文字幕| 国产专区精品视频| 国产日韩一区二区三区| 国产精品视频一区二区三区| 国产精品进线69影院| 欧美日韩中文字幕| 国产精品igao视频网网址不卡日韩| 欧美精品一区二区三区高清aⅴ| 噜噜爱69成人精品| 女主播福利一区| 欧美国产高潮xxxx1819| 欧美韩日精品| 欧美日韩国产成人在线观看| 欧美日韩国产高清| 欧美三级视频在线观看| 国产精品嫩草久久久久| 国产精品一区二区久久久久| 国产欧美综合一区二区三区| 国产日韩一区二区三区| 国内精品一区二区| 在线观看亚洲专区| 亚洲欧洲在线看| 洋洋av久久久久久久一区| 亚洲先锋成人| 久久国产福利| 蜜桃精品久久久久久久免费影院| 欧美大片免费观看在线观看网站推荐| 欧美成人69av| 亚洲人人精品| 亚洲欧美日韩精品久久亚洲区| 欧美与欧洲交xxxx免费观看 | 国产精品夜夜夜一区二区三区尤| 国产美女精品一区二区三区 | 国产欧美日韩亚洲一区二区三区| 国产午夜精品一区二区三区视频| 一区二区三区在线观看国产| 亚洲美女中出| 性欧美1819sex性高清| 久久亚洲一区| 亚洲精品一区二| 香蕉久久国产| 欧美.www| 国产啪精品视频| 91久久精品国产91久久性色tv | 亚洲精品一区二区三区在线观看| 在线亚洲欧美| 久热国产精品| 国产精品久久久久久久电影| 一区二区三区在线视频免费观看 | 亚洲国产三级网| 亚洲已满18点击进入久久| 久久综合99re88久久爱| 欧美视频官网| 91久久精品久久国产性色也91 | 欧美在线观看视频一区二区| 欧美国产综合| 欧美一级成年大片在线观看| 欧美极品一区| 一区二区三区在线观看视频| 亚洲一区二区在线免费观看视频 | 久久亚洲精品网站| 国产精品毛片| 日韩视频一区二区在线观看| 久久久欧美精品| 一区二区三区色| 男人天堂欧美日韩| 国产一区二区中文| 亚洲欧美日韩精品在线| 亚洲福利视频二区| 久久精品欧洲| 国产日韩综合一区二区性色av| 亚洲人成在线观看一区二区| 久久久久久久久久久成人| 在线一区日本视频| 欧美精品国产精品| 亚洲激情在线视频| 麻豆av一区二区三区久久| 亚洲欧美日韩系列| 国产精品久久久久av| 亚洲视频在线观看三级| 亚洲国产日韩一区二区| 亚洲视频图片小说| 亚洲国产精品va在线看黑人| 久久精品国产免费| 国产一区日韩一区| 欧美一区二区在线看| 亚洲图片在线| 欧美视频不卡中文| 亚洲小说春色综合另类电影| 亚洲精品日韩在线| 欧美日韩国产黄| 一区二区三区欧美成人| 亚洲精品乱码久久久久久黑人| 欧美肥婆在线| 一本色道久久综合亚洲精品不卡 | 日韩视频国产视频| 亚洲激情成人在线| 欧美搞黄网站| 在线综合亚洲欧美在线视频| 亚洲精品一二区| 国产精品成人一区二区| 亚洲欧美日韩一区二区三区在线| 亚洲宅男天堂在线观看无病毒|