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 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(); }
public WireFrameScene() { DefaultFloor(); Light(1, 1, -1); double Altitude(double u, double v) { var r = 8 * Helper.Radius(u - 0.5, v - 0.5); return(0.05 * (1 + Math.Cos(2 * Pi * r))); } var mesh = new HeightField(50, 50, Altitude); var triangleMeshFactory = new TriangleMeshFactory(false, false); Add(triangleMeshFactory.Build(mesh).Translate(tx: 0.5, tz: 0)); var wireFrameMeshFactory = new WireFrameMeshFactory(0.001, 0.0025); Add(wireFrameMeshFactory.Build(mesh).Translate(tx: -0.5, tz: 0)); }