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

天行健 君子當(dāng)自強(qiáng)而不息

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


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


公告

導(dǎo)航

統(tǒng)計(jì)

常用鏈接

隨筆分類(178)

3D游戲編程相關(guān)鏈接

搜索

最新評論

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <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>
            欧美国产先锋| 日韩视频精品在线| 午夜在线一区| 国产主播精品| 美女精品视频一区| 久久午夜激情| 久久欧美中文字幕| 在线播放亚洲一区| 亚洲第一黄色网| 欧美激情二区三区| 欧美福利一区二区| 亚洲永久在线观看| 午夜一级在线看亚洲| 国产真实久久| 亚洲三级毛片| 国产精品一区二区你懂的| 久久久免费精品| 嫩草影视亚洲| 国产精品v日韩精品| 欧美在线999| 久久综合伊人77777| 中文久久精品| 久久久久国产精品麻豆ai换脸 | 在线视频亚洲一区| 亚洲欧美国产高清| 亚洲国产精品成人久久综合一区| 亚洲高清视频一区| 国产拍揄自揄精品视频麻豆| 久久亚洲精品一区二区| 欧美日韩国产免费| 巨乳诱惑日韩免费av| 欧美日韩精品中文字幕| 久久―日本道色综合久久| 欧美猛交免费看| 老鸭窝毛片一区二区三区 | 欧美一级视频精品观看| 亚洲精品永久免费| 久久国产手机看片| 亚洲综合首页| 欧美黄色日本| 蜜臀久久99精品久久久画质超高清| 欧美日韩直播| 91久久线看在观草草青青| 国产日韩在线播放| 99伊人成综合| 91久久精品国产| 羞羞色国产精品| 亚洲男人天堂2024| 欧美日韩国产在线播放网站| 蜜臀久久99精品久久久久久9| 国产精品一区二区三区成人| 一本大道久久a久久精二百| 亚洲国产日韩精品| 久久精品国产999大香线蕉| 香蕉乱码成人久久天堂爱免费 | 国产精品a级| 亚洲精选大片| 一本色道久久综合亚洲精品高清 | 亚洲激情在线播放| 久久久久一区二区三区| 久久激情综合| 国产目拍亚洲精品99久久精品 | 亚洲美女中文字幕| 亚洲精品国产精品国产自| 久久久999精品视频| 久久久久久久999| 国产亚洲精品久久飘花| 亚洲欧美成人一区二区三区| 午夜精品影院| 国产日韩欧美自拍| 午夜精品一区二区三区在线视| 亚洲网址在线| 国产精品欧美日韩一区二区| 亚洲欧美日本国产专区一区| 亚洲一区免费| 国产欧美一区二区三区久久人妖| 先锋影音国产精品| 久久久综合网站| 亚洲国产精品一区二区久| 模特精品在线| 亚洲精品中文字幕女同| 亚洲伊人伊色伊影伊综合网| 国产精品一区久久久| 欧美专区第一页| 欧美成人自拍| 亚洲视频福利| 国产农村妇女毛片精品久久麻豆| 午夜久久黄色| 欧美激情亚洲自拍| 亚洲一区欧美一区| 国产一区二区三区四区| 久久这里有精品视频| 亚洲精品小视频在线观看| 午夜久久影院| 亚洲第一区中文99精品| 欧美日韩一区三区四区| 性xx色xx综合久久久xx| 欧美成人国产va精品日本一级| 亚洲精选成人| 国产日韩欧美综合精品| 欧美二区在线播放| 亚洲欧洲av一区二区| 亚洲成人自拍视频| 久久影音先锋| 日韩小视频在线观看专区| 久久精品水蜜桃av综合天堂| 亚洲东热激情| 国产欧美91| 欧美日韩性视频在线| 久久国产精品色婷婷| 亚洲精品一区二区网址| 久久青草福利网站| 亚洲一区制服诱惑| 亚洲国产婷婷| 国产区精品视频| 欧美极品一区| 久久一二三区| 亚洲欧美中文日韩在线| 亚洲日本va午夜在线电影| 老司机精品视频一区二区三区| 一本色道88久久加勒比精品| 激情偷拍久久| 国产一区视频网站| 国产精品久久一级| 欧美精品乱码久久久久久按摩| 欧美伊人久久| 一区二区三区高清不卡| 亚洲人成艺术| 怡红院精品视频| 欧美在线高清| 亚洲在线电影| 在线亚洲自拍| 一区二区久久久久| 亚洲精品看片| 亚洲欧洲精品成人久久奇米网| 免费国产一区二区| 久久嫩草精品久久久精品| 亚洲欧美中日韩| 亚洲欧美在线播放| 亚洲一区二区三区国产| 亚洲婷婷在线| 亚洲一区三区视频在线观看| 一区二区三区高清视频在线观看| 亚洲全黄一级网站| 亚洲国产婷婷综合在线精品| 在线观看视频一区二区| 久久丁香综合五月国产三级网站| 亚洲综合欧美| 欧美一级在线播放| 欧美在线观看一区| 久久久久久久999| 免费人成精品欧美精品| 免费不卡亚洲欧美| 欧美激情视频在线播放 | 亚洲国产91| 亚洲欧洲精品一区二区三区 | av不卡在线观看| 在线一区二区视频| 亚洲免费视频一区二区| 欧美在线视频观看| 麻豆成人在线播放| 欧美大片在线观看| 亚洲精品1区| 亚洲在线网站| 老司机一区二区三区| 欧美精品三级在线观看| 国产精品久久久久久五月尺| 国产一区白浆| 日韩图片一区| 欧美一区在线视频| 欧美 日韩 国产 一区| 亚洲毛片一区| 午夜在线不卡| 欧美插天视频在线播放| 999亚洲国产精| 欧美一区二区精美| 女生裸体视频一区二区三区| 欧美日韩免费观看一区=区三区| 国产精品视频免费一区| 亚洲国产一区二区三区高清| 夜久久久久久| 久久久综合网站| 洋洋av久久久久久久一区| 欧美尤物一区| 亚洲国产一区二区三区高清| 亚洲图片你懂的| 欧美大胆人体视频| 国产无一区二区| 99综合视频| 久久夜色精品国产欧美乱极品| 日韩亚洲欧美高清| 久久久久久久久久久久久女国产乱| 欧美日韩亚洲不卡| 亚洲国产经典视频| 国产精品三级视频| 日韩网站在线| 欧美成人激情在线| 欧美一区亚洲| 国产精品免费小视频| 亚洲美女色禁图|