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

天行健 君子當自強而不息

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 閱讀(268) 評論(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>
            欧美日韩免费在线观看| 国产精品久久久爽爽爽麻豆色哟哟 | 亚洲人成欧美中文字幕| 亚洲专区一二三| 国产精品第十页| 久久精品国产99精品国产亚洲性色| 亚洲一品av免费观看| 国产精品一二三视频| 久久久精品国产一区二区三区| 久久国产精品99精品国产| 伊人色综合久久天天五月婷| 欧美激情女人20p| 欧美日韩国产色综合一二三四| 亚洲午夜av在线| 久久超碰97人人做人人爱| 在线免费不卡视频| 日韩视频第一页| 国产三级精品三级| 亚洲二区视频在线| 国产精品电影观看| 理论片一区二区在线| 欧美国产精品劲爆| 小处雏高清一区二区三区| 久久精品1区| 国产精品99久久久久久久女警| 亚洲女女女同性video| 亚洲激情成人在线| 亚洲一区精彩视频| 91久久精品一区二区三区| 正在播放亚洲一区| 亚洲国产日韩美| 亚洲欧美韩国| 99国产精品99久久久久久粉嫩| 亚洲在线国产日韩欧美| 亚洲精品五月天| 久久精品免费看| 亚洲欧美日韩综合| 午夜精品视频一区| 媚黑女一区二区| 久久久久国产精品人| 欧美日韩成人综合| 欧美1区3d| 国产亚洲精品aa午夜观看| 亚洲人在线视频| 亚洲国产精品电影| 欧美一区二区在线| 亚洲欧美国产日韩中文字幕| 欧美成人在线影院| 欧美91福利在线观看| 国产偷国产偷亚洲高清97cao| 99国产精品久久久久久久久久| 在线看日韩av| 久久国产精品亚洲va麻豆| 欧美一区久久| 欧美视频在线一区| 日韩亚洲一区在线播放| 亚洲七七久久综合桃花剧情介绍| 欧美在线免费视屏| 激情丁香综合| 亚洲欧美制服中文字幕| 亚洲制服av| 欧美色区777第一页| 亚洲激情一区二区| 亚洲精品国偷自产在线99热| 免费观看成人网| 欧美国产日韩a欧美在线观看| 国内精品嫩模av私拍在线观看| 亚洲综合国产激情另类一区| 亚洲欧美国产毛片在线| 欧美婷婷在线| 亚洲欧美日本精品| 久久黄金**| 黄页网站一区| 欧美不卡福利| 亚洲人成免费| 亚洲私人影吧| 国产精品一区免费观看| 性欧美暴力猛交另类hd| 快射av在线播放一区| 在线电影国产精品| 蜜臀av一级做a爰片久久| 亚洲激情综合| 亚洲一区二区在线播放| 国产欧美视频在线观看| 久久国产精品高清| 欧美激情亚洲综合一区| 99国产精品一区| 国产精品亚洲片夜色在线| 午夜久久久久久| 女人香蕉久久**毛片精品| 亚洲三级影院| 国产精品久久久久久久久久久久| 午夜精品理论片| 欧美成人情趣视频| 亚洲一区二区三区在线视频| 国产色综合久久| 欧美成人小视频| 亚洲综合激情| 亚洲国产91| 午夜精品久久久久久久99水蜜桃 | 午夜欧美精品久久久久久久| 久久亚洲欧美| 一区二区日韩免费看| 国产精品一区三区| 米奇777超碰欧美日韩亚洲| 一区二区电影免费观看| 久久精品国产精品亚洲| 亚洲三级电影全部在线观看高清| 国产精品电影在线观看| 美女国内精品自产拍在线播放| 一本大道久久精品懂色aⅴ| 久久久久久久一区| 中国成人黄色视屏| 激情五月婷婷综合| 国产精品久久久久aaaa| 免费中文字幕日韩欧美| 亚洲女同精品视频| 亚洲精品在线免费观看视频| 久热国产精品视频| 欧美亚洲视频一区二区| 亚洲精品日韩综合观看成人91| 国产亚洲精品aa午夜观看| 欧美日韩一区二区三区在线看 | 在线亚洲精品福利网址导航| 欧美成人官网二区| 久久精品一区二区三区中文字幕| 亚洲一区二区三区免费观看| 亚洲日韩视频| 亚洲国产精品久久久久秋霞影院 | 欧美视频中文在线看| 奶水喷射视频一区| 久久久天天操| 亚洲免费在线精品一区| 一区二区三区日韩精品视频| 亚洲精品永久免费| 亚洲人成免费| 亚洲高清视频一区| 亚洲成色www8888| 亚洲激情电影在线| 在线欧美不卡| 激情欧美丁香| 一区二区三区我不卡| 国产一区二区三区视频在线观看 | 国产精品久线观看视频| 欧美日韩中文在线| 欧美日韩国产一区精品一区 | 久久精品免费观看| 欧美在线亚洲在线| 久久精品亚洲精品国产欧美kt∨| 欧美一区二区免费观在线| 亚洲综合色激情五月| 午夜欧美理论片| 久久成人av少妇免费| 久久久久久久波多野高潮日日| 久久免费偷拍视频| 蜜臀久久99精品久久久久久9 | 欧美日本三区| 欧美日韩在线观看视频| 国产精品久在线观看| 国产欧美日韩专区发布| 韩国精品久久久999| 亚洲国产欧美在线| 亚洲图片欧洲图片日韩av| 亚洲影院免费观看| 久久精品免费电影| 免费在线欧美黄色| 亚洲美女福利视频网站| 亚洲一区二区三区四区视频 | 亚洲激情视频在线播放| 99视频一区二区三区| 午夜免费电影一区在线观看| 久久久久一本一区二区青青蜜月| 狼狼综合久久久久综合网| 欧美日韩视频在线第一区| 国产精品一区二区视频| 亚洲电影天堂av| 在线亚洲欧美专区二区| 久久免费精品日本久久中文字幕| 欧美电影免费| 亚洲淫性视频| 免费试看一区| 国产精品一卡二| 亚洲人成在线免费观看| 性欧美超级视频| 亚洲国内在线| 欧美在线影院在线视频| 欧美高清视频一区| 国内精品免费午夜毛片| 一本色道久久综合狠狠躁篇怎么玩 | 亚洲天堂网在线观看| 亚洲欧美一区二区激情| 欧美成人免费观看| 国产美女搞久久| 亚洲免费观看高清完整版在线观看熊 | 久久久久天天天天| 亚洲国产清纯| 欧美一区二区播放| 欧美婷婷在线| 亚洲精品一二三| 麻豆视频一区二区|