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

天行健 君子當自強而不息

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 閱讀(261) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(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在线观看免费视频精品观看| 欧美日韩国产系列| 亚洲国产成人久久综合一区| 久久一区二区三区国产精品 | 亚洲美女区一区| 夜夜夜精品看看| 欧美理论在线| 欧美日韩高清在线播放| 欧美性猛交xxxx乱大交蜜桃| 国产一区二区三区视频在线观看| 在线看视频不卡| 中国av一区| 久久精品视频在线看| 亚洲电影中文字幕| 亚洲一区日韩| 男人的天堂亚洲| 国产精品美女久久| 在线观看精品视频| 亚洲综合社区| 欧美激情一区二区三区在线| 一区二区三区四区五区在线 | 欧美淫片网站| 免费欧美高清视频| 国产麻豆综合| 日韩视频第一页| 久久蜜桃香蕉精品一区二区三区| 欧美激情综合| 欧美亚洲在线| 欧美色大人视频| 亚洲黄色一区二区三区| 欧美在线一区二区三区| 亚洲精品免费电影| 久久久精品国产免费观看同学| 欧美日韩不卡在线| 伊人久久大香线蕉av超碰演员| 亚洲欧美另类中文字幕| 亚洲国产欧美另类丝袜| 久久精品国产亚洲一区二区| 欧美性色综合| 日韩天堂av| 欧美激情中文不卡| 久久亚裔精品欧美| 国内精品久久久久国产盗摄免费观看完整版| 亚洲精品一品区二品区三品区| 久久久国产成人精品| 亚洲一区二区黄色| 欧美精品日韩www.p站| 亚洲福利视频三区| 久久午夜国产精品| 亚洲一区二区动漫| 国产精品伊人日日| 欧美亚洲一区二区三区| 亚洲亚洲精品三区日韩精品在线视频 | 亚洲高清在线视频| 久久综合狠狠综合久久激情| 国产色爱av资源综合区| 欧美一区二区三区在线看| 一区二区三区 在线观看视| 欧美日韩a区| 亚洲欧美激情视频| 亚洲视频一区二区| 亚洲国产日韩欧美在线99| 久久亚洲精品一区二区| 一区二区三区在线观看欧美| 久热国产精品| 久久久久久久久蜜桃| 国内精品久久久久影院优| 久久精品天堂| 久久人人97超碰精品888| 曰韩精品一区二区| 亚洲成色www久久网站| 男女av一区三区二区色多| 欧美国产高清| 久久亚洲国产精品日日av夜夜| 国内精品美女在线观看| 久热精品视频在线| 欧美精品aa| 亚洲在线中文字幕| 新67194成人永久网站| 黄色日韩在线| 亚洲激情网站| 国产精品美女久久久久久久 | 亚洲麻豆av| 夜夜嗨av一区二区三区免费区| 国产精品影院在线观看| 毛片基地黄久久久久久天堂| 欧美大片18| 亚洲欧美www| 久热这里只精品99re8久| 亚洲图片在线观看| 久久夜色精品国产亚洲aⅴ| 亚洲视频图片小说| 欧美一区二区三区在线观看视频 | 久久久爽爽爽美女图片| 亚洲精品国产精品乱码不99按摩 | 国产精品欧美日韩久久| 老司机凹凸av亚洲导航| 欧美日韩在线不卡一区| 久久久噜噜噜久噜久久| 欧美激情一区二区三区蜜桃视频| 亚洲欧美偷拍卡通变态| 麻豆成人av| 久久精品国产精品亚洲| 欧美精品在欧美一区二区少妇| 欧美中文在线观看| 欧美区二区三区| 裸体女人亚洲精品一区| 国产精品久久久久久久久免费桃花 | 欧美性片在线观看| 亚洲高清视频的网址| 国产一区二区三区观看| 欧美影院精品一区| 欧美在线一二三区| 亚洲视频999| 美女久久网站| 久久久久国内| 欧美视频中文一区二区三区在线观看| 久久夜色精品国产欧美乱极品 | 欧美一区二区三区免费视频| 日韩天天综合| 欧美电影免费| 欧美高清hd18日本| 黄色成人av| 久久精品日韩一区二区三区| 先锋影院在线亚洲| 欧美视频一二三区| 日韩亚洲视频| 一区二区三区国产盗摄| 欧美电影免费观看高清| 欧美国产视频在线观看| 1769国内精品视频在线播放| 久久激情综合网| 久久视频一区| 影音先锋在线一区| 久久视频精品在线| 免费欧美日韩| 亚洲国产精品久久91精品| 狂野欧美一区| 亚洲国产高清在线| 99精品国产在热久久婷婷| 欧美激情视频一区二区三区在线播放 | 国产精品美女主播| 亚洲伊人第一页| 欧美亚洲三级| 国产在线观看一区| 久久免费精品视频| 欧美激情亚洲一区| 9人人澡人人爽人人精品| 欧美日产国产成人免费图片| 99在线精品视频| 久久国产加勒比精品无码| 在线不卡a资源高清| 欧美99久久| 一区二区三区视频在线观看| 久久国产精品亚洲va麻豆| 国产一级一区二区| 噜噜噜噜噜久久久久久91| 亚洲人成绝费网站色www| 亚洲午夜精品福利| 国产在线视频欧美| 欧美电影打屁股sp| 亚洲天堂av综合网| 久久在线播放| 99精品视频一区| 欧美日精品一区视频| 欧美亚洲视频| 亚洲激情一区二区| 欧美伊人影院| 99riav久久精品riav| 国产欧美日韩亚洲一区二区三区| 蜜桃久久精品乱码一区二区| 亚洲欧美激情视频| 久久精品国产精品亚洲精品| 亚洲第一精品久久忘忧草社区| 欧美高清视频| 欧美在线日韩| 亚洲精品国久久99热| 久久黄色网页| 国产精品99久久久久久久vr| 极品尤物av久久免费看| 欧美乱妇高清无乱码| 欧美在线观看你懂的| 亚洲国产综合在线| 久久久精彩视频| 国产精品99久久久久久久久| 影音先锋日韩精品| 国产美女一区二区| 欧美日韩免费一区二区三区视频 | 99视频精品| 国内久久婷婷综合| 欧美三级黄美女| 欧美激情欧美激情在线五月| 欧美在线观看视频| 亚洲一区一卡| 亚洲精品日日夜夜| 欧美不卡视频| 久久亚洲春色中文字幕| 亚洲欧美日韩一区二区三区在线| 亚洲精品在线观看视频| 亚洲国产一区二区视频|