还以为万事开头难,但有时还并非如此
物理引擎和渲染是没有直接关系的,但考虑到跨平台,几乎所有的物理引擎都选择在GL环境下编写
我担心没学过GL,学引物理擎会产生很大的障碍,对此望而生畏
然后昨天在newton论坛上发贴求助,一个老外很热心跟我说,你不用去看gl的任何代码,只要和newton sdk有关的代码你才去看。
tonykee
Joined: 28 May 2008 Posts: 2
|
Posted: Wed May 28, 2008 9:00 am Post subject: Can I gets more example with directx? |
|
|
As I know that physics engine does not decide to the render shell
Newton can work with opengl or directx perfectly
But I have not learn OpenGL before, it's difficult for me to read the examples in the sdk, some other physics engine example(such like bullet, ode etc.) are all writen with OpenGL, I've not enough time to learn OpenGL now
So, I need some example with directx9 . I think there is more people as the same as me
could these be realized? |
|
Back to top |
|
|
Gianluca
Joined: 11 Nov 2005 Posts: 352 Location: Rome - Italy
|
Posted: Wed May 28, 2008 11:03 am Post subject: |
|
|
When you read the code of the SDK... simple ignore all OpenGL stuff !!!
They are completly irrilevant for understanding how newton works.
You don't have to learn OpenGL !! Simple don't read it |
|
Back to top |
|
|
tonykee
Joined: 28 May 2008 Posts: 2
|
Posted: Wed May 28, 2008 11:20 am Post subject: Thx, and I'll have a try! |
|
|
Thx, and I'll have a try, the fist aim is to translate the fist tutorail_01_getingstarted uder the directx, and so on |
|
果然如此,第一个例子关键的部分看了5分钟,基本上思路就很清楚了。
接下来,把sdk里面的某些部分给抠出来,想不到出奇般的顺利,
方法是除去和gl相关的一系列代码
把他的toolbox下的一系列和dVector dMatrix等等代码搬过来,有两个和gl有关的类直接删掉了,
然后把D:\Program Files\NewtonSDK\sdk\dll 下的lib 导入,dll拷贝到编译后的exe目录下,另外一个newton.h也拷贝到toolbox下面去。
呵呵经过一系列配置,环境搭建起来了,试试一个函数看看
NewtonWorld nWorld = NewtonCreate (NULL, NULL);
编译竟然没出错,一次成功,信心大增
然后按照sdk里面第一个例子的思路迅速写完第一个demo
当然其中涉及到D3DXMATRIX和dMatrix的转换,其实两个结构完全一致的,很容易理解。
然后运行,也是一次成功,模仿第一个例子,我在空间放了一个按一定角速度旋转的方块。
所有的工作都是一次成功,真有点不感相信自己的眼睛。
看来之前的确是太浮躁了,如果真能静下心来,其实很多事情并没想象中那么复杂的。
最后还是非常感谢那个老外给我的这点提示,短短几句话却给了我一条光明大道。
接下来的很多例子也许会碰到更多的问题,但最起码我有了可用的环境,更加有了信心