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

            的筆記

            隨時隨地編輯

            Ogre Moc筆記

            MOC的資料不多,目前僅限于以下幾處:
            http://www.ogre3d.org/tikiwiki/Minimal+Ogre+Collision&structure=Libraries
            http://www.ogre3d.org/forums/viewtopic.php?t=45267
            http://sourceforge.net/projects/moc-collision/
            http://www.ogre3d.org/forums/viewtopic.php?t=23440
            http://code.google.com/p/minimal-ogre-collision-toolkit/

            moc代碼只有一個h和一個cpp文件,還算簡潔的。也是很多年沒有維護了,簡單用用也算夠了。

            使用步驟
            1、初始化
            1MOC::CollisionTools* mCollisionTools;
            2// init the collision handler
            3mCollisionTools = new CollisionTools(mSceneMgr, mArtifexLoader->mTerrainInfo);
            4
            5// set how far we want the camera to be above ground
            6mCollisionTools->setHeightAdjust(4.5f);
            7
            8// place the camera node on the ground
            9mCollisionTools->calculateY(mCamNode);

            2、碰撞檢測
             1// calculate the new Y position: check vs. terrain & all objects flagged with ENTITY_MASK
             2// multiple masks possible like e.g. ENTITY_MASK|MY_MASK|ETC_MASK
             3// doGridCheck casts a 2nd ray, gridWidth=2.0f ogre units away from the exact camera position to 
             4// avoid falling through small wholes or gaps in hangbridges for example.
             5mCollisionTools->calculateY(mCamNode,true,true,2.0f,ENTITY_MASK);
             6
             7// check if we are colliding with anything with a collision radius of 2.5 ogre units and we 
             8// set the ray origin -1.0 lower towards the ground to get smaller obstacles too
             9if (mCollisionTools->collidesWithEntity(oldPos, mCamNode->getPosition(), 2.5f-1.0f, ENTITY_MASK))
            10{
            11    // undo move
            12    mCamNode->setPosition(oldPos);
            13}

            3、鼠標拾取,射線查詢
             1void SampleApp::pickEntity(const OIS::MouseEvent &arg, const Ogre::uint32 queryMask)
             2{
             3    Entity *tmpE = NULL;
             4    Vector3 result = Vector3::ZERO;
             5    float distToColl;
             6    if (mCollisionTools->raycastFromCamera(mRenderWin, mCamera, arg, result, (ulong&)tmpE, distToColl, queryMask))
             7    {
             8        SceneNode* node = tmpE->getParentSceneNode();
             9        if (node->getShowBoundingBox()) 
            10        {
            11            node->showBoundingBox(false);
            12        }
             else 
            13        {
            14            node->showBoundingBox(true);
            15        }

            16    }

            17}

            18
            19bool SampleApp::mousePressed(const OIS::MouseEvent &arg, OIS::MouseButtonID id)
            20{
            21    if ( id == OIS::MB_Left )
            22    {
            23        mLMouseDown = true;
            24        pickEntity(arg, ENTITY_MASK);
            25    }

            26}

            4、清理
            delete mCollisionTools;

            5、中文資料
            http://archive.cnblogs.com/a/1914145/

            posted on 2011-06-08 18:14 的筆記 閱讀(1185) 評論(1)  編輯 收藏 引用

            欧美一区二区久久精品| 亚洲国产高清精品线久久 | 久久久精品国产免大香伊 | 久久国产欧美日韩精品免费| 久久se精品一区精品二区国产| 狠狠久久综合伊人不卡| 久久久久久精品久久久久| 国产精品久久久久久久久免费| 久久久网中文字幕| 99久久精品国内| 久久婷婷午色综合夜啪| 青青青青久久精品国产| 奇米综合四色77777久久| 久久久久久久国产免费看| 久久99精品久久只有精品| 久久男人AV资源网站| 成人资源影音先锋久久资源网| 久久久久久久综合狠狠综合| 一本伊大人香蕉久久网手机| 亚洲精品无码久久久久久| 久久噜噜久久久精品66| 久久国产精品久久久| 欧美一区二区三区久久综| 国产精品一区二区久久精品涩爱| 秋霞久久国产精品电影院| 久久综合狠狠综合久久| 性做久久久久久久久久久| 国产精品熟女福利久久AV| 97精品国产91久久久久久| 热re99久久6国产精品免费| 精品国产乱码久久久久久呢| 亚洲AV伊人久久青青草原| 久久亚洲精品无码观看不卡| 久久成人精品| 久久久精品国产亚洲成人满18免费网站 | 久久综合给合久久狠狠狠97色69| 亚洲精品成人久久久| 一本色道久久88综合日韩精品| 久久本道综合久久伊人| 色99久久久久高潮综合影院| 亚洲美日韩Av中文字幕无码久久久妻妇 |