還以為萬事開頭難,但有時還并非如此
物理引擎和渲染是沒有直接關系的,但考慮到跨平臺,幾乎所有的物理引擎都選擇在GL環(huán)境下編寫
我擔心沒學過GL,學引物理擎會產(chǎn)生很大的障礙,對此望而生畏
然后昨天在newton論壇上發(fā)貼求助,一個老外很熱心跟我說,你不用去看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下面去。
呵呵經(jīng)過一系列配置,環(huán)境搭建起來了,試試一個函數(shù)看看
NewtonWorld nWorld = NewtonCreate (NULL, NULL);
編譯竟然沒出錯,一次成功,信心大增
然后按照sdk里面第一個例子的思路迅速寫完第一個demo
當然其中涉及到D3DXMATRIX和dMatrix的轉(zhuǎn)換,其實兩個結(jié)構(gòu)完全一致的,很容易理解。
然后運行,也是一次成功,模仿第一個例子,我在空間放了一個按一定角速度旋轉(zhuǎn)的方塊。
所有的工作都是一次成功,真有點不感相信自己的眼睛。
看來之前的確是太浮躁了,如果真能靜下心來,其實很多事情并沒想象中那么復雜的。
最后還是非常感謝那個老外給我的這點提示,短短幾句話卻給了我一條光明大道。
接下來的很多例子也許會碰到更多的問題,但最起碼我有了可用的環(huán)境,更加有了信心