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

天行健 君子當自強而不息

Controlling Players and Characters(23)

 

Creating a Spell Controller

Controlling spells is a matter of tracking the meshes and animations that represent
the spell and then processing the spell’s effects on their intended targets. Because
the spell’s effects are really related to the characters, it’s best to let the engine that
controls the characters handle the spell effects and leave the spell animation up to
a spell controller class object.

You want to create a spell controller class that maintains a list of currently cast spells
and displays them onscreen. When a spell is complete, this controller class calls an outside
function to process the spell’s effects. This spell controller class, cSpellController,
uses supportive structures that make tracking the spell meshes and animation
easier. These structures are sMeshAnim and sSpellTracker.

 

Meshes with sMeshAnim

Reviewing the sSpell spell structure, you can see that meshes are referenced by
number rather than by name. That mesh reference number is actually the index to
an array of meshes. You store this array of meshes in a collection of sMeshAnim
structures:

typedef struct sMeshAnim
{
    
char        filename[MAX_PATH];     // filename of mesh/anim
    long        count;                  // number of characters using mesh
    cMesh       mesh;
    cAnimation  anim;    

    sMeshAnim() { count = 0; }
} *sCharMeshListPtr;

For each mesh in use in your engine, you have a matching sMeshAnim structure.
Each structure instance stores the filename of the mesh to use, a cMesh and a
cAnimation object for the mesh, and a variable (Count) that keeps count of how many
instances of the mesh are currently in use.

For each spell that needs a mesh, the appropriate .X file is loaded into the mesh
and animation objects (both using the same filename and the animation using a
single animation set called anim).

Meshes are only loaded from disk whenever the spell controller requires them, and
because the structure maintains a count of the times the mesh is in use, the spell
controller can quickly determine whether the mesh is loaded.

As spells complete their animation cycle, the appropriate mesh count is reduced,
and when the number of spells that use the mesh is reduced to zero, the mesh and
animation objects are released (to save memory).

 

Tracking Spells Using sSpellTracker

Whereas the sMeshAnim structure maintains the meshes used by spells, the actual
list of active spells is maintained by the sSpellTracker structure. The sSpellTracker
structure is allocated and inserted into a linked list of the same structures any time
a spell is cast:

#define NUM_SPELL_DEF   64

enum SpellEfects
{
    ALTER_HEALTH = 0, ALTER_MANA, CURE_AILMENT, CAUSE_AILMENT, RAISE_DEAD, INSTANT_KILL, DISPEL_MAGIC, TELEPORT
};

enum SpellTargets
{
    TARGET_SINGLE = 0, TARGET_SELF, TARGET_AREA
};

enum AnimPositions
{
    POSITION_NONE = 0, POSITION_CASTER, POSITION_TOTARGET, POSITION_TOCASTER, POSITION_TARGET, POSITION_SCALE
};

/************************************************************************************************/

typedef 
struct sSpellTracker
{
    
long        spell_index;

    sCharacter* caster;
    
long        affect_type;

    
long cur_anim;              // animation: 0-2
    float source_x, source_y, source_z;
    
float target_x, target_y, target_z;

    
float x_pos, y_pos, z_pos;  // current coordinate
    float x_add, y_add, z_add;  // movement values
    float dist_to_target;       

    union
    {
        
float   speed;          
        
long    holding_time;   
    };

    cObject 
object;             // graphics object

    sSpellTracker*  prev;
    sSpellTracker*  next;

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

    sSpellTracker()
    {
        caster = NULL;
        prev = next = NULL;
    }

    ~sSpellTracker()
    {
        delete next;
    }
} *sSpellTrackerPtr;

For each spell cast, a sSpellTracker structure is used to contain the information to track
the mesh, animation, movement, timing, and which character cast the spell. The
structure starts off with the spell number (spell_index), which relates directly to the MSL.

To later help determine the effects of a spell, a pointer to a character (caster) is
maintained as well as the type of characters the spell can affect (PCs, NPCs, or
MCs). You can define each type of character as follows:

#define CHAR_PC 0
#define CHAR_NPC 1
#define CHAR_MONSTER 2

Notice that a spell has no target character defined, but a trio of target coordinates.
In fact, a spell has a trio of source coordinates. Remember that a spell mesh can
stay in place over the caster or victim, move between the two, or stretch between
them. Setting the source and target coordinates ensures that the tracker knows how
to position the mesh in use.

Speaking of the mesh in use, curr_anim is used to track which of the three
meshes to use. As you may recall, a mesh movement takes place in three steps, and
once the current animation passes the third step, the spell takes effect.

To track the motion of the spell meshes (if they are indeed moving), you use a set of
values (x_add, y_add, and z_add) that tells the spell controller which direction to move the
mesh at each update. As for the current position of the mesh in use, the variables
x_pos, x_pos, and z_pos contain the current coordinates at which to render the mesh.

The speed in which a mesh moves is contained in speed, and the total distance the
mesh can move is contained in dist_to_target. If a mesh stays in place, the holding_time variable
does a countdown of the number of milliseconds until the cycle is complete.

Rounding off sSpellTracker, object is the graphics object you use to render the
meshes, and prev and next maintain the linked list of structures.


