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

天行健 君子當自強而不息

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>
            亚洲国产专区校园欧美| 91久久精品国产91久久性色tv| 亚洲区国产区| 欧美日韩国产在线一区| 亚洲国产成人av好男人在线观看| 久久国内精品视频| 久久精品99国产精品| 尤物网精品视频| 亚洲精品少妇网址| 欧美视频在线看| 久久xxxx| 欧美成人黑人xx视频免费观看| 亚洲精品在线看| 亚洲午夜一区| 精品二区视频| 日韩视频在线观看国产| 国产精品综合网站| 久久人91精品久久久久久不卡 | 日韩视频久久| 亚洲一区二区三区免费视频| 黑人巨大精品欧美黑白配亚洲| 免费视频一区二区三区在线观看| 欧美激情中文字幕乱码免费| 亚洲一区中文| 久久综合色一综合色88| 亚洲午夜精品久久久久久app| 香蕉视频成人在线观看| 亚洲国产清纯| 亚洲欧美日韩精品久久久| 亚洲国产免费| 午夜精品久久久久久| 亚洲巨乳在线| 久久九九99| 欧美一区午夜精品| 欧美风情在线| 蜜乳av另类精品一区二区| 欧美性猛片xxxx免费看久爱 | 亚洲九九爱视频| 亚洲一区二区三区免费观看| 亚洲国产精品一区二区三区| 亚洲一区二区高清| 亚洲精品人人| 久久久久综合一区二区三区| 亚洲自拍三区| 欧美日韩dvd在线观看| 久久综合狠狠| 国产免费成人av| 99re这里只有精品6| 在线观看国产一区二区| 亚洲欧美一区二区三区久久| 亚洲国产欧美一区| 久久综合色天天久久综合图片| 羞羞色国产精品| 欧美屁股在线| 亚洲欧洲精品一区二区三区不卡 | 国产视频一区二区在线观看| 欧美电影免费观看高清| 国产精品欧美激情| 一个色综合导航| 亚洲免费大片| 欧美国产日本| 亚洲激情在线视频| 亚洲国产精品成人综合| 欧美一区二视频| 久久精品99国产精品日本| 国产精品国产三级国产专播精品人 | 欧美精品播放| 亚洲黄色片网站| 亚洲区国产区| 欧美日韩国产成人精品| 亚洲精品一区二区三区不| 91久久在线观看| 欧美激情一区三区| 亚洲另类在线视频| 亚洲午夜伦理| 国产欧美一级| 久久福利一区| 欧美国产先锋| 一区二区三区精品国产| 国产精品99免费看| 亚洲综合日韩| 免费91麻豆精品国产自产在线观看| 韩国一区电影| 欧美福利视频在线观看| 99热在线精品观看| 性色av香蕉一区二区| 国产欧美一区二区三区另类精品| 欧美在线日韩| 欧美国产日韩a欧美在线观看| 亚洲精品免费一二三区| 欧美日韩综合在线| 午夜精品区一区二区三| 欧美成年人视频网站| 一本色道久久综合亚洲精品不| 国产精品九九久久久久久久| 久久国产夜色精品鲁鲁99| 亚洲成人在线视频播放| 亚洲三级影院| 国产乱码精品一区二区三区不卡 | 久热综合在线亚洲精品| 亚洲精品欧美日韩| 久久久7777| 日韩亚洲视频| 国语自产在线不卡| 欧美日韩国产色综合一二三四 | 午夜一区不卡| 亚洲国产一区在线| 久久av一区二区三区漫画| 亚洲黄色成人久久久| 国产精品久久久久久久久久直播| 久久精品人人做人人综合| 亚洲人午夜精品免费| 久久乐国产精品| 99精品热视频只有精品10| 国产一区二区三区免费不卡| 欧美日韩国产一区二区三区地区| 久久激情综合网| 亚洲无线一线二线三线区别av| 欧美国产日韩一区二区| 久久不射2019中文字幕| 这里只有精品视频在线| 亚洲国产精选| 影视先锋久久| 国产日韩欧美91| 国产精品久久久一区二区| 欧美激情一区二区| 老鸭窝毛片一区二区三区| 欧美一区二区三区四区在线观看 | 免费在线国产精品| 性欧美xxxx视频在线观看| 日韩性生活视频| 亚洲国产高清视频| 黄色国产精品| 国内外成人在线| 国产精品羞羞答答| 国产精品白丝av嫩草影院 | 亚洲尤物精选| 一区二区三区黄色| 亚洲精品网址在线观看| 欧美激情 亚洲a∨综合| 欧美激情国产日韩| 欧美成人国产| 欧美成人免费大片| 美女视频黄免费的久久| 久久偷看各类wc女厕嘘嘘偷窃| 久久丁香综合五月国产三级网站| 一区二区三区偷拍| 亚洲视频自拍偷拍| 亚洲小说欧美另类社区| 亚洲小少妇裸体bbw| 亚洲一区二区三区高清不卡| 亚洲永久精品国产| 欧美在线一区二区三区| 久久亚洲精品欧美| 美女主播精品视频一二三四| 欧美黄色免费| 亚洲精品孕妇| 一区二区三区四区在线| 亚洲一区二区在线免费观看| 亚洲欧美中文日韩v在线观看| 欧美亚洲网站| 免费不卡中文字幕视频| 欧美日韩国产成人| 国产农村妇女毛片精品久久莱园子| 国产精品婷婷| 一色屋精品视频在线看| 亚洲精品视频在线| 亚洲一区国产| 久久久久久久精| 亚洲二区在线观看| 这里只有精品视频| 久久久精品性| 欧美日本韩国在线| 国产亚洲激情在线| 亚洲区在线播放| 欧美在线观看天堂一区二区三区 | 亚洲午夜精品久久| 久久精品视频一| 亚洲激情一区二区三区| 亚洲自拍16p| 麻豆成人av| 国产精品看片资源| 亚洲国产欧美一区二区三区久久| aⅴ色国产欧美| 久久亚洲精品欧美| 亚洲精品免费观看| 久久九九久久九九| 国产精品v日韩精品| 亚洲电影天堂av| 午夜精品久久久久久99热| 欧美国产先锋| 欧美一区综合| 欧美香蕉视频| 最新69国产成人精品视频免费| 西西裸体人体做爰大胆久久久| 欧美激情一区在线| 性欧美精品高清| 国产精品进线69影院| 亚洲欧洲在线一区| 玖玖综合伊人|