早上跑去CMU請教了MOPED的作者,根據他的描述,只要參考裏面的modeling.dox,裏面的說明非常的直前(straightforward),只要照著做,就可以自己建立模型庫了。
不過我那時沒帶到我裝了Linux的筆電,只好等下午回到實驗室才能證實他的說法。
對於沒有安裝MOPED的人,請先根據這篇文章將MOPED check out出來,接下來所要用到的都在 pr/src/moped/moped2/modeling/ 這個目錄中。
最容易做的就是下載範例了。用
cd examples
sh download_examples.sh
等個幾分鐘,就全部下載完了。
首先要安裝Modeling
make 沒多久後就出現一個錯誤:
gcc: error trying to exec 'f951': execvp: No such file or directory
查了一下,在這裡提到要安裝gfortran,感覺蠻奇怪的,如果 gcc 是c的編譯器,那gfortran不就是fortran的編譯器了嗎!這不是我大學時代就已經開始淘汰的語言嗎!現在都什麼時代了還有人用fortran寫程式,我這可是最新的電腦耶,怎麼可以裝這種老古董的編譯器自損身價,重新找找看有沒有搞錯,可是都沒找到相關的。
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48697
雖然有點不願意,但是死馬當活馬醫,先用
sudo apt-get install gfortran
試試看,然後重新
make
果真解決了,還真的是 fortran 編譯器的問題,唉,我實在是小看了這博大精深的Linux了。
2013/06/07
2012/05/25
2012/05/17
C# game programming - For Serious Game Creation
有用的Timer
using System.Runtime.InteropServices;
namespace GameLoop {
public class PreciseTimer {
[System.Security.SuppressUnmanagedCodeSecurity] [DllImport("kernel32")] private static extern bool QueryPerformanceFrequency(ref long
PerformanceFrequency); [System.Security.SuppressUnmanagedCodeSecurity] [DllImport("kernel32")] private static extern bool QueryPerformanceCounter(ref long PerformanceCount); long _ticksPerSecond = 0; long _previousElapsedTime = 0; public PreciseTimer() {
QueryPerformanceFrequency(ref _ticksPerSecond); GetElapsedTime(); // Get rid of first rubbish result
} public double GetElapsedTime() {
long time = 0; QueryPerformanceCounter(ref time); double elapsedTime = (double)(time - _previousElapsedTime) /
(double)_ticksPerSecond; _previousElapsedTime = time; return elapsedTime;
} }
}
The QueryPerformanceFrequency function retrieves the frequency of the high-resolution performance counter. Most modern hardware has a high- resolution timer; this function is used to get the frequency at which the timer increments. The QueryPerformanceCounter function retrieves the current value of the high-resolution performance counter. These can be used together to time how long the last frame took.
GetElapsedTime should be called once per frame and this will keep track of the time. The elapsed time is so important that it should be incorporated into the game loop. Open the Program.cs file and change the game loop so it takes one argument.
public class FastLoop {
PreciseTimer _timer = new PreciseTimer(); public delegate void LoopCallback(double elapsedTime);
The timer is then called once per frame and elapsed time is passed on to FastLoop’s callback.
void OnApplicationEnterIdle(object sender, EventArgs e) {
while (IsAppStillIdle()) {
_callback(_timer.GetElapsedTime()); }
}
The game loop can now be used to smoothly animate any game! By the end of this chapter, the game loop will be used to smoothly rotate a 3D triangle—the ‘‘Hello World’’ application of OpenGL programming.
2011/10/31
2011/10/13
Working with ROS and OpenCV 在ROS裡面用OpenCV
這個印度人的部落格介紹了不少ROS與OpenCV的東西,先來試試看這個。
http://siddhantahuja.wordpress.com/2011/07/20/working-with-ros-and-opencv-draft/
http://siddhantahuja.wordpress.com/2011/07/20/working-with-ros-and-opencv-draft/
2011/07/26
How to import kivy in Eclipse 如何在Eclipse中加入Kivy的套件
今天查了下Python的資料,看到一個不錯的套件Kivy,可是呢,網站上的資料都只有英文不說,連如何加到Eclipse裡也沒有。難道我得要每次都拖拉我的程式到Kivy中執行嗎?這太麻煩了啊!
在網路上搜尋了一下,沒有人做過這件事,唯一的一個官方討論區的建議是,大部份的Kivy開發者都用小作家類得文字編輯器,在命令模式下執行。雖然我也很享受在鍵盤上敲打然後程式跑出來的感覺,可是呢,總是不甘心好不容易裝了個Eclipse+PyDev卻不能在上面用Kivy,最後花了點時間東看看西找找,居然也被我弄出來了,為了紀念這麼一天,在此紀錄一下。
在Mac OS X下的做法,首先用Terminal執行以下的命令。用來找出到底kivy躲在哪裡。
$ which kivy
我的電腦幫我找出來他在這裡的目錄內。
/usr/local/bin/kivy
輸入剛才找到的目錄,取個名字叫做kivy。
最後呢,他會幫忙找出這些,我加選了出現kivy的那兩個,其他是電腦自行找出來的。
之後選取Apply,當然,別忘記在Project->Property中選用新作的Interpreter。
最後,再重新啓動Eclipse就可以用囉!測試一下Hello World程式,完全沒有錯誤了。
import kivy
kivy.require('1.0.6') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
return Button(text='Hello World')
if __name__ in ('__android__', '__main__'):
MyApp().run()
結論,這可能是太簡單了,所以沒有人作成教學放在網路上。不過呢,對於我這種程式菜鳥,還是得靠這種圖文教學才學得會。若有其他人也有同樣的困擾,希望這篇對他有些幫助。
在網路上搜尋了一下,沒有人做過這件事,唯一的一個官方討論區的建議是,大部份的Kivy開發者都用小作家類得文字編輯器,在命令模式下執行。雖然我也很享受在鍵盤上敲打然後程式跑出來的感覺,可是呢,總是不甘心好不容易裝了個Eclipse+PyDev卻不能在上面用Kivy,最後花了點時間東看看西找找,居然也被我弄出來了,為了紀念這麼一天,在此紀錄一下。
在Mac OS X下的做法,首先用Terminal執行以下的命令。用來找出到底kivy躲在哪裡。
$ which kivy
我的電腦幫我找出來他在這裡的目錄內。
/usr/local/bin/kivy
輸入剛才找到的目錄,取個名字叫做kivy。
最後呢,他會幫忙找出這些,我加選了出現kivy的那兩個,其他是電腦自行找出來的。
之後選取Apply,當然,別忘記在Project->Property中選用新作的Interpreter。
最後,再重新啓動Eclipse就可以用囉!測試一下Hello World程式,完全沒有錯誤了。
import kivy
kivy.require('1.0.6') # replace with your current kivy version !
from kivy.app import App
from kivy.uix.button import Button
class MyApp(App):
def build(self):
return Button(text='Hello World')
if __name__ in ('__android__', '__main__'):
MyApp().run()
結論,這可能是太簡單了,所以沒有人作成教學放在網路上。不過呢,對於我這種程式菜鳥,還是得靠這種圖文教學才學得會。若有其他人也有同樣的困擾,希望這篇對他有些幫助。
Subscribe to:
Posts (Atom)