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

天行健 君子當自強而不息

Working with Maps and Levels(15)

cAutomap::load and cAutomap::save

Recall that you need to enable each map section in order for it to be visible when
rendered. The m_visible array tracks the visibility of each map section; if an array
element is set to 0, the respective map section is not displayed. If the element is set
to 1, the map section is drawn.

In your game, once the map sections are marked as visible, you save those flags
so that a player can track his progress through the game and later load his map
progression to continue the game-play. The load and save functions do just that:

bool cAutoMap::load(pcstr filename)
{
    FILE* fp = fopen(filename, "rb");
    
if(fp == NULL)
        
return false;

    
long num_sections;
    fread(&num_sections, 1, 
sizeof(num_sections), fp);
    
    fread(m_visible, 1, num_sections, fp);
    fclose(fp);
    
return true;
}

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

bool cAutoMap::save(pcstr filename)
{    
    FILE* fp = fopen(filename, "wb");
    
if(fp == NULL)
        
return false;

    fwrite(&m_num_sections, 1, 
sizeof(m_num_sections), fp);
    fwrite(m_visible, 1, m_num_sections, fp);

    fclose(fp);
    
return true;
}

The storage format for the visibility array is simple: The file starts with a long variable
that states how many elements are in the array. Following that, the entire map visibility
array is written out. To load the visibility array back up, read in the number of
elements, ensure that they match the currently loaded map, and load in the array.

 

cAutomap::get_num_section and cAutomap::visible_section, cAutomap::invisible_section

These two functions return the number of map sections loaded and allow you to
set the visibility of each map section. Each map section is numbered sequentially
from the order stored in the .X file.

 

cAutomap::set_viewport and cAutomap::render

You use set_viewport to define the area in which you want the auto map displayed
(specified in screen coordinates plus height and width in pixels). As you can see,
the function is small—it only sets up the viewport structure declared in the cAutomap
class.

As for the render function, this is where your hard work shows. To display a map,
you have to provide a pointer to a camera that you are currently using (to restore
it after changing the view matrix), the coordinates of the map camera to use when
rendering, the number of characters to display on the map, and three arrays that
define each character’s coordinates and facing angle to draw on the auto map:

void cAutoMap::render(cCamera* old_camera,
                      
float map_x_pos, float map_y_pos, float map_z_pos,
                      
float num_arrows,
                      
float* arrow_x_pos, float* arrow_z_pos, float* angle)
{
    m_camera.move(map_x_pos * m_scale, map_y_pos, map_z_pos * m_scale);
    set_display_camera(&m_camera);

    D3DVIEWPORT9 old_viewport;
    g_d3d_device->GetViewport(&old_viewport);
    g_d3d_device->SetViewport(&m_viewport);

    disable_zbuffer();
    g_d3d_device->SetTexture(0, NULL);

    
// draw little map

    cWorldPos world_pos;
    set_display_world(&world_pos);

    enable_alpha_blending(D3DBLEND_SRCCOLOR, D3DBLEND_DESTCOLOR);

    
for(long i = 0; i < m_num_sections; i++)
    {
        
if(m_visible[i])
            render_vertex_buffer(m_map_vb[i], 0, get_num_vertices(m_map_vb[i]) / 3, D3DPT_TRIANGLELIST);
    }

    disable_alpha_blending();

    
// draw the character positions
    for(long i = 0; i < num_arrows; i++)
    {
        world_pos.move(arrow_x_pos[i] * m_scale, 0.0f, arrow_z_pos[i] * m_scale);
        world_pos.rotate(0.0f, angle[i], 0.0f);

        set_display_world(&world_pos);

        render_vertex_buffer(m_arrow_vb, 0, 1, D3DPT_TRIANGLELIST);
    }

    
// restore old camera if passed
    if(old_camera)
        set_display_camera(old_camera);

    
// restore old viewport
    g_d3d_device->SetViewport(&old_viewport);
}

The render function starts off by defining a few variables, performing some errorchecking,
and setting up a camera to render the map sections. That’s right. The
map sections are still 3-D meshes, just flat and viewed from above (which is the reason
for the camera being rotated down earlier in the code).

Next you create the rendering viewport (with the old viewport settings saved for
later restoring). You set the rendering states (no Z-buffering and no textures) and
a transformation matrix to center the auto map in the world:

