Example #1
0
	void Render(double time)
	{
		gl.Clear().ColorBuffer().DepthBuffer();
		//
		// make the light position vector
		auto light = Vec3f(8.0f, 8.0f, 8.0f);
		// make the matrix for camera orbiting the origin
		auto camera = CamMatrixf::Orbiting(
			Vec3f(),
			21.0,
			Degrees(time * 15),
			Degrees(SineWave(time*0.15) * 45)
		);
		auto nucl = ModelMatrixf::RotationA(
			Vec3f(1.0f, 1.0f, 1.0f),
			FullCircles(time)
		);

		proton.SetLightAndCamera(light, camera);
		proton.Render(nucl * ModelMatrixf::Translation(+1.4f,0.0f,0.0f));
		proton.Render(nucl * ModelMatrixf::Translation(-1.4f,0.0f,0.0f));

		neutron.SetLightAndCamera(light, camera);
		neutron.Render(nucl * ModelMatrixf::Translation(0.0f,0.0f,+1.0f));
		neutron.Render(nucl * ModelMatrixf::Translation(0.0f,0.0f,-1.0f));

		electron.SetLightAndCamera(light, camera);
		electron.Render(
			ModelMatrixf::RotationY(FullCircles(time * 0.7)) *
			ModelMatrixf::Translation(10.0f, 0.0f, 0.0f)
		);
		electron.Render(
			ModelMatrixf::RotationX(FullCircles(time * 0.7)) *
			ModelMatrixf::Translation(0.0f, 0.0f, 10.0f)
		);
	}
void DrawSphere(Vector3 const &pos, float radius)
{
	static Sphere sphere;
	sphere.Render(pos, radius);
}