Siv3D / OpenSiv3D

C++20 framework for creative coding 🎮🎨🎹 / Cross-platform support (Windows, macOS, Linux, and the Web)
https://siv3d.github.io/
MIT License
1.02k stars 140 forks source link

Viewportの中でCamera2Dが使いたい #320

Open sknjpn opened 5 years ago

sknjpn commented 5 years ago

現状のCamera2Dだと、Transformer2Dのスコープの中で拡大・縮小する座標がずれてしまうために使うことが出来ないので、使えるようにしてほしいです。

# include <Siv3D.hpp> // OpenSiv3D v0.4.0

void Main()
{
    Camera2D camera;

    Array<Vec2> verticles;
    for (int i = 0; i < 100; i++) verticles.emplace_back(RandomVec2(Scene::Rect()));

    while (System::Update())
    {
        auto v = ScopedViewport2D(100, 100, 480, 360);
        auto t1 = Transformer2D(Mat3x2::Identity(), Mat3x2::Translate(100, 100));

        Circle(Cursor::PosF(), 8).draw(Palette::Green);

        camera.update();

        auto t2 = camera.createTransformer();

        Scene::Rect().draw(ColorF(Palette::Skyblue, 0.5));
        for (const auto& v : verticles) Circle(v, 16).draw(Palette::Red).drawFrame(1.0, Palette::Black);
    }
}
Reputeless commented 5 years ago

参考: https://github.com/sknjpn/TinyCamera