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

天行健 君子當自強而不息

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>
            一个人看的www久久| 欧美一区二区三区四区高清 | 国产午夜亚洲精品理论片色戒| 一本色道久久综合亚洲二区三区 | 亚洲欧美日韩在线播放| 亚洲私人影院| 国内成+人亚洲| 免费日韩成人| 欧美精品福利在线| 亚洲综合精品自拍| 欧美一区二区视频免费观看| 伊人精品在线| 国产精品99久久久久久www| 欧美视频在线观看| 欧美一级午夜免费电影| 久久精品人人做人人爽电影蜜月| 国产欧美一区二区精品性| 欧美一区在线直播| 久久男人资源视频| 亚洲日韩欧美视频一区| 一区二区三区.www| 精品999在线播放| 日韩午夜黄色| 狠狠色狠狠色综合日日五| 91久久久一线二线三线品牌| 欧美午夜在线观看| 免费观看国产成人| 国产精品国产三级国产普通话三级| 久久漫画官网| 国产精品国产三级国产aⅴ无密码 国产精品国产三级国产aⅴ入口 | 国产精品久久久久久久久动漫| 久久手机免费观看| 欧美性猛交xxxx乱大交退制版 | 99精品视频免费| 欧美中文在线观看国产| 亚洲一区二区少妇| 模特精品裸拍一区| 久久综合网络一区二区| 国产九九精品| 一本大道av伊人久久综合| 在线电影欧美日韩一区二区私密| 一本一本久久a久久精品牛牛影视| 狠狠做深爱婷婷久久综合一区| 一道本一区二区| 一区二区日韩| 欧美激情国产精品| 免费h精品视频在线播放| 国产美女诱惑一区二区| 中文国产成人精品| av成人福利| 欧美成人伊人久久综合网| 美女精品国产| 韩曰欧美视频免费观看| 欧美一区二区三区在线播放| 午夜精品久久一牛影视| 国产精品成人观看视频国产奇米| 亚洲国产激情| 99在线精品视频| 免费欧美视频| 欧美成人一区二区在线| 亚洲高清免费在线| 久久亚洲影院| 亚洲激情网站免费观看| 亚洲精品小视频在线观看| 裸体丰满少妇做受久久99精品| 久久婷婷综合激情| 狠狠色丁香久久综合频道 | 亚洲精品三级| 亚洲天堂免费在线观看视频| 欧美日韩视频在线一区二区| 99在线|亚洲一区二区| 亚洲天堂av在线免费| 欧美日韩精品一区二区| 日韩一级大片| 午夜亚洲性色福利视频| 国产人成精品一区二区三| 欧美与黑人午夜性猛交久久久| 久久精品视频在线观看| 在线日本成人| 欧美另类久久久品| 亚洲一区二区免费在线| 久久午夜国产精品| 亚洲片在线资源| 欧美久久视频| 午夜亚洲一区| 欧美黄色免费| 亚洲免费在线看| 韩国精品久久久999| 欧美激情视频网站| 亚洲免费在线视频| 欧美激情麻豆| 亚洲一线二线三线久久久| 国产午夜精品全部视频播放 | 亚洲精品在线免费| 午夜久久久久久| 在线观看一区视频| 欧美日韩国产在线一区| 欧美一区免费视频| 亚洲黄色在线视频| 久久国产色av| 日韩亚洲欧美成人| 国产一区二区三区四区| 欧美激情久久久| 欧美在线视频一区| 亚洲麻豆av| 欧美成人在线免费观看| 亚洲欧美视频在线| 亚洲精品在线一区二区| 国产欧美一区二区精品婷婷| 欧美日韩99| 久久久91精品| 亚洲在线日韩| 亚洲精品午夜| 欧美激情综合色| 欧美一区二区三区成人| 一本色道久久| 亚洲电影免费| 在线观看的日韩av| 国产精品一区在线观看你懂的| 麻豆av一区二区三区久久| 亚洲一区二区高清视频| 亚洲人成欧美中文字幕| 免费视频最近日韩| 久久久中精品2020中文| 午夜久久影院| 亚洲欧美怡红院| 亚洲小视频在线观看| 日韩午夜在线观看视频| 亚洲国产日本| 亚洲第一色在线| 激情久久五月天| 国产亚洲一区在线播放| 国产九九视频一区二区三区| 国产精品久久久久一区二区三区 | 亚洲欧美日韩精品久久久久| 99精品热视频| 亚洲精选久久| 亚洲精品综合在线| 亚洲人午夜精品| 亚洲国产精品久久久久| 欧美国产精品人人做人人爱| 久久资源av| 麻豆精品一区二区av白丝在线| 久久久久久色| 美女精品在线| 欧美成人免费全部观看天天性色| 久久全国免费视频| 老司机67194精品线观看| 久久综合五月| 亚洲国产一区二区精品专区| 亚洲第一主播视频| 亚洲欧洲精品一区| 99热这里只有精品8| 亚洲一级一区| 欧美一区二区三区视频免费| 久久精品道一区二区三区| 久久久午夜电影| 欧美成人激情在线| 欧美日韩亚洲视频一区| 国产精品推荐精品| 好吊视频一区二区三区四区| 91久久一区二区| 亚洲香蕉在线观看| 久久久综合视频| 亚洲激精日韩激精欧美精品| 这里是久久伊人| 久久久人成影片一区二区三区| 欧美极品一区| 国产精品一卡二卡| 亚洲国产成人tv| 亚洲综合国产激情另类一区| 久久精品夜色噜噜亚洲aⅴ| 欧美黑人国产人伦爽爽爽| 在线视频你懂得一区二区三区| 欧美一区二区三区四区在线 | 国产视频一区二区在线观看| 精品成人一区二区| 一区二区三区偷拍| 久久激五月天综合精品| 亚洲福利视频一区| 亚洲欧美日韩国产综合精品二区| 久久婷婷国产综合精品青草| 欧美日韩直播| 精品9999| 欧美一级理论片| 亚洲看片网站| 久久精品国产一区二区三 | 性久久久久久| 欧美日韩大片| 国产一区导航| 亚洲伊人伊色伊影伊综合网| 久久婷婷激情| 亚洲男同1069视频| 欧美日韩高清不卡| 黄色精品一二区| 亚洲一线二线三线久久久| 久久精品国产欧美亚洲人人爽| 日韩亚洲视频在线| 免费看成人av| 亚洲国产精品久久久久婷婷老年 |