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

天行健 君子當自強而不息

Controlling Players and Characters(35)

You're coming to the end of the long haul. You’ve finished the private data and
functions, and the public functions are left:

public:
    cCharController()
    {
        ZeroMemory(
thissizeof(*this));
    }

    ~cCharController()
    {
        shutdown();
    }

    
void free()
    {
        delete m_root_char;
        m_root_char = NULL;

        m_num_char = 0;
    }

    
void shutdown()
    {
        free();

        delete[] m_mesh_anim;
        m_mesh_anim = NULL;
        m_num_mesh_anim = 0;

        delete[] m_char_anim;
        m_char_anim = NULL;
        m_num_char_anim = 0;

        m_spell_controller    = NULL;
        m_def_file[0]         = '\0';
        m_weapon_mesh_path[0] = '\0';
        m_texture_path[0]     = '\0';
    }
///////////////////////////////////////////////////////////////////////////////////////////////////

void cCharController::init(ID3DXFont* font, PCSTR def_file,
                           sItem* mil, sSpell* msl,
                           
long num_mesh_anim, PCSTR* mesh_names,
                           PCSTR weapon_mesh_path, PCSTR texture_path,
                           
long num_char_anim, sCharAnimInfo* char_anims)
{
    free();

    
if(mesh_names == NULL || def_file == NULL)
        
return;

    m_font = font;

    strcpy(m_def_file, def_file);

    m_mil = mil;
    m_msl = msl;

    
// copy over mesh path and texture path (or set default)
    strcpy(m_weapon_mesh_path, weapon_mesh_path ? weapon_mesh_path : ".\\");
    strcpy(m_texture_path, texture_path ? texture_path : ".\\");

    
// get mesh names
    if((m_num_mesh_anim = num_mesh_anim) != 0)
    {
        m_mesh_anim = 
new sMeshAnim[num_mesh_anim];

        
for(long i = 0; i < m_num_mesh_anim; i++)
            strcpy(m_mesh_anim[i].filename, mesh_names[i]);
    }

    
// get animation data
    if((m_num_char_anim = num_char_anim) != 0)
    {
        m_char_anim = 
new sCharAnimInfo[m_num_char_anim];

        
for(long i = 0; i < m_num_char_anim; i++)
            memcpy(&m_char_anim[i], &char_anims[i], 
sizeof(sCharAnimInfo));
    }
}

In addition to the typical class constructor and destructor are the init and shutdown pair
of functions. For the controller to operate, it must first be initialized with a call to init.
When you’re done with the character controller class, a call to shutdown is in order.

Somewhat similar in nature to shutdown, the free function completely
removes all characters in the list of active characters. This function is useful for
clearing the list when a character leaves a level and a whole new set of characters
need to be added to the list.

Speaking of adding characters to the list, here comes the function that does it all.

With the add_char function, you need to provide a unique identification number, the MCL
character definition number to use, the character’s type to assign (CHAR_PC, CHAR_NPC,
or CHAR_MONSTER), the artificial intelligence to use, and the character’s coordinates and
Y-axis angle used to point the character in a specific direction.

Following add_char are two functions that remove a character in the list. The remove function
takes a character’s unique identification number as an argument,
and the remove_char function takes a pointer to the character structure.

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

