Siv3D May 2013 を公開しました
Siv3D のアップデート May 2013 を公開しました。
導入の手順はこちらです。
http://play-siv3d.hateblo.jp/entry/install
おもな新機能を紹介します。
Visual Studio 2012 対応
enum class や <random> ヘッダ、range-based for ループ、emplace_back などの C++11 の機能が使えるようになりました。なお Visual C++ 2010 は非対応になったので注意してください。
# include <Siv3D.hpp> void Main() { Vec2 pts[200]; for(auto& p : pts) // range-based for ループ { p.set(Random(0,640),Random(0,480)); } while(System::Update()) { for(auto const& p : pts) { Circle(p,5).draw(); } } }
インターネットからファイルをダウンロード
URL を指定して、インターネット上のファイルを同期または非同期でダウンロードできるようになりました。
# include <Siv3D.hpp> void Main() { const FilePath url = L"https://www.google.co.jp/images/srpr/logo4w.png"; const FilePath downloadFile = L"download.png"; if(!Internet::IsConnected()) return; // インターネット接続をチェック if(!Internet::Connect(url)) return; // URL に接続 if(!Internet::DownloadTo(downloadFile)) return; // ダウンロード(同期) const Texture texture(downloadFile); while(System::Update()) { texture.draw(); } }
Kinect 対応
接続された Kinect for Windows からカラー、深度、スケルトン、加速度を取得できるようになりました。near モード、seated モード、カメラの角度の設定もできます。
# include <Siv3D.hpp> void Main() { DynamicTexture texture; if(!Kinect::IsConnected()) return; // Kinect の接続チェック if(!Kinect::Start( ImageResolution::Image_640x480, DepthResolution::Depth_640x480, true)) return; // Kinect の起動 optional<Skelton> skelton; while(System::Update()) { if(Kinect::HasNewDepth()) { Kinect::GetDepthFrame(texture); } if(auto s = Kinect::GetSkelton()) { skelton = s.get(); } texture.draw(); if(skelton) { for(const Vec2& p : skelton.get().screenPostions) { Circle(p,10).draw(); } } } }
単一のサウンドの複数同時再生に対応
すでに再生中の Sound を、重ねて同時再生できるようになりました。
# include <Siv3D.hpp> void Main() { const Sound sound(L"xxx.mp3"); while(System::Update()) { if(Input::MouseL.clicked) { sound.playMulti(); // クリックするたびに重ねて再生 } } }
2D / 3D 描画のサンプラーステート
リニアサンプリング / 異方性サンプリング / ポイントサンプリングを設定できるようになりました。
指定した座標を中心にフォントを描画
中心位置を指定してフォントを描画できるようになりました。
# include <Siv3D.hpp> void Main() { const Font font(50); const Circle circle(150,150,120); const Rect rect(250,250,300,200); while(System::Update()) { circle.draw(); rect.draw(); font.drawCenter(L"Siv3D",circle.pos,Palette::Blue); font.drawCenter(L"Engine",rect.center,Palette::Gray); } }
指定した座標を中心に Texture を描画
中心位置を指定してテクスチャを描画できるようになりました。
Texture::drawAt() 関数を使います。
ファイルとディレクトリを操作する関数
ファイルとディレクトリを操作する関数を充実させました。
また、ファイル保存時にディレクトリが自動で作成されるようになりました。
image.save(L"aaa/bbb/ccc.png");
aaa フォルダが存在しない場合、aaa フォルダと bbb フォルダが自動で作成されます。
Noise クラスを再設計
Perlin Noise クラスが使いやすくなりました。
# include <Siv3D.hpp> void Main() { Noise perlin; Image image(640,480); for(unsigned y=0; y<image.height; ++y) { for(unsigned x=0; x<image.width; ++x) { double n = perlin.octaveNoise(x/40.0,y/40.0,6); n = Clamp(n*0.5+0.5,0.0,1.0); image[y][x] = ColorF(n,n,n); } } const Texture texture(image); while(System::Update()) { texture.draw(); } }
FBX ロード仮実装
実験的に FBX 形式の 3D モデルの読み込みに対応しました。Model クラスを使います。
新しいサンプルゲームを付属
動作チェックプログラムを、先日サークルのハッカソンで作ったゲーム「Reversi+」に変更しました。
その他の変更点一覧はこちらに載せています。
https://sites.google.com/site/siv3dgameengine/news/updates
次回のアップデートはバグ修正+小規模な機能追加で、5 - 6 月中に出す予定です。
Siv3D チュートリアルとサンプルも、新しいバージョンに対応するよう書き直します。