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

天行健 君子當自強而不息

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

公告

導航

統(tǒng)計

常用鏈接

隨筆分類(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热免费精品| 午夜精品久久| 91久久久久久| 亚洲无人区一区| 一色屋精品亚洲香蕉网站| 91久久香蕉国产日韩欧美9色| 欧美日韩精品是欧美日韩精品| 亚洲图片欧洲图片av| 欧美一级电影久久| 亚洲日本成人网| 亚洲综合99| 亚洲黄色影院| 亚洲欧美卡通另类91av| 精品96久久久久久中文字幕无| 亚洲激情第一页| 国产农村妇女毛片精品久久莱园子 | 久久久久综合| 亚洲综合国产| 欧美jizzhd精品欧美喷水| 午夜激情综合网| 欧美成人黑人xx视频免费观看| 午夜精品影院在线观看| 欧美aaa级| 性欧美长视频| 欧美日韩高清在线| 鲁大师影院一区二区三区| 欧美三级午夜理伦三级中文幕| 久久先锋影音| 国产欧美日韩| 一区二区三区日韩精品| 亚洲精品中文字| 久久精品国语| 久久久一二三| 国产精品亚洲人在线观看| 亚洲日本电影| 亚洲国产精品久久人人爱蜜臀| 亚洲欧美日韩直播| 99天天综合性| 免费成人性网站| 理论片一区二区在线| 国产精品自在欧美一区| av不卡在线看| 亚洲视频播放| 欧美日韩国产在线播放| 亚洲成人在线视频播放 | 国内精品一区二区| 亚洲香蕉网站| 性伦欧美刺激片在线观看| 欧美人与禽性xxxxx杂性| 欧美高清视频| 亚洲精品一区二区三区四区高清| 久久天天狠狠| 欧美激情在线观看| 91久久精品国产| 欧美精品成人一区二区在线观看| 亚洲风情亚aⅴ在线发布| 亚洲激情国产| 欧美精品18videos性欧美| 最新成人在线| 99视频精品在线| 欧美日韩国产高清| 中国成人黄色视屏| 午夜精品久久久久久久99热浪潮| 国产精品亚洲一区二区三区在线| 亚洲香蕉视频| 榴莲视频成人在线观看| 亚洲国产精品久久久久秋霞蜜臀| 美女主播精品视频一二三四| 最新中文字幕亚洲| 亚洲女同同性videoxma| 国产日韩欧美电影在线观看| 久久精彩视频| 亚洲欧洲精品一区二区三区波多野1战4 | 欧美在线免费一级片| 国内综合精品午夜久久资源| 久色婷婷小香蕉久久| 亚洲精品美女91| 欧美影院一区| 亚洲精品国产精品国自产在线| 欧美日韩 国产精品| 亚洲欧美日韩一区二区| 欧美va天堂在线| 在线亚洲一区二区| 国产一区二区成人| 欧美成人情趣视频| 亚洲自拍高清| 亚洲高清二区| 欧美亚洲在线播放| 亚洲国产综合在线| 国产精品尤物| 欧美xart系列高清| 亚洲欧美国产三级| 亚洲成人直播| 久久av资源网| 中文av一区特黄| 黑丝一区二区| 国产精品久久久久毛片大屁完整版 | 一区二区三区免费网站| 老巨人导航500精品| 亚洲一级片在线观看| 伊人成人在线视频| 国产精品综合色区在线观看| 欧美+日本+国产+在线a∨观看| 亚洲欧美日韩国产综合在线 | 久久精品123| 中文精品视频| 亚洲美女黄色| 欲香欲色天天天综合和网| 国产精品视频久久| 欧美日韩另类一区| 农夫在线精品视频免费观看| 欧美一区二区三区四区高清 | 午夜精品美女久久久久av福利| 亚洲精品乱码| 最新亚洲电影| 亚洲大胆在线| 蜜桃av噜噜一区| 久久久天天操| 久久精品水蜜桃av综合天堂| 亚洲免费在线视频| 亚洲午夜精品久久久久久浪潮| 亚洲激情在线观看| 亚洲韩国青草视频| 1204国产成人精品视频| 韩国女主播一区二区三区| 国产亚洲综合精品| 国产亚洲欧美日韩精品| 国产精品免费网站在线观看| 欧美日韩精品在线| 欧美电影免费观看网站| 牛牛国产精品| 欧美成人69| 欧美精品乱码久久久久久按摩| 美女精品在线观看| 欧美激情aⅴ一区二区三区| 免费在线观看精品| 欧美成人激情视频免费观看| 欧美电影资源| 欧美成年人视频网站欧美| 欧美激情综合亚洲一二区| 欧美精品一二三| 欧美日韩一区二区三区在线| 国产精品啊啊啊| 国产日韩在线一区二区三区| 国产自产女人91一区在线观看| 激情欧美一区二区| 亚洲国产精品免费| 一区二区电影免费观看| 亚洲综合首页| 亚洲一区久久久| 国产精品99久久久久久www| 亚洲国内精品在线| 日韩亚洲欧美一区| 在线中文字幕不卡| 亚洲欧美在线磁力| 久久综合狠狠| 欧美成人dvd在线视频| 亚洲欧洲在线播放| 亚洲伊人伊色伊影伊综合网| 久久动漫亚洲| 欧美日韩精品免费看| 国产精品视频一| 亚洲国内精品| 欧美在线|欧美| 亚洲二区三区四区| 亚洲一区二区三区乱码aⅴ| 久久久久九九九| 欧美日韩日日骚| 国产在线欧美| 在线亚洲一区| 久久久久综合网| 日韩一级成人av| 久久综合九色综合欧美就去吻| 欧美日韩国产高清视频| 好吊妞这里只有精品| 亚洲天堂第二页| 欧美成人中文字幕在线| 狠狠综合久久av一区二区老牛| 亚洲精品在线电影| 久久成人一区| 亚洲国产精品成人综合色在线婷婷 | 亚洲私人影院| 欧美freesex交免费视频| 亚洲一区二区三区欧美| 欧美国产亚洲视频| 一区二区亚洲欧洲国产日韩| 亚洲欧美日韩电影| 亚洲精品乱码久久久久久日本蜜臀| 久久精品二区三区| 国产乱码精品| 亚洲自拍偷拍麻豆|