• <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 的筆記 閱讀(1193) 評論(1)  編輯 收藏 引用

            久久这里只精品99re66| 国产 亚洲 欧美 另类 久久| www.久久热| 香港aa三级久久三级| 国产69精品久久久久99| 久久婷婷午色综合夜啪| 久久99精品国产自在现线小黄鸭| 久久99精品久久久久久齐齐| 色青青草原桃花久久综合| 热re99久久精品国99热| 精品久久久久久无码人妻热| 久久亚洲国产精品成人AV秋霞| 69国产成人综合久久精品| 久久人人爽人爽人人爽av| 久久久一本精品99久久精品88| 国产精品美女久久久免费| 色综合久久久久久久久五月| 91久久精品无码一区二区毛片| 亚洲va久久久噜噜噜久久| 亚洲精品久久久www| 大香网伊人久久综合网2020| 久久精品九九亚洲精品| 国产精品乱码久久久久久软件 | 97精品国产91久久久久久| 国产精品九九久久精品女同亚洲欧美日韩综合区 | 久久丫精品国产亚洲av不卡| 久久亚洲中文字幕精品一区四| 丁香狠狠色婷婷久久综合| 国产精品久久久久免费a∨| 久久伊人五月天论坛| 久久精品国产亚洲5555| 91久久精品视频| 精品久久久久久无码人妻热| 久久久精品免费国产四虎| 人妻精品久久无码区| 77777亚洲午夜久久多喷| 7777久久久国产精品消防器材| 久久精品中文无码资源站| 久久亚洲sm情趣捆绑调教| 人妻精品久久久久中文字幕一冢本 | 亚洲精品NV久久久久久久久久 |