ODE教程by wiki

ODE教程by wiki

ID:38583508

大小:95.50 KB

页数:9页

时间:2019-06-15

ODE教程by wiki_第1页
ODE教程by wiki_第2页
ODE教程by wiki_第3页
ODE教程by wiki_第4页
ODE教程by wiki_第5页
资源描述:

《ODE教程by wiki》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、HOWTOsimplebouncingsphere如何制作弹跳球Thispageisunderconstruction!1、Introduction介绍Thisarticledescribeshowtomakeaspherethatfallsontoaplaneandbounces.Thisisaboutassimpleasitgets,butitshowsthegeneralstructureofadynamicsimulationusingODE.本文介绍了如何制作一个落向地面并会弹起的球体。这很容易做到,但是它展示了利用ODE做动力学仿真的基本框架。2、Sampl

2、eCode示例代码ThiscodeiswritteninthestyleoftheODEdemos,andusesdrawstufftoshowthesimulation.这段代码使用ODE风格编写的,利用drawstuff函数(用于绘图)显示仿真过程。Firsttheobjectsforthesimulationmustbedeclared.Youmusthaveaworld,aspacetoputeverythingin,abodywithassociatedgeometryandmass,andajointgrouptostorethecontactjointst

3、hatarecreatedduringacollision.首先,必须声明仿真中用到的物体。你必须得有一个world,一个space来装载所有的东西,一个具有几何形状geometry和质量mass的body,还要有一个用于存放碰撞过程中产生的contactjoints的关节组jointgroup。#include#include//dynamicsandcollisionobjectsstaticdWorldIDworld;staticdSpaceIDspace;staticdBodyIDbody;st

4、aticdGeomIDgeom;staticdMassm;staticdJointGroupIDcontactgroup;Whenthecollisionsystemdetectsthattwoobjectsarecolliding,itcallsthisroutinewhichdeterminesthepointsofcontactandcreatestemporaryjoints.Thesurfaceparametersofthejoint(friction,bouncevelocity,CFM,etc)arealsosethere.当碰撞系统检测到两个物体相互碰撞

5、了,它就会调用下面这个程序来确定碰撞点的位置并创建暂时的碰撞关节。碰撞关节的表面参数(摩擦力,反弹速度,CFM等)也在这里设置。//thisiscalledbydSpaceCollidewhentwoobjectsinspaceare//potentiallycolliding.staticvoidnearCallback(void*data,dGeomIDo1,dGeomIDo2){dBodyIDb1=dGeomGetBody(o1);dBodyIDb2=dGeomGetBody(o2);dContactcontact;contact.surface.mode=dCo

6、ntactBounce

7、dContactSoftCFM;//frictionparameter摩擦参数contact.surface.mu=dInfinity;//bounceistheamountof"bouncyness".Bounce表示弹性度contact.surface.bounce=0.9;//bounce_velistheminimumincomingvelocitytocauseabounce.bounce_vel表示引起回弹的最小入射速度。contact.surface.bounce_vel=0.1;//constraintforcemixingpar

8、ameter.约束力混合参数CFMcontact.surface.soft_cfm=0.001;if(intnumc=dCollide(o1,o2,1,&contact.geom,sizeof(dContact))){dJointIDc=dJointCreateContact(world,contactgroup,&contact);dJointAttach(c,b1,b2);}}Thisfunctioniscalledatthestartofthesimulationtosetupthepointofviewofthecamera.下面

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。