Next you render every map section. Actually, only those map sections that are
flagged as visible are rendered. The code to render those map sections is small, so
you can wrap it up with the code that renders the pointers (which represent the
characters’ positions on the map).

After rendering the map sections, you disable alpha blending (in case it was used
to render the map) and position and render the pointer vertex buffer for each
character that was passed to the render function.

Last, you restore the camera and viewport settings that were used prior to rendering
the auto map.

 

Using cAutomap

The mapping demo for this chapter contains a perfect example of using the auto
map class, but to give you a clear idea of its use, here is an example. Start by
instancing the cAutomap class and call create to load an .X file:

cAutomap Automap;
Automap.create(“Map.x”, D3DCOLOR_RGBA(64,64,64,255));

At this point, the map is loaded and ready to go. The map uses a color of dark gray
for rendering (which is the reason for the D3DCOLOR_RGBA macro). To start rendering
the map, you must first set the position of the window to which you are rendering:

Automap.set_viewport(0,0,200,200); // Use 0,0 to 200,200 for map

Next, you mark a map section as visible:

Automap.visible_section(0); // Set 1st section to visible

All that’s left to do is to render the map:

Automap.render(NULL, 0.0f, 200.0f, 0.0f, 0, NULL, NULL, NULL);

The preceding call positions the camera and renders the single visible map section. Now, what about the
other map sections? How is your game going to know which map sections to flag as
visible? By using triggers; that’s how!

By instancing a cTrigger class, you can embed triggers into your map that signal
which map sections have been entered, and thus marked as visible. You just mark
those map triggers using the same identification numbers as the map section mesh
contained with the map .X file (the first mesh in the file needs a trigger with an
identification number of 1, the second mesh needs a trigger identification number
of 2, and so on).

The Mapping example uses triggers to mark sections of the map to display as characters
enter them—be sure to check out the example to see just what I’m talking about.

