• <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>

            天行健 君子當(dāng)自強(qiáng)而不息

            Working with Maps and Levels(11)

            Adding Barriers with cBarrier

            Even though the barrier class marks areas on the map using geometric shapes in
            exactly the same way as the trigger class does, the barrier class also positions meshes.
            Looking again at the cBarrier class declaration, notice that each of the add barrier
            functions — add_sphere, add_box, add_cylinder, and add_triangle—have a set of coordinates
            that position and rotate the barrier’s mesh before being rendered.

            To determine where the mesh is positioned, set the x_pos, y_pos, and z_pos arguments
            of the add barrier functions to where you want the mesh rendered. You also need
            to set the x_rot, y_rot, and z_rot arguments to the rotational values to draw the mesh.

            For example, say that you want to add a spherical barrier that already has a mesh
            assigned. The barrier is positioned at coordinates 10,20,30 (with a radius of 40),
            while the mesh is positioned at 10,0,30 using no rotational values. To add the barrier,
            you call the add_sphere function as follows:

            cBarrier::add_sphere(1, TRUE,
                                 10.0f, 0.0f, 30.0f, 0.0f, 0.0f, 0.0f,
                                 10.0f, 20.0f, 30.0f, 40.0f);

            You get a better understanding of adding and using barriers in the next section.

             

            Using the Barrier Class

            Using the barrier class is not difficult; it’s much like using the trigger class. The
            biggest difference is that you have to add object placement data to the barrier data
            files and assign the appropriate meshes and animations.

             

            Creating the Barrier Data File

            The barrier data files are arranged just like trigger data files, except that you start
            each barrier definition with the identification number, type, enabled flag, placement
            coordinates (X, Y, Z), and rotations (X-rotation, Y-rotation, and Z-rotation) to
            place the barrier graphics object. Finish each definition with the respective barrier
            type’s data.

            The following defines two barriers to use (contained in a file called test.bar). Note
            that the coordinates and rotational values of the barrier are shown in bold:

            1 1 1 -900 0 0 0 0 0 -1154 0 10 -645 100 -10
            2 1 0 0 0 -900 0 1.57 0 -10 0 -1154 10 100 -645

            Here are two barriers, both using a box shape. The first barrier’s graphics object is
            placed at -900,0,0 and has rotational values of 0,0,0. The first box covers the area
            from -1154,0,10 to -645,100, -10.

            The second barrier has a graphics object placed at 0,0, -900 and has rotational values
            of 0,1.57,0. The second barrier covers the area from -10,0,-1154 to 10,100,-645.

             

            Loading the Barrier Data

            In order to load and use a barrier data file, instance the cBarrier class, load the data
            file and appropriate meshes, and assign the meshes:

            cBarrier Barrier;

            // Load a barrier data file
            Barrier.Load(“test.bar”);

            // Load a mesh and animation to use
            cMesh Mesh;
            cAnimation Anim;
            Mesh.Load(“barrier.x”);
            Anim.Load(“barrier.x”, &Mesh);

            // Assign mesh and animation to both barriers loaded
            Barrier.SetMesh(1, &Mesh);
            Barrier.SetMesh(2, &Mesh);
            Barrier.SetAnim(1, &Anim, “AnimationName”, 0);
            Barrier.SetAnim(2, &Anim, “AnimationName”, 0);

             

            Checking Barrier Collisions

            To see whether an area on the map is blocked, call get_barrier with the character
            coordinates. If a value of TRUE is returned, passage is blocked, and you should take
            appropriate actions. Take the following example that checks a character’s coordinates
            against all barriers loaded from the barrier list.

            You use a trio of values that represents the direction the character is moving in
            each axis to determine beforehand whether the movement is blocked by a barrier.
            Say that a character is moving 10 units in the position Z-axis, meaning that the
            upcoming ZMove variable will be set to 10. That ZMove variable is added to the character’s
            current position, and if intersecting with a barrier, that ZMove variable is cleared
            out, thus not allowing such a movement along the axis, as shown here:

            // XPos, YPos, ZPos = character coordinates
            // XMove, YMove, ZMove = character movement values
            if(Barrier.get_barrier(XPos+XMove,YPos+YMove,ZPos+ZMove)) {
              // Passage not allowed, clear movement variables
              XMove = YMove = ZMove = 0.0f;
            }

             

            Rendering Barriers

            Last, you only need to call cBarrier::Render to draw all barrier objects within view:

            // Frustum = pre-initialize cFrustum object
            Barrier.render(timeGetTime(), &Frustum);

            posted on 2007-12-10 14:50 lovedday 閱讀(190) 評(píng)論(0)  編輯 收藏 引用

            公告

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            隨筆分類(178)

            3D游戲編程相關(guān)鏈接

            搜索

            最新評(píng)論

            国产亚洲精品美女久久久| 久久WWW免费人成—看片| 国产亚洲欧美精品久久久| 亚洲欧洲久久久精品| 一97日本道伊人久久综合影院| 老司机国内精品久久久久| 久久精品国产亚洲精品2020 | 久久99九九国产免费看小说| 久久久久久久久久免免费精品 | 久久精品国产一区| 国产精品久久免费| 亚洲嫩草影院久久精品| 99久久国产亚洲高清观看2024| 人妻中文久久久久| 色偷偷88欧美精品久久久| 国产精品久久久久免费a∨| 久久亚洲sm情趣捆绑调教| 久久无码AV中文出轨人妻| 久久精品99久久香蕉国产色戒| 久久精品18| 久久婷婷国产剧情内射白浆 | 亚洲级αV无码毛片久久精品| 国产精品久久午夜夜伦鲁鲁| 久久久精品2019免费观看| 久久亚洲高清观看| 欧美日韩中文字幕久久久不卡| 久久久久久夜精品精品免费啦| 久久夜色tv网站| 久久久久久午夜精品| 久久大香香蕉国产| 欧美久久一级内射wwwwww.| 精品久久人人爽天天玩人人妻| 国产亚洲精久久久久久无码AV| 亚洲国产美女精品久久久久∴| 国产精品成人久久久久三级午夜电影| 久久精品国产男包| 久久免费视频网站| 久久无码国产专区精品| 久久99精品免费一区二区| 99久久精品免费看国产一区二区三区| 狠狠久久综合伊人不卡|