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

天行健 君子當自強而不息

Working with Maps and Levels(7)

cTrigger::get_trigger

get_trigger is the function in the trigger class that you call every time the player’s character
moves. get_trigger will take the coordinates of the character you are checking and
return the identification number of the first trigger found at that location (if any). If
no triggers are found at the specified location, get_trigger returns a value of zero.

A great deal is going on in get_trigger, but things are not too complicated. As
the linked list of triggers is scanned, each trigger in question is checked to
see whether it and the specified coordinates share the same map space.

If so, the trigger’s identification number is returned.

CAUTION
Never assign a value of zero to a trigger because the trigger class uses zero
to signify that no trigger is found when the get_trigger function is called.

long cTrigger::get_trigger(float x_pos, float y_pos, float z_pos)
{
    
for(sTrigger* trigger = m_root_trigger; trigger != NULL; trigger = trigger->next)
    {
        
if(! trigger->enabled)      // only bother if enabled
            continue;

        
float x_diff, y_diff, z_diff, dist;

        
switch(trigger->type)
        {
        
case TRIGGER_SPHERE:
            
// check distance from sphere (using radius)
            x_diff = fabs(trigger->x1 - x_pos);
            y_diff = fabs(trigger->y1 - y_pos);
            z_diff = fabs(trigger->z1 - z_pos);

            dist = x_diff * x_diff + y_diff * y_diff + z_diff * z_diff;

            
if(dist <= trigger->radius)
                
return trigger->id;

            
break;

        
case TRIGGER_BOX:
            
// check if inside box
            if((x_pos >= trigger->x1 && x_pos <= trigger->x2) &&
               (y_pos >= trigger->y1 && y_pos <= trigger->y2) &&
               (z_pos >= trigger->z1 && z_pos <= trigger->z2))
            {
                
return trigger->id;
            }

            
break;

        
case TRIGGER_CYLINDER:
            
// first make sure within height bounds
            if(y_pos >= trigger->y1 && y_pos <= trigger->y1 + trigger->y2)
            {
                
// check distance from cylinder
                x_diff = abs(trigger->x1 - x_pos);
                y_diff = abs(trigger->y1 - y_pos);
                z_diff = abs(trigger->z1 - z_pos);
            
                dist = x_diff * x_diff + y_diff * y_diff + z_diff * z_diff;

                
if(dist <= trigger->radius)
                    
return trigger->id;
            }

            
break;

        
case TRIGGER_TRIANGLE:
            
// first make sure within height bounds
            if(y_pos >= trigger->y1 && y_pos <= trigger->y1 + trigger->y2)
            {
                
// check if point in front of all lines

                D3DXVECTOR2 norm_vec;
                
                
// x1,z1 to x2,z2
                D3DXVec2Normalize(&norm_vec, &D3DXVECTOR2(trigger->z2 - trigger->z1, trigger->x1 - trigger->x2));

                
if(D3DXVec2Dot(&D3DXVECTOR2(x_pos - trigger->x1, z_pos - trigger->z1), &norm_vec) < 0)
                    
break;

                
// x2,z2 to x3,z3
                D3DXVec2Normalize(&norm_vec, &D3DXVECTOR2(trigger->z3 - trigger->z2, trigger->x2 - trigger->x3));

                
if(D3DXVec2Dot(&D3DXVECTOR2(x_pos - trigger->x2, z_pos - trigger->z2), &norm_vec) < 0)
                    
break;

                
// x3,z3 to xz,zz
                D3DXVec2Normalize(&norm_vec, &D3DXVECTOR2(trigger->z1 - trigger->z3, trigger->x3 - trigger->x1));

                
if(D3DXVec2Dot(&D3DXVECTOR2(x_pos - trigger->x3, z_pos - trigger->z3), &norm_vec) < 0)
                    
break;

                
return trigger->id;
            }

            
break;
        }
    }

    
return 0;   // means no trigger found
}

