• <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>
            Cpper
            C/C++高級工程師 Android高級軟件工程師 IT集成工程師 音頻工程師 熟悉c,c++,java,c#,py,js,asp等多種語言 程序猿

             

             

            接上文介紹了ode的基本函數(shù),接下來應該考慮如何綁定Ode和游戲引擎
            簡單的說,單單使用ode不是什么難事情,必須網上使用ode的例子一大把
            問題的關鍵是如何較好的結合ode和引擎,記不至于游戲引擎把ode封裝的太深以至于影響其使用的靈活性.另外一方面是,也不能把過多的額外操作拋給用戶操作。
            不過可以先設計一個基本的框架,以后根據(jù)需要和認識的不斷加深再做修改。
            于是先寫下物理引擎的基本框架-很簡單的了:

             1 ////////////////////////////////////////////////////////////
             2 /// 定義物理引擎模板類 
             3 ////////////////////////////////////////////////////////////
             4 template<class World,class Space,class JointGroup,class Geom> 
             5 class PhysicsEngine
             6 {
             7 public:
             8     typedef void(*ContactNearCallback)(void *data, Geom o1, Geom o2);             
             9 public:
            10     ///////////////////////////////////////////////////////
            11     /// 構造,析構物理引擎類 
            12     //////////////////////////////////////////////////////
            13     PhysicsEngine();
            14     ~PhysicsEngine(); 
            15 public:     
            16     ///////////////////////////////////////////////////////
            17     /// 設定物理引擎平面(ax+by+cz+d=0) 
            18     //////////////////////////////////////////////////////
            19     void        SetPlane(float a = 0float b = 0float c = 1float d = 0);
            20     
            21     ///////////////////////////////////////////////////////
            22     /// 設定物理世界重力加速度 
            23     ///////////////////////////////////////////////////////     
            24     void        SetGravity(float x = 0float y = 0float z = -9.81);
            25     
            26     ///////////////////////////////////////////////////////
            27     /// 設定物理世界仿真更新值 
            28     ///////////////////////////////////////////////////////     
            29     inline void SetStepValue(float step = 0.05fbool quick = true)
            30     {
            31         this->step = step; this->quick = quick;      
            32     }
            33     
            34     ///////////////////////////////////////////////////////
            35     /// 加載引擎物理對象碰撞回調函數(shù) 
            36     //////////////////////////////////////////////////////
            37     inline void  SetCollideCallBack(ContactNearCallback callback)
            38     {
            39          this->callback = callback;        
            40     }
            41  
            42     ///////////////////////////////////////////////////////
            43     /// 調用物理引擎模擬 
            44     ///////////////////////////////////////////////////////     
            45     void       Simulation(); 
            46     
            47     ///////////////////////////////////////////////////////
            48     /// 獲取物理引擎世界,空間和關節(jié)組對象. 
            49     ///////////////////////////////////////////////////////    
            50     inline World       GetWorld(){return world;}
            51     inline Space       GetSpace(){return space;}
            52     inline JointGroup  GetContactGroup(){return contactgroup;}
            53 private:
            54     World                  world;
            55     Space                  space;
            56     JointGroup             contactgroup;
            57     ContactNearCallback    callback; 
            58     float                  step;
            59     bool                   quick;                 
            60 };
            61  
            62 #ifdef PHYSICS_EXT_ODE
            63     #include "OdePhysics.inl"
            64 #endif 

             具體對于ode,我看可以這樣使用之:

            1 core::PhysicsEngine<dWorldID,dSpaceID,dJointGroupID,dGeomID> engine;
            或者可以這樣
            1 core::PhysicsEngine<> engine;
            再給出一個簡單的物理對象數(shù)據(jù)結構
             1 ////////////////////////////////////////////////////////////
             2 /// 定義引擎物理對象數(shù)據(jù)結構(一個對象由N個幾何體構成)
             3 ////////////////////////////////////////////////////////////
             4 /*template<class Object,class Geom,int N>
             5 struct PhysicsObject
             6 
             7     Object object;
             8     //! 有必要設計一個定長數(shù)組了.
             9     Geom   geom[N];    
            10 };*/ 
            一個物理對象由N個簡單幾何體構成
            這個是簡單到了極點只是不太符合要求
            下一步該考慮設計物理對象類了
            對象可以旋轉,平移,設置質量,加掛幾何體.......
            最后再上幾個ode函數(shù)加深一點認識吧:
             1 /**
             2  * @brief Set the local offset rotation matrix of a geom from its body.
             3  *
             4  * Sets the geom's rotational offset in local coordinates.
             5  * After this call, the geom will be at a new position determined from the
             6  * body's position and the offset.
             7  * The geom must be attached to a body.
             8  * If the geom did not have an offset, it is automatically created.
             9  *
            10  * @param geom the geom to set.
            11  * @param R the new rotation matrix.
            12  * @ingroup collide
            13  */
            14 ODE_API void dGeomSetOffsetRotation (dGeomID geom, const dMatrix3 R);

            設置幾何體相對于其物體的局部旋轉平移矩陣
             1 /**
             2  * @brief Set the offset position of a geom from its body.
             3  *
             4  * Sets the geom's positional offset to move it to the new world
             5  * coordinates.
             6  * After this call, the geom will be at the world position passed in,
             7  * and the offset will be the difference from the current body position.
             8  * The geom must be attached to a body.
             9  * If the geom did not have an offset, it is automatically created.
            10  *
            11  * @param geom the geom to set.
            12  * @param x the new X coordinate.
            13  * @param y the new Y coordinate.
            14  * @param z the new Z coordinate.
            15  * @ingroup collide
            16  */
            17 ODE_API void dGeomSetOffsetWorldPosition (dGeomID geom, dReal x, dReal y, dReal z);
            生成,設置幾何對象的函數(shù):
             1 ODE_API dGeomID dCreateSphere (dSpaceID space, dReal radius);
             2 ODE_API void dGeomSphereSetRadius (dGeomID sphere, dReal radius);
             3 ODE_API dReal dGeomSphereGetRadius (dGeomID sphere);
             4 ODE_API dGeomID dCreateBox (dSpaceID space, dReal lx, dReal ly, dReal lz);
             5 ODE_API void dGeomBoxSetLengths (dGeomID box, dReal lx, dReal ly, dReal lz);
             6 ODE_API void dGeomBoxGetLengths (dGeomID box, dVector3 result);
             7 ODE_API dGeomID dCreateCapsule (dSpaceID space, dReal radius, dReal length);
             8 ODE_API void dGeomCapsuleSetParams (dGeomID ccylinder, dReal radius, dReal length);
             9 ODE_API void dGeomCapsuleGetParams (dGeomID ccylinder, dReal *radius, dReal *length);
            10 ODE_API dReal dGeomCapsulePointDepth (dGeomID ccylinder, dReal x, dReal y, dReal z);
            11 ODE_API dGeomID dCreateCylinder (dSpaceID space, dReal radius, dReal length);
            12 ODE_API void dGeomCylinderSetParams (dGeomID cylinder, dReal radius, dReal length);
            13 ODE_API void dGeomCylinderGetParams (dGeomID cylinder, dReal *radius, dReal *length);
            14 ODE_API dGeomID dCreateRay (dSpaceID space, dReal length);
            15 ODE_API void dGeomRaySetLength (dGeomID ray, dReal length);
            16 ODE_API dReal dGeomRayGetLength (dGeomID ray);
            17 ODE_API void dGeomRaySet (dGeomID ray, dReal px, dReal py, dReal pz,
            18 dReal dx, dReal dy, dReal dz);
            19 ODE_API void dGeomRayGet (dGeomID ray, dVector3 start, dVector3 dir);

            posted on 2010-02-28 17:02 ccsdu2009 閱讀(1548) 評論(3)  編輯 收藏 引用
            Comments
            • # re: 綁定ode物理引擎于蓋莫游戲引擎
              陳梓瀚(vczh)
              Posted @ 2010-02-28 17:14
              一般來說,要求用戶提供一個模型的同時,要提供一個配套的物理模型(可以不只一個多面體,譬如說人,是有關節(jié)的),然后給接口讓他們有機會直接控制速度、位置和力就好了。沒設置的就讓物理引擎去算。

              你可以通過開發(fā)一個3dmax插件來為你的引擎產生這些數(shù)據(jù)  回復  更多評論   
            • # re: 綁定ode物理引擎于蓋莫游戲引擎
              99書城
              Posted @ 2010-03-01 18:02
              問我ieriuwer我的房間和我  回復  更多評論   
            • # re: 綁定ode物理引擎于蓋莫游戲引擎
              樂蜂網美麗俏佳人
              Posted @ 2010-03-01 22:01
              開始的法規(guī)盡快答復進口  回復  更多評論   
             
            精品久久久久久成人AV| 久久夜色精品国产噜噜亚洲a| 色播久久人人爽人人爽人人片aV| 国产V亚洲V天堂无码久久久| 久久久久亚洲精品日久生情| 久久综合视频网站| 伊人精品久久久久7777| 亚洲精品国精品久久99热| 欧美一级久久久久久久大| 久久亚洲中文字幕精品一区| 亚洲国产精品无码久久九九| 亚洲国产综合久久天堂| 欧美久久久久久| 无码伊人66久久大杳蕉网站谷歌 | 91精品国产91久久| 国产午夜免费高清久久影院| AV狠狠色丁香婷婷综合久久| 91精品国产高清久久久久久io| 久久最近最新中文字幕大全| 狠狠综合久久综合中文88| 亚洲国产精品嫩草影院久久| 国内高清久久久久久| 久久精品国产亚洲AV无码偷窥| 久久久青草青青亚洲国产免观| 精品无码久久久久久国产| 国内精品久久久久影院亚洲| 色婷婷久久综合中文久久蜜桃av| 久久本道伊人久久| 四虎国产精品免费久久| 婷婷久久久亚洲欧洲日产国码AV| 久久综合中文字幕| 7777精品伊人久久久大香线蕉| 久久精品亚洲日本波多野结衣| 成人午夜精品久久久久久久小说| 亚洲精品高清一二区久久| AAA级久久久精品无码片| 亚洲а∨天堂久久精品| 精品久久久久久久无码| 欧美精品九九99久久在观看| www.久久99| 久久99精品久久久大学生|