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

天行健 君子當自強而不息

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>
            99re国产精品| 久久成人一区二区| 欧美二区乱c少妇| 老司机精品视频网站| 久久久国产视频91| 久久野战av| 久久久综合免费视频| 久久亚洲精品伦理| 六十路精品视频| 欧美色网在线| 国产一区清纯| 亚洲蜜桃精久久久久久久| 亚洲理论电影网| 亚洲一区二区三区成人在线视频精品| 亚洲一区制服诱惑| 久久精品视频亚洲| 久久激情五月激情| 午夜精品视频在线| 亚洲高清在线精品| 99视频精品在线| 久久成人国产精品| 亚洲国产精品va在看黑人| 欧美激情国产高清| 亚洲一区亚洲| 欧美高清视频一区二区三区在线观看 | 久久国产加勒比精品无码| 蜜臀久久99精品久久久画质超高清| 欧美日韩国产影片| 国产一区二区高清不卡| 亚洲精选一区| 久久久噜噜噜久久| 日韩亚洲国产欧美| 久久久亚洲午夜电影| 国产精品久久午夜| 亚洲国产高潮在线观看| 欧美一区综合| 99精品国产在热久久婷婷| 久久精品在线播放| 国产精品乱人伦一区二区| 日韩视频免费在线观看| 蜜臀99久久精品久久久久久软件| 亚洲制服少妇| 国产精品久久7| 99国产精品国产精品毛片| 欧美凹凸一区二区三区视频| 欧美在线你懂的| 欧美视频在线一区| 在线一区二区三区四区| 亚洲东热激情| 免费成人网www| 亚洲成在人线av| 美女视频一区免费观看| 久久精品免费电影| 国产一区二区三区的电影| 欧美亚洲在线视频| 亚洲欧美日韩精品久久亚洲区| 国产精品成人久久久久| 在线性视频日韩欧美| 亚洲精品一区在线| 欧美日韩免费高清一区色橹橹| 日韩视频欧美视频| 亚洲美女色禁图| 欧美性片在线观看| 亚洲午夜av在线| 艳妇臀荡乳欲伦亚洲一区| 欧美手机在线| 午夜精品偷拍| 久久www成人_看片免费不卡| 黄网动漫久久久| 蜜桃久久av一区| 欧美精品97| 亚洲欧美一区二区原创| 亚洲女与黑人做爰| 欧美一级专区免费大片| 在线中文字幕日韩| 欧美视频在线免费看| 欧美一级一区| 久久久久国产精品一区二区| 91久久精品美女| 一区二区三区高清| 国产欧美日韩亚州综合| 久久香蕉国产线看观看网| 久久国产天堂福利天堂| 亚洲日本在线视频观看| 99国产精品一区| 国产精一区二区三区| 久久久久久久波多野高潮日日| 久久五月婷婷丁香社区| 99在线|亚洲一区二区| 亚洲一区二区成人| 在线国产日韩| avtt综合网| 亚洲国产色一区| 亚洲欧美日韩在线一区| 亚洲国产一区二区三区高清| 99在线|亚洲一区二区| 精品粉嫩aⅴ一区二区三区四区| 99国产精品视频免费观看一公开| 狠狠色伊人亚洲综合成人| 亚洲美女在线视频| 国产一区二区三区视频在线观看| 欧美激情在线有限公司| 国产精品视频xxx| 亚洲国产日韩在线| 国产亚洲a∨片在线观看| 亚洲精品日韩激情在线电影| 在线观看免费视频综合| 亚洲视频在线二区| 亚洲黄色天堂| 久久精品国产亚洲精品| 亚洲在线免费视频| 狂野欧美一区| 久久精品一二三区| 国产精品久久久一区二区| 欧美激情性爽国产精品17p| 国产日韩欧美三区| 这里只有精品在线播放| 一区二区三区视频免费在线观看| 久久九九免费| 久久精品首页| 国产农村妇女精品一区二区| 一区二区三区国产精品| 日韩午夜av| 蜜臀av性久久久久蜜臀aⅴ| 久久频这里精品99香蕉| 国产欧美一区二区精品性色| 亚洲综合色网站| 午夜日韩在线观看| 欧美肉体xxxx裸体137大胆| 91久久久久久久久久久久久| 最近中文字幕日韩精品| 理论片一区二区在线| 欧美大片一区| 亚洲精品在线一区二区| 另类天堂av| 亚洲精品123区| 在线视频日韩精品| 欧美三级视频在线| 一区二区三区高清在线观看| 久久成人人人人精品欧| 欧美国产先锋| 黄色成人91| 久久精品视频在线看| 久久av一区二区| 国内精品久久久久影院色| 欧美在线不卡视频| 麻豆精品在线视频| 亚洲免费成人av| 欧美日韩在线电影| 亚洲天堂男人| 久久免费视频网站| 亚洲国产精品电影在线观看| 欧美h视频在线| 亚洲国产99| 亚洲在线1234| 樱花yy私人影院亚洲| 欧美成人一区在线| 中文在线一区| 久久久夜色精品亚洲| 亚洲欧洲精品成人久久奇米网| 欧美激情一区二区久久久| 一区二区三区毛片| 六月丁香综合| 亚洲午夜激情免费视频| 国产婷婷色一区二区三区| 久久久久久婷| 亚洲精品视频在线观看免费| 欧美在线观看视频一区二区| 在线观看欧美日韩| 欧美视频免费看| 久久婷婷国产综合国色天香| 亚洲人精品午夜在线观看| 亚洲欧美日韩精品在线| 亚洲成色最大综合在线| 国产精品国内视频| 久久人人爽爽爽人久久久| 99国产精品久久久久久久久久| 久久久久一区二区| 一本一本久久| 精品999在线播放| 国产精品久久久久久久午夜| 鲁大师影院一区二区三区| 午夜精品影院| 日韩香蕉视频| 欧美黄色aaaa| 久久九九国产| 午夜视频在线观看一区| 日韩视频中文字幕| 国内精品久久国产| 国产精品视频第一区| 欧美另类高清视频在线| 欧美一区二区三区喷汁尤物| 亚洲六月丁香色婷婷综合久久| 久久综合久久美利坚合众国| 亚洲欧美综合v| 中文在线一区| 日韩亚洲欧美成人一区| 亚洲电影在线免费观看| 国产尤物精品| 国产视频精品va久久久久久|