At this point, you check a trigger that is enabled to see whether it intersects with
the coordinates passed in the x_pos, y_pos, and z_pos arguments of the get_trigger function.
Each trigger has a special way of determining whether the specified coordinates
are within the trigger space, and by using a switch statement, the following
code can determine how to process that intersection check:

For spheres, you use a distance check. If the coordinates have a distance equal to
or less than the radius of the sphere, the trigger is touched.

Box triggers use typical bounding boxes to compare the coordinates of the opposing
corners to the coordinates being checked to see whether they intersect.

Cylinder triggers use a mixture of spheres and bounding boxes.

The triangle trigger code shown here checks whether the coordinate in question
is in front of all three edges of the triangle by using what’s called a dot-product. For
each edge of the triangle, the dot-product is calculated and checked to see whether
the coordinates in question are on the inside or the outside of the triangle.

You can think of the dot-product as the distance of the coordinates in question
from a triangle edge. A negative distance means that the coordinates in question
are on the outside of the triangle, whereas a positive distance means that the coordinates
in question are inside the triangle.

If all three dot-product checks come up with positive values, the coordinates in question
must be inside the triangle. You use one last test to determine whether the coordinates
in question fall within the height range defined in the sTrigger structure.

posted on 2007-12-10 11:15 lovedday 閱讀(270) 評論(0)  編輯 收藏 引用

公告

導航

統計

常用鏈接

