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

天行健 君子當自強而不息

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 閱讀(276) 評論(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>
            免费欧美网站| 国产精品国产精品| 亚洲国产精品久久久久秋霞蜜臀 | 国产亚洲欧洲997久久综合| 亚洲免费网址| 亚洲欧美精品在线观看| 国产亚洲福利一区| 久久综合久久综合久久| 久久综合色婷婷| 日韩一级在线| 亚洲视频1区| 一区二区三区在线视频观看 | 亚洲欧美日韩综合国产aⅴ| 亚洲特级片在线| 国产一区二区三区久久 | 99国产精品自拍| 中日韩高清电影网| 国内久久精品| 亚洲精品自在在线观看| 欧美三级不卡| 蜜臀av性久久久久蜜臀aⅴ四虎| 欧美大片在线看| 亚洲欧美影院| 久久综合色播五月| 亚洲欧美日韩在线综合| 久久另类ts人妖一区二区| 亚洲免费观看高清完整版在线观看熊| 亚洲色图自拍| 亚洲国产第一| 亚洲一区亚洲二区| 亚洲免费观看在线观看| 亚洲欧美影音先锋| 99re国产精品| 久久成人精品| 亚洲欧美资源在线| 欧美成人精品福利| 久久精品91| 欧美三级小说| 欧美成人性生活| 国产一区二区观看| av成人手机在线| 欧美一级淫片aaaaaaa视频| 亚洲精品乱码| 久久三级福利| 久久精品免视看| 国产精品成人在线| 亚洲欧洲精品一区二区三区 | 久久久久国产一区二区三区| 亚洲一区二区三区激情| 欧美成人嫩草网站| 欧美gay视频激情| 韩国av一区二区三区| 亚洲一区二区三区影院| 一区二区欧美亚洲| 欧美黄色免费网站| 欧美大片在线看免费观看| 国产一区二区精品久久| 亚洲欧美日韩在线高清直播| 亚洲色图综合久久| 欧美日韩美女在线观看| 亚洲乱亚洲高清| 99ri日韩精品视频| 欧美激情视频在线免费观看 欧美视频免费一 | 欧美在线免费一级片| 国产精品多人| 亚洲一区二区三区在线视频| 亚洲午夜久久久| 国产精品久久久久久av福利软件 | 亚洲国产精品成人久久综合一区| 极品av少妇一区二区| 久久免费视频在线观看| 美国十次成人| 亚洲国产精品一区二区第一页 | 亚洲欧美日韩综合国产aⅴ| 亚洲欧美一级二级三级| 国产欧美韩国高清| 欧美在线网站| 免费短视频成人日韩| 亚洲高清三级视频| 欧美精品三级| 一本色道久久综合| 午夜一级久久| 黄色日韩网站视频| 久久一区欧美| 亚洲精品你懂的| 99精品久久久| 国产精品久久久久秋霞鲁丝| 亚洲主播在线播放| 久久久亚洲欧洲日产国码αv | 精品二区视频| 欧美成人一区二免费视频软件| 亚洲欧洲在线免费| 亚洲欧美电影在线观看| 国产亚洲人成网站在线观看| 久久午夜影视| 一本高清dvd不卡在线观看| 欧美一乱一性一交一视频| 怡红院精品视频| 欧美屁股在线| 欧美在线视频日韩| 亚洲精品中文字幕在线| 久久国产黑丝| 日韩视频免费看| 国产亚洲综合性久久久影院| 欧美精品亚洲二区| 欧美伊人久久大香线蕉综合69| 亚洲福利小视频| 久久成人亚洲| 在线一区二区三区四区| 韩国一区电影| 欧美无乱码久久久免费午夜一区| 久久精品国产成人| 日韩一区二区免费看| 亚洲欧洲免费视频| 国产精品久久一区二区三区| 另类av一区二区| 性欧美8khd高清极品| 亚洲精品1区| 免费观看成人| 久久精品国产免费观看| 在线视频日韩精品| 国内久久精品| 国产视频精品网| 亚洲欧美另类久久久精品2019| 欧美激情二区三区| 久久久久天天天天| 欧美一级久久久| 正在播放欧美一区| 亚洲老板91色精品久久| 狠狠狠色丁香婷婷综合激情| 国产欧美日韩免费看aⅴ视频| 欧美日韩福利视频| 欧美粗暴jizz性欧美20| 久久久久.com| 欧美中文字幕视频| 欧美一区二区三区视频在线观看| 亚洲无限乱码一二三四麻| 亚洲精品综合精品自拍| 亚洲国产精品久久| 亚洲二区精品| 亚洲高清久久网| 欧美高清在线视频| 亚洲二区在线| 亚洲人午夜精品免费| 亚洲第一久久影院| 亚洲福利久久| 亚洲黄网站黄| 日韩天堂av| 亚洲一二三区精品| 亚洲一本大道在线| 午夜伦理片一区| 欧美一级播放| 久久综合亚州| 欧美国产日韩二区| 欧美片第1页综合| 国产精品久久久久久久app| 欧美性开放视频| 国产精品一区二区久激情瑜伽| 久久久久久噜噜噜久久久精品| 久久九九国产精品怡红院| 美日韩在线观看| 欧美精品一区二区三区久久久竹菊| 欧美精品乱人伦久久久久久| 欧美日精品一区视频| 国产精品一区二区女厕厕| 国产一区二区精品丝袜| 亚洲国产乱码最新视频| 亚洲日本va午夜在线电影| 一区二区高清视频| 性做久久久久久免费观看欧美| 久久精品伊人| 亚洲黄色高清| 亚洲主播在线播放| 老司机成人在线视频| 欧美日韩在线一区二区三区| 国产欧美日韩三区| 黄色成人片子| 一本色道综合亚洲| 久久精品成人一区二区三区蜜臀| 欧美国产视频在线观看| 夜夜精品视频一区二区| 欧美一区二区三区视频免费播放| 女女同性女同一区二区三区91| 欧美视频在线一区| 在线视频成人| 欧美一区二区视频在线观看| 欧美激情视频在线免费观看 欧美视频免费一 | 在线日韩欧美| 午夜精品理论片| 亚洲高清在线精品| 午夜在线成人av| 欧美日韩一区二区精品| 黄色亚洲精品| 午夜免费在线观看精品视频| 欧美高清视频免费观看| 先锋影音国产精品| 欧美日韩人人澡狠狠躁视频| 伊人激情综合| 久久不射2019中文字幕| 99精品福利视频|