bool cCharController::add_char(long id, long def, long type, long ai,
                               
float pos_x, float pos_y, float pos_z,
                               
float direction)
{
    FILE* fp;
    
if((fp = fopen(m_def_file, "rb")) == NULL)
        
return false;

    sCharacter* character = 
new sCharacter;

    character->def           = def;
    character->id            = id;
    character->type          = type;
    character->ai            = ai;
    character->pos_x         = pos_x;
    character->pos_y         = pos_y;
    character->pos_z         = pos_z;
    character->direction     = direction;
    character->update_enable = 
true;
    character->charge        = rand()%101;

    sCharDef& char_def = character->char_def;

    fseek(fp, 
sizeof(sCharDef) * def, SEEK_SET);
    fread(&char_def, 1, 
sizeof(sCharDef), fp);
    fclose(fp);

    character->health_points = char_def.health_points;
    character->mana_points   = char_def.mana_points;

    
// load character ics
    if(char_def.item_filename)
    {
        character->char_ics = 
new cCharIcs;
        character->char_ics->load(char_def.item_filename);
    }

    sMeshAnim& mesh_anim = m_mesh_anim[char_def.mesh_index];

    
// load mesh and animation if needed
    if(mesh_anim.count == 0)
    {
        mesh_anim.mesh.load(mesh_anim.filename, m_texture_path);
        mesh_anim.anim.load(mesh_anim.filename, &mesh_anim.mesh);
        
        
for(long i = 0; i < m_num_char_anim; i++)
            mesh_anim.anim.set_loop(m_char_anim[i].is_loop, m_char_anim[i].name);
    }

    character->
object.create(&mesh_anim.mesh);
    mesh_anim.count++;

    
// load and configure weapon (if any)
    if(m_mil && char_def.weapon != -1 && m_mil[char_def.weapon].mesh_filename)
    {
        
char path[MAX_PATH];
        sprintf(path, "%s%s", m_weapon_mesh_path, m_mil[char_def.weapon].mesh_filename);
        character->weapon_mesh.load(path, m_texture_path);

        character->weapon_object.create(&character->weapon_mesh);
        character->weapon_object.attach_to_object(&character->
object, "WeaponHand");
    }

    
// link into head of list
    if(m_root_char)
        m_root_char->prev = character;

    character->next = m_root_char;
    m_root_char = character;

    
return true;
}

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

void cCharController::remove_char(sCharacter* character)
{
    
if(character == NULL)
        
return;

    
// decrease mesh count and release if no more

    sMeshAnim& mesh_anim = m_mesh_anim[character->char_def.mesh_index];

    
if(--mesh_anim.count == 0)
    {
        mesh_anim.mesh.free();
        mesh_anim.anim.free();
    }

    
// remove from list
    if(character->prev)
        character->prev->next = character->next;
    
else
        m_root_char = character->next;

    
if(character->next)
        character->next->prev = character->prev;

    character->prev = character->next = NULL;
    delete character;
}

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

void remove(long char_id)
{
     
return remove_char(get_char(char_id));
}

