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

            精品熟女少妇a∨免费久久| 国产叼嘿久久精品久久| 亚洲精品国产第一综合99久久| 久久精品国产99国产精品| 性欧美大战久久久久久久| 久久久久亚洲AV片无码下载蜜桃| 久久久久久人妻无码| 99久久www免费人成精品| 无码任你躁久久久久久久| 久久亚洲精品无码AV红樱桃| 久久亚洲国产中v天仙www| 亚洲婷婷国产精品电影人久久| 99久久99久久久精品齐齐| 色综合久久中文字幕综合网| 精品一区二区久久| 亚洲日本va中文字幕久久| 久久久精品人妻无码专区不卡| 无码国内精品久久人妻蜜桃| 日韩久久久久中文字幕人妻 | 99久久亚洲综合精品网站| 人妻无码精品久久亚瑟影视| 777久久精品一区二区三区无码| 久久亚洲中文字幕精品有坂深雪 | 欧美黑人激情性久久| 精品久久久久久国产三级| 一本久久a久久精品vr综合| 97精品依人久久久大香线蕉97| 99久久精品费精品国产| 亚洲国产精品18久久久久久| 亚洲AⅤ优女AV综合久久久| 国产99久久久久久免费看| 国产精品免费看久久久| 亚洲欧美伊人久久综合一区二区| 久久天天躁狠狠躁夜夜2020| 久久精品无码一区二区三区免费| 久久综合综合久久狠狠狠97色88| 久久午夜伦鲁片免费无码| 久久99久久99精品免视看动漫| 亚洲女久久久噜噜噜熟女| 日韩精品久久无码人妻中文字幕 | 精品久久久久久中文字幕人妻最新|