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

天行健 君子當自強而不息

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 閱讀(274) 評論(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>
            午夜精彩视频在线观看不卡 | 亚洲黄色高清| 久久视频精品在线| 欧美制服第一页| 国产主播一区| 欧美成人乱码一区二区三区| 久久一区二区视频| 亚洲精品你懂的| 亚洲色图自拍| 国产亚洲毛片在线| 欧美国产日韩二区| 欧美国产视频一区二区| 亚洲一区二区在线观看视频| 午夜久久福利| 在线播放亚洲一区| 亚洲伦理在线| 国产一区二区日韩精品| 你懂的国产精品| 欧美日韩免费视频| 久久精品亚洲一区二区| 女人天堂亚洲aⅴ在线观看| 中文在线一区| 久久亚洲精品网站| 在线视频欧美日韩精品| 欧美一级网站| 亚洲乱码视频| 欧美一级午夜免费电影| 亚洲黑丝在线| 西西人体一区二区| 亚洲精品国产日韩| 午夜性色一区二区三区免费视频| 亚洲第一二三四五区| 日韩一本二本av| 在线免费观看日韩欧美| 宅男精品视频| 亚洲日本电影在线| 久久国产精品久久国产精品| 一级成人国产| 久久这里有精品15一区二区三区| 亚洲无亚洲人成网站77777| 久久精品亚洲一区二区三区浴池 | 国产精品美女诱惑| 亚洲第一在线综合网站| 国产日产欧产精品推荐色 | 欧美日韩视频在线一区二区观看视频 | 浪潮色综合久久天堂| 亚洲网站在线看| 欧美成人亚洲| 久久综合色一综合色88| 欧美天堂在线观看| 亚洲区一区二| 亚洲精品乱码久久久久久| 久久久精品国产免费观看同学| 午夜激情久久久| 欧美日韩精品免费观看视一区二区| 蘑菇福利视频一区播放| 国产一区二区黄色| 亚洲欧美精品一区| 性欧美video另类hd性玩具| 欧美日韩大片| 亚洲精品欧美日韩| 亚洲美女视频网| 欧美bbbxxxxx| 亚洲区中文字幕| 一本色道久久综合精品竹菊| 欧美成人在线网站| 亚洲国产高清高潮精品美女| 亚洲第一黄色| 欧美成人tv| 亚洲人成毛片在线播放女女| 日韩视频在线播放| 欧美国产精品v| 亚洲精品一区二区三区在线观看| 亚洲欧洲另类国产综合| 欧美国产三级| 99re6这里只有精品| 一区二区三区四区国产| 欧美视频中文字幕| 亚洲免费影视| 久久一区亚洲| 亚洲茄子视频| 欧美日韩123| 亚洲在线免费观看| 久久亚洲精品视频| 亚洲国产小视频在线观看| 欧美福利小视频| 亚洲视频在线二区| 久久精品国产999大香线蕉| 黄色成人精品网站| 久久天堂av综合合色| 亚洲国产精品电影| 亚洲一区二区三区精品在线| 国产精品欧美日韩一区二区| 久久成人国产精品| 亚洲国产成人午夜在线一区| 这里只有精品在线播放| 国产精品一区二区男女羞羞无遮挡| 亚洲欧美中文日韩v在线观看| 久久亚洲一区二区| 夜夜嗨av一区二区三区| 国产欧美视频一区二区| 久久精品一区二区三区不卡牛牛| 亚洲成色777777女色窝| 久久中文欧美| 99精品欧美一区二区三区| 欧美在线观看www| 亚洲成色最大综合在线| 欧美性理论片在线观看片免费| 欧美在线亚洲一区| 亚洲欧洲在线视频| 久久久国产成人精品| 一区二区三区高清| 国产一区二区三区无遮挡| 欧美日韩国产成人| 久久久久久尹人网香蕉| 亚洲视频福利| 亚洲国产成人久久综合一区| 欧美专区18| 亚洲一区二区三区中文字幕在线| 黄色日韩精品| 国产精品在线看| 欧美日韩伦理在线| 久久字幕精品一区| 亚洲欧洲99久久| 夜夜精品视频| 亚洲精品免费电影| 欧美大片91| 久久久久国产精品www| 亚洲综合视频一区| 亚洲卡通欧美制服中文| 黄色一区二区在线观看| 国产精品亚洲综合一区在线观看 | 亚洲永久字幕| 亚洲精品一区二区三区在线观看| 美女国产一区| 免费欧美网站| 久久久久成人精品| 久久se精品一区二区| 亚洲伊人网站| 亚洲伊人第一页| 亚洲一区二区三区高清不卡| 亚洲伦理中文字幕| 亚洲三级观看| 亚洲另类春色国产| 日韩视频一区二区在线观看| 最新日韩欧美| 一本久道久久综合婷婷鲸鱼| 亚洲美女精品久久| 亚洲精品视频在线观看免费| 亚洲乱码日产精品bd| 日韩视频不卡中文| 一区二区三区四区蜜桃| 一本色道久久99精品综合| 夜夜嗨av色综合久久久综合网| 99精品欧美一区二区三区| 一区二区精品| 亚洲欧美日韩国产精品| 久久成人18免费观看| 久久久久久国产精品mv| 免费在线观看日韩欧美| 亚洲大胆在线| 日韩网站在线观看| 亚洲视频在线一区| 欧美一区=区| 久久中文欧美| 欧美日韩精品综合在线| 国产精品嫩草久久久久| 国产一区二区中文字幕免费看| 在线成人av| 一区二区欧美国产| 亚洲欧美一区二区三区极速播放| 欧美一区免费视频| 久久亚洲视频| 亚洲乱码国产乱码精品精天堂| 亚洲性图久久| 久久久久国产一区二区| 欧美激情aⅴ一区二区三区| 欧美色123| 黄色综合网站| 中文精品视频| 男女激情久久| 亚洲深夜福利网站| 久久免费视频这里只有精品| 欧美极品在线观看| 国产日本欧美视频| 亚洲精品三级| 久久久久久久尹人综合网亚洲| 欧美大片专区| 亚洲欧美成人| 欧美日韩国产在线看| 国产一区日韩二区欧美三区| 99伊人成综合| 免费观看日韩| 欧美一区中文字幕| 国产精品福利在线观看网址| 亚洲国产精品成人综合| 久久精品99久久香蕉国产色戒| 亚洲片在线资源| 久久综合伊人77777蜜臀| 国产精品一香蕉国产线看观看 |