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

天行健 君子當自強而不息

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>
            毛片av中文字幕一区二区| 亚洲综合不卡| 亚洲一区二区成人| 在线综合欧美| 国产日本欧美一区二区三区| 久久久亚洲高清| 欧美激情第1页| 性色av香蕉一区二区| 欧美在线视频一区二区| 亚洲国产精品久久| 亚洲综合色婷婷| 亚洲电影激情视频网站| 一区二区三区视频在线| 亚洲高清不卡一区| 亚洲在线视频免费观看| 最新中文字幕亚洲| 亚洲综合视频网| 亚洲美女电影在线| 欧美一区在线看| 亚洲尤物在线视频观看| 蜜桃伊人久久| 久久九九精品99国产精品| 欧美日韩国产小视频| 老**午夜毛片一区二区三区| 国产精品多人| 欧美激情性爽国产精品17p| 国产一区二区三区av电影 | 亚洲中字黄色| 亚洲人久久久| 久久精品女人天堂| 欧美一级成年大片在线观看| 欧美黑人在线播放| 蜜桃视频一区| 国产亚洲女人久久久久毛片| 在线亚洲成人| 亚洲天堂成人在线视频| 美日韩精品免费| 久久久亚洲高清| 国产精品视频免费一区| 亚洲美女免费精品视频在线观看| 在线观看欧美黄色| 久久精品国产精品亚洲| 亚洲自拍偷拍视频| 欧美三级电影大全| 9i看片成人免费高清| 一区二区三区不卡视频在线观看| 蜜桃久久精品一区二区| 美女精品一区| 亚洲国产cao| 久久久福利视频| 久久在线精品| 黄色成人在线网站| 久久久久久久网| 另类av导航| 亚洲国产成人av在线| 久久久久国产精品午夜一区| 久久久久久网址| 激情视频亚洲| 巨乳诱惑日韩免费av| 麻豆精品精华液| 亚洲国产精品成人一区二区 | 中国成人黄色视屏| 亚洲一区日韩| 亚洲视频在线免费观看| 亚洲午夜性刺激影院| 欧美日韩国产一级| 一区二区三区高清| 性久久久久久久久| 狠狠色狠色综合曰曰| 久久久久久久久久码影片| 裸体一区二区| 亚洲国产精品一区二区第一页| 女生裸体视频一区二区三区| 亚洲清纯自拍| 99精品黄色片免费大全| 国产精品国产自产拍高清av王其| 亚洲尤物在线视频观看| 久久人人爽人人爽爽久久| 精东粉嫩av免费一区二区三区| 久久在线精品| 亚洲高清视频一区| 午夜国产精品视频免费体验区| 国产欧美日韩免费| 久久综合电影| 一本色道久久综合狠狠躁篇怎么玩| 午夜视频在线观看一区| 国产一区二区三区免费不卡| 久久午夜视频| 99精品欧美一区二区三区| 亚洲欧美一区二区三区极速播放| 国产一级久久| 免费欧美网站| 亚洲欧美日韩国产中文| 欧美成人精品在线播放| 亚洲视频在线看| 伊人久久成人| 欧美午夜不卡| 久久综合色一综合色88| 亚洲视频axxx| 欧美激情片在线观看| 亚洲欧美清纯在线制服| 亚洲激情网站免费观看| 国产免费一区二区三区香蕉精| 欧美a一区二区| 欧美专区第一页| 这里只有精品电影| 亚洲激情二区| 久久五月天婷婷| 亚洲女同性videos| 亚洲精品乱码久久久久久按摩观| 国产欧美一区视频| 欧美视频福利| 欧美精品麻豆| 一区二区三区产品免费精品久久75| 国产欧美精品一区| 欧美日韩精品免费| 欧美成人精品福利| 久久精品2019中文字幕| 亚洲一区二区三区影院| 亚洲精品中文在线| 欧美大片一区二区三区| 久久大逼视频| 午夜精品久久久久久久99水蜜桃| 亚洲人成人一区二区在线观看| 国产欧美日韩一区二区三区在线观看| 欧美国产大片| 免费毛片一区二区三区久久久| 久久国产日本精品| 羞羞视频在线观看欧美| 亚洲图色在线| 在线视频欧美一区| 亚洲精品视频在线看| 欧美激情亚洲自拍| 欧美肥婆在线| 欧美成人亚洲成人| 欧美国产亚洲另类动漫| 欧美精品成人| 欧美成人伊人久久综合网| 亚洲视频中文字幕| 亚洲国产一区二区a毛片| 免费在线欧美视频| 欧美成人免费观看| 米奇777在线欧美播放| 久久噜噜亚洲综合| 久久综合电影| 麻豆精品视频在线| 久久中文字幕一区| 女同性一区二区三区人了人一| 美女国产精品| 欧美xart系列高清| 欧美成人中文字幕| 亚洲国产精品嫩草影院| 亚洲二区免费| 亚洲精品日韩在线观看| 99re视频这里只有精品| 国产精品99久久久久久久女警| 制服丝袜亚洲播放| 一区二区三区欧美| 午夜精品99久久免费| 欧美一级大片在线免费观看| 久久动漫亚洲| 美女精品在线观看| 欧美黑人国产人伦爽爽爽| 欧美日韩一区二区三区在线| 国产精品久久久久久久第一福利| 国产乱码精品一区二区三| 国模精品一区二区三区| 亚洲国产影院| 亚洲无限av看| 久久国产一区二区| 欧美激情第二页| 亚洲日本在线视频观看| 国产精品99久久久久久宅男 | 国产亚洲欧美在线| 在线精品亚洲一区二区| 亚洲日本电影| 欧美在线电影| 亚洲第一色中文字幕| 亚洲视频免费看| 久久国产精品72免费观看| 欧美www视频在线观看| 国产精品久久久久久妇女6080| 影音国产精品| 亚洲男人第一网站| 欧美国产精品专区| 亚洲一区二区3| 久久综合99re88久久爱| 欧美视频在线观看 亚洲欧| 国产综合av| 亚洲线精品一区二区三区八戒| 美乳少妇欧美精品| 亚洲一区二区精品在线| 久久综合久久久久88| 国产精品美女主播| 亚洲欧洲中文日韩久久av乱码| 销魂美女一区二区三区视频在线| 亚洲电影免费在线| 欧美一区二区三区男人的天堂| 欧美国产精品一区| 在线成人黄色|