Play Siv3D!

ゲームとメディアアートのための C++ ライブラリ「Siv3D」

極座標系

極座標系

Siv3D June 2015 v2

円座標

# include <Siv3D.hpp>

void Main()
{
	Graphics::SetBackground(Palette::White);

	while (System::Update())
	{
		for (int i = 0; i < 72; ++i)
		{
			const double radian = Radians(i * 10);

			const Vec2 pos = Circular(i * 3, radian) + Window::Center();

			Circle(pos, 6).draw(HSV(i * 10));
		}
	}
}


円柱座標

# include <Siv3D.hpp>

void Main()
{
	Graphics::SetBackground(Color(80, 160, 230));
	Graphics3D::SetAmbientLight(ColorF(0.4));

	Texture texture(L"Example/ground.jpg", TextureDesc::For3D);

	while (System::Update())
	{
		Graphics3D::FreeCamera();

		Plane(100).draw(texture);

		for (int i = 0; i < 120; ++i)
		{
			Box(Cylindrical(4 + i * 0.1, i / 20.0 * TwoPi, i * 0.2), 1)
				.draw(HSV(i*3).toColorF());
		}
	}
}


球面座標

# include <Siv3D.hpp>

void Main()
{
	Graphics::SetBackground(Color(80, 160, 230));
	Graphics3D::SetAmbientLight(ColorF(0.4));

	Texture texture(L"Example/ground.jpg", TextureDesc::For3D);

	while (System::Update())
	{
		Graphics3D::FreeCamera();

		Plane(100).draw(texture);

		for (int i = 0; i < 10; ++i)
		{
			Box(Spherical(5, i / 10.0 * TwoPi, 1.0), 1)
				.moveBy(0, 6, 0)
				.draw(HSV(i*30).toColorF());
		}

		for (int i = 0; i < 10; ++i)
		{
			Sphere(Spherical(6, HalfPi, i / 10.0 * TwoPi), 0.5)
				.moveBy(0, 6, 0)
				.draw(HSV(i * 30).toColorF());
		}
	}
}