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

天行健 君子當自強而不息

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>
            国产精品videossex久久发布| 亚洲精品欧美精品| 亚洲一区二区视频在线| 国产精品啊啊啊| 亚洲欧美日韩国产中文在线| 亚洲小视频在线| 国产一区二区你懂的| 久久尤物视频| 欧美精品国产一区二区| 欧美在线视频全部完| 国内一区二区三区在线视频| 欧美国产免费| 欧美日韩国产影院| 久久精品国产91精品亚洲| 久久精品国产综合| 99riav1国产精品视频| 亚洲一区二区在线播放| 在线观看成人av电影| 亚洲欧洲日夜超级视频| 国产精品男人爽免费视频1| 久久久另类综合| 欧美连裤袜在线视频| 久久av资源网| 欧美黑人一区二区三区| 欧美中文字幕在线| 欧美精品在线网站| 久久伊人亚洲| 欧美午夜在线视频| 欧美刺激午夜性久久久久久久| 欧美日韩午夜剧场| 蜜臀av在线播放一区二区三区| 欧美日韩美女| 欧美高清在线播放| 国产偷久久久精品专区| 亚洲精华国产欧美| 极品少妇一区二区| 亚洲综合首页| 中日韩美女免费视频网址在线观看| 欧美伊人久久久久久久久影院 | 久久gogo国模裸体人体| 亚洲社区在线观看| 欧美激情成人在线| 欧美激情国产日韩精品一区18| 国产免费成人| 亚洲性感美女99在线| 夜夜嗨av一区二区三区四区| 裸体一区二区三区| 久久夜色精品亚洲噜噜国产mv| 国产精品美女一区二区在线观看| 亚洲人久久久| 99re6这里只有精品| 久久综合色婷婷| 久久在线免费| 狠狠做深爱婷婷久久综合一区| 亚洲伊人久久综合| 午夜精品福利视频| 国产精品久久久久久久久借妻| 亚洲国产欧美一区二区三区久久| 亚洲国产成人一区| 久久香蕉精品| 欧美黄在线观看| 亚洲人成在线观看| 欧美大片在线观看一区| 亚洲国产专区校园欧美| 亚洲精品国精品久久99热| 久久综合五月| 91久久久久久久久久久久久| 亚洲欧洲日产国产综合网| 免费观看国产成人| 亚洲欧洲三级| 亚洲婷婷免费| 国产亚洲aⅴaaaaaa毛片| 欧美一区二区三区精品电影| 久久精品观看| 尤物在线精品| 欧美大片免费久久精品三p | 91久久精品国产91性色| 欧美成人久久| 日韩亚洲视频在线| 欧美制服丝袜| 永久555www成人免费| 免费欧美网站| 亚洲精品专区| 久久久久久久一区二区| 国产午夜精品久久久| 久久久噜噜噜久噜久久| 亚洲激情网站| 亚洲欧美日韩区| 在线 亚洲欧美在线综合一区| 欧美大尺度在线| 亚洲天堂av图片| 久久九九免费| 99热免费精品| 国产伊人精品| 欧美日韩在线播放一区二区| 亚洲欧美日韩另类| 欧美高清在线精品一区| 亚洲欧美日韩精品在线| 亚洲国产美国国产综合一区二区 | 亚洲永久精品国产| 欧美成人午夜影院| 午夜精品视频在线观看| 亚洲欧洲精品一区二区三区不卡| 国产精品人人做人人爽| 免费短视频成人日韩| 亚洲欧美乱综合| 亚洲精品在线免费| 榴莲视频成人在线观看| 亚洲尤物精选| 亚洲精品五月天| 国内伊人久久久久久网站视频| 欧美日韩国内| 欧美fxxxxxx另类| 欧美一二区视频| 在线一区日本视频| 亚洲人成网站在线观看播放| 久久高清福利视频| 亚洲欧美电影在线观看| 亚洲精品一区二区在线观看| 国内一区二区三区| 国产麻豆91精品| 欧美日韩国产精品一区| 欧美1区2区| 久久在线精品| 久久琪琪电影院| 久久精品国产亚洲高清剧情介绍| 亚洲一区二区三区影院| 99国产精品99久久久久久| 亚洲福利视频三区| 欧美二区在线播放| 久久色中文字幕| 久久久久青草大香线综合精品| 亚洲综合精品一区二区| 亚洲视频在线观看免费| 一区二区国产日产| 一二三区精品| 亚洲深夜福利在线| 亚洲视频第一页| 亚洲无线视频| 久久久久亚洲综合| 欧美在线播放高清精品| 久久9热精品视频| 久久成人18免费网站| 久久成人国产精品| 久久精品2019中文字幕| 久久久久久9| 久久伊人一区二区| 免费在线一区二区| 欧美精品日韩| 欧美日韩在线视频一区二区| 欧美色欧美亚洲高清在线视频| 欧美三区在线观看| 国产精品一区二区久久精品| 国产精品日本欧美一区二区三区| 国产精品视频久久一区| 国产午夜精品一区二区三区欧美| 国产综合av| 91久久精品一区二区别| 夜夜嗨av色综合久久久综合网 | 伊人蜜桃色噜噜激情综合| **欧美日韩vr在线| 99re国产精品| 亚洲免费人成在线视频观看| 欧美综合国产| 欧美激情片在线观看| 9l国产精品久久久久麻豆| 亚洲在线中文字幕| 久久美女性网| 欧美视频一区二区三区四区| 国产欧美日韩三级| 亚洲国产影院| 亚洲女人天堂av| 玖玖国产精品视频| 亚洲免费观看| 欧美影视一区| 欧美日韩精品一本二本三本| 国产欧美亚洲一区| 亚洲肉体裸体xxxx137| 亚洲中午字幕| 亚洲大胆女人| 亚洲一区美女视频在线观看免费| 亚洲欧美国内爽妇网| 欧美v亚洲v综合ⅴ国产v| 国产精品美女黄网| 亚洲精品视频在线| 久久精品亚洲一区二区| 亚洲国产成人av| 久久国产手机看片| 欧美肉体xxxx裸体137大胆| 黄色亚洲在线| 午夜在线视频一区二区区别| 欧美福利一区二区| 欧美在线一二三四区| 欧美日韩在线一二三| 亚洲国产一区视频| 久久久蜜桃一区二区人| 亚洲视频在线观看视频| 欧美精品v日韩精品v韩国精品v| 海角社区69精品视频| 性色av一区二区三区在线观看|