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

天行健 君子當自強而不息

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 閱讀(273) 評論(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>
            欧美永久精品| 欧美激情无毛| 国产亚洲精品7777| 久久精品视频在线播放| 欧美在线免费观看亚洲| 一区二区三区在线免费视频| 久久综合精品国产一区二区三区| 欧美一区二区三区四区在线| 国产综合网站| 亚洲国产91精品在线观看| 蜜臀va亚洲va欧美va天堂| 亚洲精品一品区二品区三品区| 亚洲精品国产精品国自产在线| 欧美日一区二区在线观看| 欧美一区二区在线播放| 久久亚洲国产成人| 99视频在线精品国自产拍免费观看 | 欧美日韩成人在线播放| 亚洲欧美日韩天堂一区二区| 欧美一站二站| 日韩亚洲综合在线| 香蕉尹人综合在线观看| 亚洲国产日韩欧美在线动漫| 99精品久久久| 在线免费不卡视频| 亚洲香蕉视频| 最近看过的日韩成人| 亚洲一区自拍| 99re6这里只有精品视频在线观看| 中文在线资源观看视频网站免费不卡| 国内精品视频在线播放| 日韩一级片网址| 精品成人一区二区| 亚洲小视频在线观看| 亚洲激情视频在线播放| 亚洲一二三区精品| 日韩亚洲欧美精品| 久久野战av| 欧美综合第一页| 欧美视频一区二区三区在线观看| 久久琪琪电影院| 欧美少妇一区| 欧美黄色免费网站| 狠狠色狠狠色综合人人| 亚洲视频网在线直播| 99热在这里有精品免费| 久久免费高清| 久久久久久久久久久一区| 国产精品国产三级国产aⅴ浪潮 | 免费成人黄色片| 国产欧美在线视频| 一本大道久久a久久精二百| 亚洲日韩第九十九页| 久久久久国产精品厨房| 欧美在线视频一区二区| 国产精品三上| 亚洲一区二区三区中文字幕在线| 一本一本大道香蕉久在线精品| 麻豆精品视频在线| 欧美主播一区二区三区美女 久久精品人 | 欧美在线日韩精品| 欧美在线观看你懂的| 国产欧美丝祙| 亚洲欧美另类在线观看| 午夜国产精品视频| 国产精品久久久一区二区三区| 亚洲日本中文字幕免费在线不卡| 亚洲精品美女在线| 欧美精品亚洲一区二区在线播放| 欧美黄色免费| 日韩亚洲视频| 国产精品国产a| 亚洲一区欧美一区| 久久久成人精品| 在线不卡中文字幕| 欧美国产一区二区在线观看| 亚洲精品一区二区在线| 一本综合久久| 国产精品爱啪在线线免费观看| 99re热精品| 欧美在线播放一区| 激情综合色综合久久综合| 久久美女艺术照精彩视频福利播放| 女女同性女同一区二区三区91| 亚洲黄色影片| 欧美视频在线观看视频极品| 亚洲尤物在线| 欧美va日韩va| 99精品欧美一区| 国产精品拍天天在线| 欧美一级二区| 亚洲国产女人aaa毛片在线| 一区二区av在线| 国产三级欧美三级日产三级99| 久久尤物视频| 一本色道久久综合一区| 久久国产精品99精品国产| 亚洲国产精品成人综合色在线婷婷| 欧美成人一区在线| 亚洲午夜电影在线观看| 米奇777在线欧美播放| 一区二区电影免费在线观看| 国产免费成人av| 欧美成人69av| 香蕉久久精品日日躁夜夜躁| 欧美国产在线视频| 欧美在线影院| 亚洲乱码一区二区| 国产手机视频一区二区| 欧美精品日韩精品| 久久精品国产亚洲aⅴ| 亚洲国产日韩欧美在线动漫| 久久成人av少妇免费| 亚洲美女福利视频网站| 韩日在线一区| 国产精品第一区| 欧美成人精品在线播放| 欧美一区深夜视频| 一二美女精品欧洲| 亚洲福利av| 老司机精品视频网站| 亚洲欧美日韩在线| 一区二区日韩伦理片| 亚洲人成在线播放网站岛国| 国产一区二区三区久久久| 国产精品超碰97尤物18| 欧美成人国产va精品日本一级| 久久国产精品久久w女人spa| 亚洲视频在线观看免费| 亚洲美洲欧洲综合国产一区| 欧美国产日产韩国视频| 美日韩在线观看| 久久久夜精品| 久久精品国产第一区二区三区最新章节 | 亚洲综合三区| 亚洲香蕉在线观看| 艳妇臀荡乳欲伦亚洲一区| 亚洲黄色av一区| 91久久国产综合久久蜜月精品 | 亚洲视频一区二区在线观看| 亚洲破处大片| 亚洲国产精品一区二区www在线| 国产综合久久久久久| 国产在线欧美| 国产亚洲精品7777| 国产一区二区看久久| 国产午夜精品全部视频播放| 国产欧美va欧美va香蕉在| 国产精品久久久久影院亚瑟| 国产精品视频免费| 国产精品综合| 韩国女主播一区| 黑人操亚洲美女惩罚| 狠狠88综合久久久久综合网| 国模一区二区三区| 永久免费毛片在线播放不卡| 今天的高清视频免费播放成人| 伊人久久综合| 亚洲靠逼com| 亚洲综合成人在线| 性色一区二区三区| 看片网站欧美日韩| 欧美激情亚洲国产| 夜夜嗨av一区二区三区中文字幕 | 亚洲在线免费| 久久黄色小说| 欧美极品影院| 国产精品久久91| 国产一级一区二区| 亚洲激情在线激情| 亚洲线精品一区二区三区八戒| 欧美在线播放视频| 欧美激情视频一区二区三区在线播放 | 亚洲一区二区三区激情| 性欧美xxxx大乳国产app| 久久国产精品亚洲va麻豆| 久久久www成人免费毛片麻豆| 久久精品99国产精品日本| 免费亚洲电影在线| 国产毛片一区| 亚洲麻豆av| 久久精品五月婷婷| 亚洲精品久久久久久久久久久久 | 久久精品亚洲一区二区三区浴池 | 欧美一区=区| 欧美国产一区二区| 亚洲一区中文字幕在线观看| 麻豆国产精品va在线观看不卡| 国产精品v欧美精品v日本精品动漫| 国产午夜精品一区二区三区欧美| 亚洲欧洲另类国产综合| 欧美在线视频二区| 亚洲精品中文字| 久久综合九色九九| 国产精品日韩精品欧美精品| 亚洲黄网站在线观看| 久久国产精品99精品国产| 亚洲免费av观看| 欧美国产日韩免费| 1024国产精品|