posted on 2007-12-10 19:31 lovedday 閱讀(262) 評論(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>
            久久精品男女| 亚洲欧美日韩在线一区| 理论片一区二区在线| 亚洲欧美激情视频在线观看一区二区三区| 亚洲国产一区二区三区青草影视| 老司机午夜精品视频| 久久久国产精彩视频美女艺术照福利| 欧美一区二区三区久久精品茉莉花| 亚洲男同1069视频| 亚洲欧美日韩一区| 久久久五月婷婷| 欧美大片在线影院| 亚洲精品一区二区三区av| 99国产精品久久久久久久成人热 | 欧美人与禽猛交乱配| 欧美精品国产一区| 国产精品分类| 黄色成人在线网站| 夜夜夜久久久| 久久精品91久久香蕉加勒比 | 久久久精品免费视频| 免费成人黄色片| 亚洲精品永久免费精品| 亚洲午夜高清视频| 久久久一区二区| 欧美午夜免费| 伊人久久大香线蕉av超碰演员| 亚洲精品一区在线观看| 午夜视频在线观看一区二区| 免费欧美网站| 伊甸园精品99久久久久久| 日韩一级不卡| 久久超碰97中文字幕| 欧美成人激情视频| 亚洲最新中文字幕| 久久本道综合色狠狠五月| 久久综合99re88久久爱| 西西裸体人体做爰大胆久久久| 亚洲国产一区在线| 亚洲福利视频三区| 99在线热播精品免费| 亚洲免费影视| av成人免费观看| 欧美诱惑福利视频| 在线视频精品一| 国产精品女人网站| 亚洲大胆视频| 香蕉久久一区二区不卡无毒影院| 美日韩精品视频| 亚洲一区精彩视频| 欧美激情一区二区三区在线| 国产日韩一区二区| 亚洲一区欧美二区| 亚洲福利国产精品| 久久频这里精品99香蕉| 国产一区二区三区电影在线观看 | 亚洲一区二区三区在线观看视频| 欧美电影在线| 久久久噜久噜久久综合| 国产一区二区三区免费不卡| 欧美一区二区日韩| 亚洲综合首页| 国产精品日本精品| 亚洲欧美成人网| 一区二区三区毛片| 欧美午夜在线观看| 亚洲伊人一本大道中文字幕| 99国产精品视频免费观看| 欧美精品18+| 日韩午夜精品视频| 亚洲黄色成人| 欧美日韩大片| 亚洲一区二区四区| 亚洲网站啪啪| 国产精品高潮呻吟| 校园春色国产精品| 香蕉国产精品偷在线观看不卡| 国产精品视频免费| 久久国产欧美日韩精品| 久久激情五月激情| 伊人蜜桃色噜噜激情综合| 麻豆国产精品一区二区三区| 久久久www成人免费无遮挡大片| 黄色精品网站| 亚洲狠狠丁香婷婷综合久久久| 欧美激情无毛| 伊人久久综合| 亚洲自拍偷拍福利| 性做久久久久久久久| 久久人人爽人人爽爽久久| 亚洲最新视频在线播放| 欧美一区二区视频观看视频| 亚洲激情黄色| 在线欧美日韩国产| 亚洲精品国产精品乱码不99| 国产日韩欧美精品一区| 久久精品国产一区二区三区| 亚洲大胆在线| 欧美另类99xxxxx| 亚洲一区二区三区成人在线视频精品 | 亚洲欧洲日产国产综合网| 欧美日韩www| 欧美制服丝袜| 麻豆av一区二区三区久久| 99re这里只有精品6| 中文在线资源观看视频网站免费不卡| 国产日韩欧美不卡| 亚洲成色777777在线观看影院 | 国产一区二区0| 欧美激情麻豆| 国产精品久久久久久久久免费樱桃 | 国产九九精品视频| 欧美成人午夜激情在线| 欧美日韩小视频| 久久久久久久久久久一区 | 久久精品国产综合| 亚洲天堂av在线免费观看| 亚洲大片在线| 国产一区二区三区四区三区四| 亚洲黄色小视频| 国产日韩欧美综合| 日韩亚洲一区在线播放| 狠狠色综合色区| 亚洲一区二区三区中文字幕| 亚洲欧洲在线免费| 久久国产直播| 性视频1819p久久| 久久国产66| 夜夜嗨av一区二区三区中文字幕 | 亚洲二区视频在线| 99riav国产精品| 亚洲毛片视频| 国产综合一区二区| 亚洲色无码播放| 夜夜精品视频一区二区| 久久精品一区二区| 欧美在线一二三区| 国产精品www色诱视频| 亚洲精品免费一区二区三区| 在线观看91久久久久久| 午夜精品免费| 亚洲欧美一区在线| 欧美亚日韩国产aⅴ精品中极品| 亚洲国产一区视频| 亚洲精品国产日韩| 欧美va亚洲va香蕉在线| 毛片基地黄久久久久久天堂| 国产一区二区精品久久99| 亚洲视频一区二区| 午夜日韩在线| 欧美在线看片| 久久一区二区精品| 狠狠爱成人网| 久久久www成人免费精品| 久久久噜久噜久久综合| 国产日韩欧美综合一区| 亚洲欧美综合一区| 久久精品30| 1024成人| 欧美国产日韩视频| 亚洲美女视频网| 亚洲欧美成人在线| 国产欧美在线观看| 久久久999精品| 欧美激情第9页| 亚洲肉体裸体xxxx137| 欧美日韩国产区一| 亚洲一区二区3| 亚洲国产一成人久久精品| 欧美成人午夜| 亚洲另类在线一区| 小处雏高清一区二区三区| 国产在线高清精品| 欧美成人国产| 亚洲一区亚洲| 米奇777在线欧美播放| 亚洲精品在线免费观看视频| 欧美日韩国产综合视频在线观看| 国产精品99久久久久久www| 亚洲淫性视频| 亚洲三级性片| 欧美日本一区| 在线观看欧美精品| 欧美一区二区三区另类| 亚洲激情成人在线| 久久狠狠亚洲综合| 国产精品久久久久毛片软件| 今天的高清视频免费播放成人 | 久久久免费观看视频| 一区二区三区偷拍| 9久re热视频在线精品| 国产精品午夜在线观看| 美女主播精品视频一二三四| 亚洲天堂第二页| 欧美/亚洲一区| 一区二区三区免费观看| 国语自产在线不卡| 先锋影音久久| 夜色激情一区二区| 欧美国产第一页|