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

天行健 君子當自強而不息

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>
            免费影视亚洲| 激情综合五月天| 欧美日韩视频在线第一区| 欧美老女人xx| 欧美日韩精品免费 | 久久综合久色欧美综合狠狠| 久久一区二区视频| 亚洲成人资源| 一本久久a久久免费精品不卡| 一区二区三区精品在线| 欧美一区二区精美| 欧美freesex8一10精品| 欧美视频手机在线| 国内精品模特av私拍在线观看| 亚洲国产成人精品久久久国产成人一区| 亚洲第一精品影视| 亚洲图片你懂的| 久久综合国产精品| 99在线热播精品免费99热| 午夜欧美大尺度福利影院在线看| 久久久人成影片一区二区三区| 欧美人妖在线观看| 国内精品久久久久影院优| 99精品久久| 美国十次成人| 亚洲一区激情| 欧美成人免费在线| 国产一区二区高清| 日韩视频在线永久播放| 欧美一区二区三区在线播放| 欧美成人在线免费视频| 亚洲综合日韩| 欧美区亚洲区| 亚洲国产乱码最新视频| 欧美专区在线观看| 99热这里只有成人精品国产| 久久综合久久综合这里只有精品| 国产精品久久久久9999吃药| 亚洲欧洲精品一区二区三区不卡 | 在线观看亚洲| 久久久久国产精品人| 夜夜嗨av一区二区三区中文字幕| 久久最新视频| 国产午夜精品全部视频在线播放| 中文久久精品| 亚洲看片免费| 欧美日韩国产一区二区三区地区| 亚洲丶国产丶欧美一区二区三区| 欧美在线关看| 亚洲免费在线| 国产精品亚洲综合一区在线观看 | 亚洲精品视频在线观看免费| 能在线观看的日韩av| 欧美主播一区二区三区美女 久久精品人 | 亚洲私拍自拍| 国产精品vvv| 亚洲一区二区欧美日韩| 亚洲精品乱码久久久久久蜜桃91| 蜜桃精品一区二区三区| 在线免费日韩片| 麻豆精品传媒视频| 久久久久久夜| 亚洲国产高清一区二区三区| 美女福利精品视频| 久久天天躁狠狠躁夜夜av| 影音先锋欧美精品| 亚洲第一色在线| 久久先锋影音| 亚洲大胆人体在线| 亚洲国产成人av| 欧美成人精品激情在线观看| 99国产精品| 在线视频欧美日韩| 国产人久久人人人人爽| 久热精品视频| 欧美成人性网| 亚洲午夜女主播在线直播| 亚洲一区二区三区高清不卡| 国产午夜精品全部视频在线播放| 久久亚洲不卡| 欧美大胆人体视频| 亚洲一二三区视频在线观看| 午夜精品影院在线观看| 在线观看不卡av| 亚洲精品小视频| 国产女主播一区| 欧美成ee人免费视频| 欧美日本二区| 久久久夜色精品亚洲| 男女激情久久| 欧美一区二区精品在线| 国产精品久久久久久久久免费桃花| 欧美在线观看视频一区二区| 久久夜色精品国产| 亚洲永久免费视频| 久久综合精品一区| 亚洲一二三区在线观看| 久久精品人人| 亚洲一区二区三区777| 久久欧美肥婆一二区| 亚洲性感美女99在线| 久久久精彩视频| 亚洲免费在线播放| 免费不卡亚洲欧美| 亚洲一区二区网站| 欧美成人69av| 久久免费精品视频| 国产精品久久久久久久久久免费 | 亚洲制服少妇| 鲁大师影院一区二区三区| 午夜精品理论片| 欧美精品一线| 欧美成年视频| 国内一区二区三区| 亚洲影视九九影院在线观看| 日韩视频在线一区二区| 久久免费99精品久久久久久| 欧美在线视频一区二区| 欧美午夜不卡在线观看免费 | 欧美日韩视频专区在线播放| 欧美韩国日本一区| 国模精品一区二区三区色天香| 9久草视频在线视频精品| 亚洲精品综合在线| 久久久久久久精| 久久国产精品久久久久久电车| 欧美日韩亚洲激情| 亚洲裸体视频| 欧美大片在线看| 久久伊人精品天天| 欧美视频中文在线看| 欧美国产日韩精品| 国产综合欧美在线看| 亚洲少妇在线| 一区二区国产在线观看| 免费成人黄色片| 久久亚洲综合网| 国产亚洲激情视频在线| 亚洲一区二区三区777| 亚洲免费影视第一页| 国产精品久久久爽爽爽麻豆色哟哟| 日韩一区二区免费高清| 99国产一区| 国产精品草草| 亚洲女性裸体视频| 久久高清国产| 樱花yy私人影院亚洲| 老牛嫩草一区二区三区日本| 欧美福利一区二区| 一本色道久久综合亚洲精品不 | 午夜电影亚洲| 久久久久国产精品厨房| 在线成人免费观看| 欧美高清在线一区| 一区二区三区四区精品| 午夜视频在线观看一区二区| 国产毛片一区| 久久久亚洲高清| 亚洲激情一区二区三区| 亚洲一区二区久久| 韩国精品主播一区二区在线观看| 久久久精彩视频| 亚洲精品视频一区| 欧美亚洲日本一区| 亚洲欧洲精品一区| 国产精品毛片a∨一区二区三区|国| 亚洲欧美制服另类日韩| 麻豆精品在线观看| 亚洲视频在线免费观看| 红桃视频一区| 欧美日韩亚洲网| 久久精品一级爱片| 99在线热播精品免费99热| 久久成人免费日本黄色| 亚洲人永久免费| 国产美女诱惑一区二区| 欧美成年人视频网站欧美| 亚洲一区二区三区久久| 欧美国产先锋| 欧美在线日韩| 亚洲视频一区二区免费在线观看| 国内自拍一区| 国产精品久久久久久久第一福利| 蜜桃av噜噜一区| 欧美一级久久久| 99精品国产在热久久下载| 美女国产一区| 久久精品视频在线看| 亚洲一区二区高清| 亚洲免费观看高清完整版在线观看熊| 国产日韩欧美高清| 国产精品va在线| 欧美人在线观看| 欧美1区2区视频| 久久久www成人免费精品| 亚洲一区二区影院| 一区二区不卡在线视频 午夜欧美不卡'| 裸体歌舞表演一区二区| 欧美在线影院| 午夜国产一区|