Skip to content

Latest commit

 

History

History
32 lines (26 loc) · 629 Bytes

Intersection3D.md

File metadata and controls

32 lines (26 loc) · 629 Bytes

3D 交差判定

3D 交差判定

# include <Siv3D.hpp>

void Main()
{
	Array<Box> boxes;

	for (auto i : step(50))
	{
		boxes.emplace_back(RandomVec3({ -20, 20 }, { -20, 20 }, { -20, 20 }), 3.0);

		boxes[i].rotation.rotateRollPitchYaw(Random(Pi), Random(Pi), Random(Pi));
	}

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

		for (auto& box : boxes)
		{
			box.rotation.rotateRollPitchYaw(0.01, 0.01, 0.01);
		}

		for (const auto& box : boxes)
		{
			box.draw(box.intersects(Mouse::Ray()) ? Palette::Yellow : Palette::White);
		}
	}
}