隨筆分類(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>
            欧美一区二区在线观看| 亚洲国内精品| 亚洲女爱视频在线| 国产精品亚洲片夜色在线| 欧美亚洲免费在线| 午夜一区二区三视频在线观看 | 久久成人精品一区二区三区| 国产亚洲美州欧州综合国| 麻豆精品在线视频| 欧美激情一区二区三区蜜桃视频| 9色精品在线| 亚洲香蕉伊综合在人在线视看| 国产精品视频xxx| 牛牛影视久久网| 欧美三级不卡| 蜜乳av另类精品一区二区| 欧美韩国日本一区| 欧美在线免费视屏| 欧美aa国产视频| 欧美一区二区观看视频| 美女被久久久| 欧美一级片久久久久久久 | 亚洲第一色中文字幕| 欧美色图麻豆| 裸体一区二区三区| 国产精品久久久99| 亚洲国产精品久久精品怡红院| 欧美天天影院| 欧美国产欧美综合 | 欧美日韩中文字幕| 欧美成人一区在线| 国产精品一区毛片| 亚洲美女中文字幕| 亚洲国产精品久久久久秋霞不卡| 99精品国产在热久久下载| 影音先锋久久精品| 亚洲一区在线播放| 中文高清一区| 欧美大片免费| 欧美1区视频| 国产一区二区av| 亚洲网站在线播放| 在线亚洲欧美视频| 欧美激情视频一区二区三区在线播放| 欧美一区二区日韩一区二区| 欧美日韩一区二区在线| 欧美激情1区| 樱桃成人精品视频在线播放| 午夜一区不卡| 久久精品人人| 国产视频一区二区在线观看| 亚洲天堂av高清| 亚洲婷婷综合色高清在线| 欧美精品国产精品日韩精品| 亚洲大胆视频| 亚洲人永久免费| 美女视频一区免费观看| 欧美凹凸一区二区三区视频| 悠悠资源网亚洲青| 久久久天天操| 鲁大师影院一区二区三区| 国产综合视频| 久久精品国产亚洲一区二区三区| 欧美在线播放一区二区| 国产欧美日本| 久久精品国产精品| 老色鬼久久亚洲一区二区| 尤妮丝一区二区裸体视频| 久久人人爽爽爽人久久久| 牛牛精品成人免费视频| 亚洲精品国产精品乱码不99按摩 | 午夜国产精品影院在线观看| 先锋影音国产精品| 国产综合色在线| 老妇喷水一区二区三区| 欧美黄色一区| 这里是久久伊人| 国产精品毛片在线看| 午夜精品短视频| 免费欧美日韩国产三级电影| 最新亚洲激情| 欧美午夜久久久| 午夜精品久久久久久久久久久| 久久精品夜色噜噜亚洲a∨| 在线日韩一区二区| 欧美日韩国产色视频| 亚洲综合日韩在线| 免费在线成人| 亚洲一区二区三区高清| 国产亚洲一区二区三区在线观看 | 一区二区三区精品在线| 国产精品网曝门| 久久久91精品国产| 亚洲精品1区| 久久国产婷婷国产香蕉| 亚洲国产老妈| 国产精品伦理| 欧美成人免费一级人片100| 亚洲小说区图片区| 欧美国产三区| 先锋影音网一区二区| 亚洲日本va午夜在线电影| 国产精品一二三四| 欧美电影资源| 久久国产主播| 亚洲天堂成人在线观看| 亚洲第一精品福利| 欧美一级播放| 制服丝袜激情欧洲亚洲| 在线看无码的免费网站| 国产精品外国| 欧美色大人视频| 蜜臀久久99精品久久久画质超高清 | 欧美大色视频| 久久精品综合| 香蕉成人久久| 中日韩高清电影网| 亚洲国产日日夜夜| 韩国av一区二区三区四区| 国产精品久久久久毛片软件| 欧美国产精品劲爆| 久久中文字幕一区| 久久精品毛片| 欧美专区中文字幕| 亚洲一区精品电影| 一区二区三区av| 亚洲免费av片| 91久久在线播放| 免费的成人av| 免费观看不卡av| 麻豆精品精华液| 久久夜色精品国产欧美乱| 午夜激情综合网| 亚洲欧美国产一区二区三区| 一区二区三区免费网站| 亚洲免费观看高清完整版在线观看熊 | 亚洲自拍另类| 亚洲一区在线直播| 亚洲在线视频免费观看| 一本色道久久综合狠狠躁的推荐| 亚洲精品欧美专区| 日韩一级欧洲| 亚洲社区在线观看| 亚洲一区二区三区三| 亚洲一区在线观看视频| 午夜精品久久久久99热蜜桃导演| 销魂美女一区二区三区视频在线| 亚洲欧美日韩国产一区二区三区 | 免费看黄裸体一级大秀欧美| 麻豆av一区二区三区| 欧美成人四级电影| 亚洲国产一二三| avtt综合网| 亚洲欧美在线看| 久久久久在线观看| 欧美激情亚洲激情| 国产精品va在线播放我和闺蜜| 国产精品欧美一区二区三区奶水 | 国产一区二区日韩精品欧美精品| 韩国三级电影一区二区| 亚洲日本无吗高清不卡| 亚洲视频日本| 久久日韩粉嫩一区二区三区| 欧美顶级艳妇交换群宴| 99国内精品久久久久久久软件| 亚洲综合色激情五月| 久久蜜桃资源一区二区老牛| 欧美激情一区二区三区蜜桃视频| 国产精品久久久久久av下载红粉| 国产精品亚洲综合久久| 亚洲缚视频在线观看| 亚洲一区二区三区欧美| 老司机久久99久久精品播放免费 | 午夜在线视频一区二区区别| 久久在线视频| 99国内精品| 久久久水蜜桃av免费网站| 欧美午夜精品久久久久久浪潮 | 欧美日韩在线三区| 好看的日韩av电影| 一区二区三区鲁丝不卡| 久久久久久伊人| 夜夜嗨一区二区三区| 久久久久国产精品麻豆ai换脸| 欧美日韩精选| 国内偷自视频区视频综合| 亚洲线精品一区二区三区八戒| 久久日韩精品| 亚洲免费在线观看视频| 欧美另类综合| 亚洲大片精品永久免费| 欧美一区激情| 夜夜精品视频| 欧美精品成人91久久久久久久| 韩国女主播一区二区三区| 亚洲欧美成人在线| 亚洲狼人综合| 欧美韩日一区| 亚洲国产天堂久久国产91| 久久亚洲春色中文字幕久久久 |