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

天行健 君子當自強而不息

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>
            欧美一区二区三区在线| 老司机午夜精品视频| 国产精品成人久久久久| 一卡二卡3卡四卡高清精品视频| 亚洲国产成人一区| 欧美a级片网站| 在线亚洲精品福利网址导航| 夜夜嗨av色综合久久久综合网| 欧美视频网站| 欧美在线电影| 麻豆av一区二区三区久久| 亚洲精品视频免费观看| 一区电影在线观看| 国产三级欧美三级日产三级99| 久久亚洲国产精品日日av夜夜| 麻豆久久婷婷| 亚洲午夜精品| 久久国产精品黑丝| 亚洲日本一区二区三区| 日韩视频在线观看| 国产毛片一区二区| 欧美国产先锋| 国产伦精品一区二区| 嫩模写真一区二区三区三州| 欧美日韩国产美女| 久久久国产精品一区| 欧美高清视频一区二区| 欧美亚洲视频在线观看| 老色批av在线精品| 亚洲欧美中文在线视频| 欧美/亚洲一区| 新狼窝色av性久久久久久| 久久三级视频| 欧美一级免费视频| 欧美精品情趣视频| 久久久久国产精品厨房| 欧美视频你懂的| 免费久久精品视频| 国产精品午夜在线| 日韩视频专区| 伊人色综合久久天天| 亚洲一区二区三区免费观看| 亚洲精品欧美在线| 久久疯狂做爰流白浆xx| 亚洲综合色丁香婷婷六月图片| 美国十次了思思久久精品导航| 欧美亚洲一区二区在线观看| 欧美激情国产日韩精品一区18| 久久青草福利网站| 国产欧美视频一区二区| 99国产精品自拍| 亚洲精品乱码久久久久久按摩观| 午夜精品视频在线观看| 亚洲五月婷婷| 欧美日韩视频在线| 亚洲国产日韩欧美| 亚洲国产三级网| 久久综合给合久久狠狠色| 久久国产精品久久久久久| 国产精品久久久久久久久久妞妞| 亚洲精品乱码久久久久久| 亚洲人精品午夜| 免费成人av在线| 欧美成在线视频| 亚洲国产精品久久久久秋霞不卡| 久久久国产精品亚洲一区| 久久国产天堂福利天堂| 国产女优一区| 午夜宅男久久久| 欧美资源在线| 国产综合色精品一区二区三区| 午夜久久资源| 久久久在线视频| 精品成人一区二区三区| 久久久久久97三级| 欧美电影在线观看完整版| 亚洲国产片色| 欧美精品v日韩精品v国产精品| 亚洲欧洲日韩综合二区| 亚洲乱码国产乱码精品精可以看 | 欧美一区二区三区四区在线观看地址| 中文久久乱码一区二区| 国产精品国产三级欧美二区 | 欧美jizz19hd性欧美| 亚洲第一中文字幕在线观看| 欧美成人精品一区二区| 亚洲精品国产日韩| 亚洲尤物视频网| 国产一区二区视频在线观看 | 日韩午夜免费视频| 亚洲欧美日韩国产成人| 国产亚洲福利一区| 免费人成精品欧美精品| 日韩网站在线| 久久激情综合网| 最近看过的日韩成人| 欧美三级不卡| 久久成人资源| 亚洲毛片一区二区| 久久av一区二区三区| 亚洲大片免费看| 国产精品v一区二区三区 | 欧美不卡高清| 亚洲一区在线观看视频 | 欧美日韩亚洲国产精品| 亚洲欧美日韩成人高清在线一区| 欧美成人国产| 欧美一区二区在线播放| 亚洲黄色在线观看| 国产欧美日韩综合精品二区| 媚黑女一区二区| 亚洲欧美日韩精品久久奇米色影视| 毛片av中文字幕一区二区| 一区二区av在线| 一区在线免费| 国产精品久久久久久久午夜| 你懂的成人av| 欧美一区综合| 亚洲午夜视频在线| 亚洲狠狠丁香婷婷综合久久久| 欧美中文字幕在线播放| 中文在线资源观看网站视频免费不卡 | 影音先锋久久精品| 欧美日韩免费高清一区色橹橹| 国产精品99久久久久久白浆小说| 欧美国产激情二区三区| 久久久97精品| 午夜日韩福利| 亚洲男同1069视频| 99视频精品| 亚洲精品一区中文| 亚洲国产99| 好看不卡的中文字幕| 国产欧美日韩另类一区 | 欧美在线视频一区二区| 一个人看的www久久| 91久久黄色| 欧美黄色大片网站| 免播放器亚洲| 鲁鲁狠狠狠7777一区二区| 欧美在线观看视频在线| 香蕉成人久久| 午夜日韩激情| 亚洲欧美国产va在线影院| 亚洲一区二区伦理| 一区二区三区国产精品| 99在线精品免费视频九九视| 亚洲欧洲精品一区二区三区不卡 | 伊人久久婷婷色综合98网| 国内精品久久久久久 | 国产精品入口尤物| 国产精品久久久久久久久久ktv| 欧美日韩国产精品成人| 亚洲欧美日韩国产成人| 亚洲一区在线观看视频 | 亚洲第一在线综合在线| 在线观看三级视频欧美| 亚洲国产高清一区| 亚洲激情六月丁香| 日韩亚洲欧美精品| 一区二区三区精品视频在线观看| 一区二区冒白浆视频| 亚洲在线成人精品| 欧美在线精品免播放器视频| 久久久爽爽爽美女图片| 欧美a级大片| 日韩一二在线观看| 亚洲一区二区三区中文字幕在线 | 久久免费视频网站| 欧美.www| 国产精品久久久久久久久久免费 | 国产亚洲一区在线| 影音先锋亚洲视频| 99亚洲视频| 欧美一区二区三区精品| 欧美.www| 亚洲色图自拍| 久久裸体艺术| 欧美午夜精品电影| 极品av少妇一区二区| 99成人精品| 久久人人爽人人爽爽久久| 亚洲国产mv| 午夜精品一区二区在线观看| 美女视频黄a大片欧美| 国产精品久久久久aaaa九色| 亚洲高清三级视频| 午夜日韩激情| 亚洲清纯自拍| 久久9热精品视频| 欧美日韩精品一区二区天天拍小说| 国产亚洲精品aa午夜观看| 99精品欧美一区| 久久综合久久88| 中文国产亚洲喷潮| 欧美成人亚洲成人日韩成人| 国产日产欧产精品推荐色| 亚洲天堂av在线免费| 欧美激情精品久久久久久免费印度| 亚洲中字在线|