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

天行健 君子當自強而不息

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>
            久久久久久尹人网香蕉| 久久精品午夜| 欧美色网在线| 亚洲一区二区综合| 亚洲一区二区免费视频| 国产精品午夜av在线| 欧美在线不卡| 久久精品视频免费| 最新成人av网站| 亚洲伦理精品| 国产婷婷精品| 欧美肥婆bbw| 欧美日韩国产一区二区三区地区| 正在播放亚洲一区| 午夜精品久久久久久久白皮肤| 国产日本欧美一区二区三区在线| 久久久久久久综合色一本| 久久美女艺术照精彩视频福利播放| 精品成人久久| 亚洲美女黄网| 国产在线视频欧美一区二区三区| 久久天堂精品| 欧美日韩网址| 美女主播一区| 国产精品久久久久毛片软件| 久久久之久亚州精品露出| 欧美高清视频免费观看| 性欧美精品高清| 免费av成人在线| 午夜精品一区二区三区在线| 久久色在线观看| 亚洲男人影院| 欧美大色视频| 久久伊人精品天天| 国产精品久久久一本精品| 久久先锋资源| 国产欧美欧美| 99www免费人成精品| 一色屋精品视频在线看| 亚洲一区二区久久| 99国产精品久久久久久久久久| 欧美一级理论性理论a| 亚洲色诱最新| 欧美成人免费全部| 麻豆国产精品va在线观看不卡| 欧美午夜视频| 亚洲美女黄网| 亚洲免费高清| 免费看的黄色欧美网站| 久久婷婷人人澡人人喊人人爽| 欧美体内she精视频| 亚洲日本精品国产第一区| 极品av少妇一区二区| 午夜在线一区二区| 亚欧成人精品| 国产伦精品一区二区三区在线观看 | 亚洲欧美激情四射在线日 | 国产一区二区无遮挡| 一本色道久久综合一区| 亚洲精品专区| 欧美黑人在线观看| 亚洲第一搞黄网站| 亚洲国产欧美日韩| 免费一级欧美在线大片| 欧美成人午夜激情视频| 在线观看欧美日韩| 久久综合一区二区| 欧美国产精品| 亚洲三级影院| 欧美欧美全黄| 一本综合久久| 欧美在线综合| 国产一区二区日韩精品欧美精品 | 亚洲国产裸拍裸体视频在线观看乱了中文 | 亚洲天堂免费在线观看视频| 欧美日韩国产免费观看| 日韩性生活视频| 午夜精品国产更新| 国产在线欧美| 老牛国产精品一区的观看方式| 欧美成人国产一区二区| 最近看过的日韩成人| 欧美日韩国产三区| 亚洲午夜黄色| 久久久爽爽爽美女图片| **性色生活片久久毛片| 欧美黑人一区二区三区| 一区二区三区四区五区视频| 香蕉久久夜色精品国产使用方法| 国产亚洲欧美一区| 欧美a级片一区| 一区二区三区欧美日韩| 欧美在线观看你懂的| 伊人伊人伊人久久| 欧美精品一区二区三区蜜桃| 亚洲小说春色综合另类电影| 久久字幕精品一区| 一本久道综合久久精品| 国产伦精品一区二区三区免费| 久久久久久自在自线| 99精品国产高清一区二区| 久久精品青青大伊人av| 最新亚洲激情| 国产美女精品免费电影| 欧美99久久| 校园激情久久| 亚洲毛片av在线| 美女999久久久精品视频| 亚洲伊人一本大道中文字幕| 在线观看日韩av电影| 国产精品xnxxcom| 美国十次了思思久久精品导航| 一区二区三区免费观看| 欧美黄色日本| 久久精品99国产精品| 日韩一区二区精品视频| 在线免费观看欧美| 国产毛片一区二区| 欧美日韩国产综合视频在线观看| 久久成人免费| 亚洲综合精品自拍| 亚洲精品久久久久| 免费不卡亚洲欧美| 欧美一级片一区| 亚洲视频1区2区| 亚洲日韩欧美视频| 在线观看中文字幕不卡| 国产情人综合久久777777| 欧美午夜精品电影| 欧美激情一区二区三区| 麻豆av福利av久久av| 久久精品久久综合| 性欧美video另类hd性玩具| 国产精品99久久久久久白浆小说| 亚洲国产精品999| 欧美高清免费| 欧美承认网站| 欧美高清视频一区二区| 你懂的视频欧美| 免费观看在线综合色| 美女国产一区| 美女脱光内衣内裤视频久久影院 | 欧美大秀在线观看| 免费成人高清在线视频| 久久视频这里只有精品| 久久精品成人一区二区三区蜜臀| 午夜在线视频一区二区区别| 欧美亚洲综合在线| 欧美亚洲视频在线看网址| 欧美在线999| 久久精品欧美| 女生裸体视频一区二区三区| 女人色偷偷aa久久天堂| 亚洲风情亚aⅴ在线发布| 91久久国产综合久久| 亚洲精品视频在线观看免费| 亚洲精品国精品久久99热| 一本色道久久88综合亚洲精品ⅰ| 日韩视频精品在线| 午夜精品亚洲一区二区三区嫩草| 亚欧成人在线| 免费成人性网站| 欧美日韩国产系列| 国产精品日韩欧美一区二区三区| 国产美女精品人人做人人爽| 黑人巨大精品欧美一区二区| 亚洲黄色成人久久久| 亚洲小视频在线观看| 欧美一区二区三区在线免费观看 | 亚洲激情影视| 中文日韩在线视频| 久久激情中文| 欧美激情片在线观看| 亚洲精品小视频在线观看| 在线视频中文亚洲| 久久精彩免费视频| 欧美激情一区二区三级高清视频| 欧美视频中文一区二区三区在线观看 | 亚洲激情偷拍| 亚洲一区在线免费观看| 久久久国产精品一区二区三区| 欧美高清视频在线观看| 国产精品亚洲аv天堂网| 亚洲高清免费视频| 亚洲一区精品在线| 欧美h视频在线| 亚洲午夜视频在线观看| 女主播福利一区| 国产女人aaa级久久久级| 亚洲三级免费电影| 久久久精品动漫| 一本久久精品一区二区| 久久久之久亚州精品露出| 国产精品多人| 亚洲欧洲视频在线| 久久精品国产第一区二区三区最新章节 | 一区二区三区高清不卡| 美女日韩在线中文字幕| 亚洲午夜视频在线| 欧美激情亚洲视频|