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

            場景查詢
            創建查詢的代價比較大,而執行不是。SceneQueryResualt只定義了兩種成員:movables與worldFragments.
            掩碼也需要自己定義,自己解釋。在一個軸對齊盒子中查詢燈光的例子如下:
            const unsigned int LIGHT_QUERY_MASK = 0x00000001; //掩碼定義
            Light* light1 = mSceneMgr->createLight("Light1");
            Light* light2 = mSceneMgr->createLight("Light2");
            light1->setPosition(12, 12, 12);
            light2->setPosition(5, 5, 5);
            light1->setQueryFlags(LIGHT_QUERY_MASK);
            light2->setQueryFlags(LIGHT_QUERY_MASK);
            AxisAlignedBoxSceneQuery* lightQuery =
            mSceneMgr->createAABBQuery(
            AxisAlignedBox(0, 0, 0, 10, 10, 10), LIGHT_QUERY_MASK);
            // sometime later in the application's code, find out what lights are in the box
            SceneQueryResult& results = lightQuery->execute(); //查詢
            // iterate through the list of items returned; there should only be one, and it
            // should be light2 created above. The list iterator is MovableObject type.
            SceneQueryResultMovableList::iterator it = results.movables.begin();
            for (; it != results.movables.end(); it++)
            {
            // act only on the lights, which should be all we have
            assert ((*it)->getQueryFlags() & LIGHT_QUERY_MASK) != 0);
            // do whatever it was we needed to do with the lights
            }
            // destroy the query when we are done with it
            mSceneMgr->destroyQuery(lightQuery);

            我們知道地形總是起伏不平的,當主角在上面行走時需要根據地形的高度調整,可以光線查詢來實現。
            原理比較簡單:向主角腳下執行光線查詢,與地形有一個交點,根據交點的高度調整主角位置。
            Terrain Clamping
            void Entity::clampToTerrain() {
            static Ogre::Ray updateRay;
            updateRay.setOrigin(m_controlledNode->getPosition() + Ogre::Vector3(0, 15, 0));
            updateRay.setDirection(Ogre::Vector3::NEGATIVE_UNIT_Y);
            m_raySceneQuery->setRay(updateRay);
            Ogre::RaySceneQueryResult& qryResult = m_raySceneQuery->execute();
            if (qryResult.size() == 0) {
            // then we are under the terrain and need to pop above it
            updateRay.setOrigin(m_controlledNode->getPosition());
            updateRay.setDirection(Ogre::Vector3::UNIT_Y);
            m_raySceneQuery->setRay(updateRay);
            }
            qryResult = m_raySceneQuery->execute();
            Ogre::RaySceneQueryResult::iterator i = qryResult.begin();
            if (i != qryResult.end() && i->worldFragment)
            {
            Ogre::SceneQuery::WorldFragment* wf = i->worldFragment;
            m_controlledNode->setPosition(m_controlledNode->getPosition().x,
            i->worldFragment->singleIntersection.y,
            m_controlledNode->getPosition().z);
            }
            }
            void Entity::init()
            {
            // lots of other irrelevant entity init stuff goes here
            m_raySceneQuery = sm->createRayQuery(
            Ogre::Ray(m_controlledNode->getPosition(),
            Ogre::Vector3::NEGATIVE_UNIT_Y));
            // move this node is such a way that it is above the terrain
            clampToTerrain();
            }

            posted on 2007-03-11 17:24 清源游民 閱讀(1160) 評論(0)  編輯 收藏 引用 所屬分類: OGRE
            <2007年3月>
            25262728123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            留言簿(35)

            隨筆分類(78)

            隨筆檔案(74)

            文章檔案(5)

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            99久久久精品免费观看国产 | 国产三级久久久精品麻豆三级| 无码国内精品久久综合88| 久久精品国产2020| 曰曰摸天天摸人人看久久久| 久久93精品国产91久久综合| 久久久久av无码免费网| 91精品婷婷国产综合久久| 久久人人青草97香蕉| 97久久精品无码一区二区天美 | 久久久久久久97| 久久国产精品成人免费| 日韩久久无码免费毛片软件| 久久精品蜜芽亚洲国产AV| 久久无码AV中文出轨人妻| 久久精品国产亚洲αv忘忧草| 久久美女人爽女人爽| 久久久久女教师免费一区| 久久久无码一区二区三区| 久久天天躁狠狠躁夜夜2020老熟妇 | 国产成人精品久久| 热re99久久精品国99热| 国产精品热久久毛片| 99久久国产热无码精品免费| 婷婷久久五月天| 久久精品成人一区二区三区| 精品久久人妻av中文字幕| 合区精品久久久中文字幕一区| 热久久这里只有精品| 久久精品国产影库免费看| 久久久精品人妻一区二区三区四| 国产精品中文久久久久久久| 性欧美大战久久久久久久| 欧美精品丝袜久久久中文字幕| 久久精品视屏| 久久久久国产一级毛片高清板| 色综合久久综精品| 国产成人精品久久亚洲高清不卡| 97久久精品无码一区二区 | 亚洲国产成人久久精品99| 久久久精品久久久久特色影视|