private void TheOneRing() { const double r1 = 1; const double r2 = 0.2; void CirclePath(double t, out double x, out double y, out double z) { x = r1 * Math.Cos(2 * Pi * t); y = 0; z = r1 * Math.Sin(2 * Pi * t); } void CircleCurve(double u, double v, out double x, out double y) { x = r2 * 0.5 * Math.Cos(2 * Pi * v); y = r2 * Math.Sin(2 * Pi * v); } CurveSweepMesh mesh = new CurveSweepMesh(100, 40, CirclePath, CircleCurve); TriangleMeshFactory triFactory = new TriangleMeshFactory(); var torusTriangle = triFactory.Build(mesh); torusTriangle.Material = new Material((Yellow + Brown) / 2, reflective: 1, diffuse: 1, specular: 2, ambient: 0); Add(torusTriangle).Translate(ty: r2); }
public override void InitWorld() { Light(-10, 10, -10); const double r0 = 0.02; const double r1 = 1; const double r2 = 0.25; void CloverPath(double t, out double x, out double y, out double z) { x = r1 * (Math.Cos(2 * Pi * t) + 2 * Math.Cos(2 * Pi * 2 * t)); y = r1 * (Math.Sin(2 * Pi * t) - 2 * Math.Sin(2 * Pi * 2 * t)); z = 2 * r2 * Math.Sin(2 * Pi * 3 * t); } void CircleCurve(double u, double v, out double x, out double y) { x = r2 * Math.Cos(2 * Pi * v); y = r2 * Math.Sin(2 * Pi * v); } CurveSweepMesh mesh = new CurveSweepMesh(80, 15, CloverPath, CircleCurve); WireFrameMeshFactory factory = new WireFrameMeshFactory(r0, true, true); var cloverWire = factory.Build(mesh); cloverWire.Material = new Material(Magenta); Add(cloverWire); }
public CurveSweepScene() { DefaultFloor(); Light(0, 5, -5); var curveSweepMesh = new CurveSweepMesh(36 * 10, 18, Path, Curve); var triangleFactory = new TriangleMeshFactory(); var curveSweep = triangleFactory.Build(curveSweepMesh); Add(curveSweep.Rotate(rx: Pi / 2).Translate(ty: 0.55)); }
public override void InitWorld() { Light(-10, 10, -10); const double r0 = 0.05; const double r1 = 3; const double r2 = 1; void CirclePath(double t, out double x, out double y, out double z) { x = r1 * Math.Cos(2 * Pi * t); y = 0; z = r1 * Math.Sin(2 * Pi * t); } void CircleCurve(double u, double v, out double x, out double y) { x = r2 * Math.Cos(2 * Pi * v); y = r2 * Math.Sin(2 * Pi * v); } CurveSweepMesh mesh = new CurveSweepMesh(40, 10, CirclePath, CircleCurve); WireFrameMeshFactory factory = new WireFrameMeshFactory(r0, true, true); var torusWire = factory.Build(mesh); torusWire.Material = new Material(Magenta); Add(torusWire).Translate(ty: r2 + r0); TriangleMeshFactory triFactory = new TriangleMeshFactory(); var torusTriangle = triFactory.Build(mesh); torusTriangle.Material = new Material(Cyan) { Transparency = 0.99 }; Add(torusTriangle).Translate(ty: r2 + r0); SphereMeshFactory sphereFactory = new SphereMeshFactory(2 * r0); var torusSphere = sphereFactory.Build(mesh); torusSphere.Material = new Material(Yellow); Add(torusSphere).Translate(ty: r2 + r0); DefaultFloor(); }