posted on 2007-12-03 19:11 lovedday 閱讀(212) 評論(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综合电影在线视频| 午夜精品剧场| 亚洲精品系列| 午夜精品久久久久久99热| 在线观看三级视频欧美| 99国产精品自拍| 韩日欧美一区二区| 9久re热视频在线精品| 国产真实乱子伦精品视频| 91久久在线观看| 国产日韩欧美综合在线| 最新国产精品拍自在线播放| 国产精品手机在线| 亚洲第一视频网站| 国产亚洲成av人片在线观看桃| 欧美国内亚洲| 国产日韩欧美三区| 亚洲美女啪啪| 亚洲国产欧美在线人成| 午夜精品国产| 一本一道久久综合狠狠老精东影业| 香港久久久电影| 亚洲午夜一区| 欧美国产日韩二区| 久久亚洲精品视频| 国产精品视区| 正在播放欧美视频| 日韩视频免费观看高清完整版| 欧美伊人久久| 欧美一级黄色网| 欧美日韩免费一区二区三区| 美女网站久久| 韩国精品久久久999| 亚洲一区二区av电影| 日韩一区二区高清| 久久婷婷国产综合尤物精品| 午夜欧美精品| 国产精品高潮久久| 日韩亚洲欧美一区二区三区| 亚洲国产成人av好男人在线观看| 欧美亚洲系列| 久久精品在这里| 国产欧美视频一区二区三区| 一区二区欧美日韩视频| 99re亚洲国产精品| 欧美韩日一区二区| 亚洲国产精品久久精品怡红院| 亚洲电影免费在线观看| 久久久免费精品视频| 久久美女性网| 好看不卡的中文字幕| 欧美自拍偷拍午夜视频| 久久亚洲二区| 亚洲福利一区| 欧美极品一区| 日韩一二三在线视频播| 在线性视频日韩欧美| 欧美激情精品久久久久久| 亚洲国产裸拍裸体视频在线观看乱了中文 | 亚洲一区国产精品| 亚洲一级黄色| 国产精品久久久久久av下载红粉 | 久久久久久噜噜噜久久久精品| 国产欧美一区二区三区在线老狼 | 国产欧美日韩精品专区| 欧美一级免费视频| 久久亚洲春色中文字幕| 亚洲成人在线网| 欧美黄色小视频| 国产精品人人爽人人做我的可爱 | 久久久噜噜噜久久久| 亚洲男女毛片无遮挡| 国产精品成人一区二区网站软件 | 欧美日韩综合一区| 亚洲婷婷综合色高清在线 | aⅴ色国产欧美| 欧美视频二区| 久久er精品视频| 亚洲高清不卡在线| 亚洲性视频网址| 国产一区二区电影在线观看| 久久这里有精品15一区二区三区| 亚洲高清不卡在线| 亚洲欧美中日韩| 亚洲高清在线视频| 国产精品美女久久福利网站| 欧美在线国产精品| 亚洲精品一区二区三区不| 欧美亚洲日本网站| 亚洲黄一区二区三区| 国产精品成人aaaaa网站| 久久成人久久爱| 一本大道久久a久久综合婷婷 | 亚洲一级片在线观看| 国产一区久久| 欧美日韩一区三区四区| 久久久久久久久伊人| 亚洲精选大片| 免费观看成人网| 欧美亚洲在线播放| 中日韩美女免费视频网址在线观看 | 国产毛片精品视频| 欧美精品国产精品日韩精品| 香港成人在线视频| 99国内精品久久| 亚洲国产精品电影| 久久一区二区三区av| 亚洲永久精品大片| 99re视频这里只有精品| 亚洲国产精品一区二区第四页av| 国产精品美女久久久久av超清| 欧美xx69| 免费一级欧美片在线播放| 欧美在线一区二区三区| 亚洲欧美国产精品桃花| 亚洲精品专区| 亚洲精品免费看| 欧美激情一区二区三区成人| 久久最新视频| 久久精品国产91精品亚洲| 亚洲欧美中文日韩在线| 中日韩美女免费视频网址在线观看 | 久久精品欧洲| 久久久久九九九| 久久久久久久久久久一区 | 日韩视频精品在线| 亚洲三级国产| 亚洲精品孕妇| 夜夜精品视频| 亚洲在线成人精品| 小处雏高清一区二区三区 | 亚洲福利视频在线| 亚洲国产日韩欧美在线99| 亚洲福利免费| 亚洲黄色成人| 99av国产精品欲麻豆| 中文亚洲视频在线| 亚洲欧美日韩国产精品| 欧美在线播放一区| 久久久久久久波多野高潮日日| 久久久精品五月天| 蜜桃久久精品乱码一区二区| 欧美成人一区二区三区在线观看 | 亚洲欧美日韩精品久久| 午夜电影亚洲| 久热这里只精品99re8久| 欧美风情在线观看| 国产精品hd| 国内外成人在线视频| 亚洲国产导航| 亚洲视频中文| 久久久噜噜噜| 亚洲精品女人| 夜夜嗨av一区二区三区网页| 亚洲欧洲99久久| 女主播福利一区| 国产精品va在线播放| 国产日韩欧美一区在线| 亚洲激情欧美| 午夜伦理片一区| 欧美福利精品| 亚洲一区二区不卡免费| 久久久久久久尹人综合网亚洲| 欧美精品乱人伦久久久久久| 国产精品视频区| 亚洲精品中文字幕在线观看| 午夜视频一区二区| 亚洲国产成人porn| 欧美一区激情| 欧美午夜大胆人体| 亚洲国产精品t66y| 先锋影音国产一区| 91久久精品国产| 久久精品欧美| 国产欧美精品一区aⅴ影院| 亚洲精品免费在线| 久久久久久久网站| 亚洲少妇中出一区| 你懂的视频一区二区| 国产亚洲综合在线| 亚洲自拍另类| 亚洲精品系列| 欧美丰满高潮xxxx喷水动漫| 国产最新精品精品你懂的|