posted on 2007-12-04 17:27 lovedday 閱讀(230) 評論(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>
            巨乳诱惑日韩免费av| 久久裸体艺术| 午夜精品久久久久久久男人的天堂 | 亚洲精品乱码视频| 亚洲毛片在线看| 亚洲一区二区三区四区五区黄| 亚久久调教视频| 欧美激情五月| 亚洲一区自拍| 免费观看30秒视频久久| 国产精品久久久久av免费| 狠狠入ady亚洲精品经典电影| 亚洲欧洲另类国产综合| 亚洲欧美日韩综合国产aⅴ| 老鸭窝亚洲一区二区三区| 亚洲精品网站在线播放gif| 翔田千里一区二区| 欧美激情第9页| 国产一区激情| 亚洲一二三级电影| 亚洲国产精品一区在线观看不卡 | 久久gogo国模裸体人体| 欧美激情中文字幕在线| 先锋亚洲精品| 国产精品av免费在线观看| 亚洲福利视频在线| 久久九九国产精品怡红院| aa级大片欧美三级| 欧美va天堂va视频va在线| 国产日韩欧美在线播放| 亚洲一区二区三区久久| 亚洲国产欧美另类丝袜| 久久精品在线观看| 国产午夜精品视频| 欧美一区二区成人6969| 一区二区欧美日韩| 欧美日韩美女| 一区二区三区久久| 最新日韩av| 欧美成人精品福利| 亚洲高清免费视频| 欧美fxxxxxx另类| 久久女同精品一区二区| 黑丝一区二区| 久久亚洲私人国产精品va| 午夜精品久久久久久久99水蜜桃| 国产精品国产三级国产a| 中文亚洲欧美| 亚洲桃花岛网站| 国产精品久久久久久五月尺| 亚洲欧美清纯在线制服| 一本色道久久综合亚洲91| 欧美午夜无遮挡| 亚洲欧美日韩精品久久亚洲区| 亚洲一区二区伦理| 国产日韩一级二级三级| 久久久久久亚洲综合影院红桃| 欧美在线关看| 91久久精品国产91性色tv| 亚洲国产影院| 欧美日韩在线第一页| 亚洲欧美中文日韩在线| 欧美有码视频| 亚洲经典一区| 国产精品99久久久久久久vr | 亚洲午夜久久久久久久久电影院 | 欧美亚洲三级| 一区精品在线| 亚洲人成人一区二区三区| 欧美日韩一区二区三区在线看| 亚洲一区欧美二区| 欧美在线你懂的| 亚洲片区在线| 国产精品99久久99久久久二8| 国产亚洲福利| 欧美高清视频免费观看| 欧美视频二区36p| 久久亚洲精品视频| 欧美日韩精品免费观看视频| 久久av最新网址| 欧美sm重口味系列视频在线观看| 亚洲午夜在线| 久久免费视频这里只有精品| 一区二区三区成人| 久久激情综合| 亚洲男女毛片无遮挡| 久久综合久久综合久久| 亚洲欧美国产一区二区三区| 久久综合网色—综合色88| 中文在线资源观看网站视频免费不卡| 午夜欧美视频| 9l视频自拍蝌蚪9l视频成人| 久久激情中文| 亚洲欧美国产日韩天堂区| 久久人91精品久久久久久不卡| 亚洲图片欧洲图片日韩av| 久久精品成人一区二区三区蜜臀| 宅男66日本亚洲欧美视频 | 久久久久9999亚洲精品| 欧美日产在线观看| 久久夜色精品国产亚洲aⅴ| 欧美午夜在线观看| 亚洲国产精品第一区二区| 国产日韩欧美日韩大片| 日韩午夜激情av| 亚洲电影免费在线观看| 性欧美xxxx大乳国产app| 一区二区高清视频在线观看| 免费看的黄色欧美网站| 久久琪琪电影院| 国产精品综合| 中文一区字幕| 亚洲女优在线| 欧美午夜精品久久久久免费视 | 99视频精品在线| 久久精品国内一区二区三区| 午夜精品福利电影| 国产精品成人在线观看| 最新日韩精品| 亚洲精品在线免费| 欧美高清视频一二三区| 欧美高清在线视频观看不卡| 激情成人中文字幕| 久久国产视频网| 欧美在线关看| 国产亚洲成av人片在线观看桃 | 久久久久国产精品厨房| 国产精品久久久久久久久免费樱桃 | 亚洲国产高清在线| 久久婷婷成人综合色| 久久综合福利| 1769国产精品| 欧美成人69av| 亚洲国产精品嫩草影院| 亚洲国产另类久久精品| 免费人成精品欧美精品| 亚洲第一精品久久忘忧草社区| 亚洲人成毛片在线播放| 欧美巨乳波霸| 国产精品99久久久久久www| 午夜在线视频一区二区区别| 国产精品网站一区| 久久久九九九九| 欧美成人性生活| 亚洲精品在线看| 国产精品白丝av嫩草影院| 午夜精品久久久久久99热软件| 久久久久九九九| 亚洲国产mv| 欧美网站在线| 久久激情中文| 亚洲欧洲精品一区二区三区不卡| 亚洲一区二区三| 国内精品福利| 欧美gay视频| 日韩视频免费| 久久影院午夜论| 99亚洲一区二区| 国产欧美日韩精品在线| 你懂的国产精品永久在线| 在线一区亚洲| 欧美大秀在线观看| 亚洲欧美日韩国产综合| 在线看国产一区| 国产精品超碰97尤物18| 久久久久亚洲综合| 中日韩美女免费视频网址在线观看 | 国产精品一卡二| 榴莲视频成人在线观看| 国产精品99久久久久久久vr| 美女视频黄 久久| 亚洲综合成人在线| 亚洲人成网站色ww在线| 国产美女扒开尿口久久久| 欧美激情第二页| 久久精品五月婷婷| 亚洲欧美电影院| 亚洲片在线资源| 欧美r片在线| 久久久五月天| 性视频1819p久久| 在线亚洲美日韩| 亚洲三级电影全部在线观看高清| 国产午夜亚洲精品羞羞网站| 欧美视频在线观看免费| 美女视频黄免费的久久| 欧美中文日韩| 亚洲欧美在线免费| 在线亚洲伦理| 99热精品在线观看| 亚洲茄子视频| 亚洲国产精品一区二区第一页 | 很黄很黄激情成人| 国产精品久久久久久久午夜| 欧美精品一区二区视频| 狂野欧美一区| 理论片一区二区在线| 久久久人成影片一区二区三区观看| 午夜一级久久| 欧美中文字幕不卡|