public Scene GetScene(int width, int height) { Scene scene; var lookFrom = new Vector3(0, 2, 3); var lookAt = new Vector3(0, 0, 0); float distToFocus = 3; var aperture = 0.1f; aperture *= 0.2f; scene.Camera = Camera.Create( lookFrom, lookAt, Vector3.UnitY, 60, (float)width / height, aperture, distToFocus); scene.Solids = new List <Solid> { Solid.CreateSphere(100, new Vector3(0, -100.5f, -1), new Vector3(0.8f), 0.0f, 0f, 0.5f, 0), Solid.CreateSphere(0.5f, new Vector3(2, 0, -1), new Vector3(0.8f, 0.4f, 0.4f), 0f, 0f, 0.5f, 1), Solid.CreateSphere(0.5f, new Vector3(0, 0, -1), new Vector3(0.4f, 0.8f, 0.4f), 0.0f, 0.0f, 0.5f, 2), Solid.CreateSphere(0.3f, new Vector3(-1.5f, 1.5f, 0f), new Vector3(1f, 1f, 1f), 0.0f, 10f, 0f, 3), Solid.CreateSphere(0.3f, new Vector3(1.5f, 1.5f, -2f), new Vector3(0.8f, 0.8f, 0.2f), 0.0f, 5f, 0f, 4) }; scene.BackgroundColor = Vector4.Zero; return(scene); }
public void InitPoints() { double halfWidth = 0.0; double halfHeight = 0.0; switch (Rotation) { case OnRotation.TOP: case OnRotation.BELOW: { halfWidth = 0.5 * Parent.SectionWidth; halfHeight = 0.5 * Parent.SectionHeight; } break; case OnRotation.FRONT: case OnRotation.BACK: { halfWidth = 0.5 * Parent.SectionHeight; halfHeight = 0.5 * Parent.SectionWidth; } break; } Vector3D halfV2 = halfHeight * Parent.V2; Vector3D halfV3 = halfWidth * Parent.V3; Vector3D lcrOffsetV = _lcrOffset * lcrDir * Parent.V3; Vector3D depthOffsetV = _depthOffset * depthDir * Parent.V2; allignPnts[0, 0] = Parent.MidPoint - halfV2 + halfV3 + lcrOffsetV + depthOffsetV; allignPnts[1, 0] = Parent.MidPoint + halfV3 + lcrOffsetV + depthOffsetV; allignPnts[2, 0] = Parent.MidPoint + halfV2 + halfV3 + lcrOffsetV + depthOffsetV; allignPnts[0, 1] = Parent.MidPoint - halfV2 + lcrOffsetV + depthOffsetV; allignPnts[1, 1] = new Point3D(Parent.MidPoint.X, Parent.MidPoint.Y, Parent.MidPoint.Z) + lcrOffsetV + depthOffsetV;; allignPnts[2, 1] = Parent.MidPoint + halfV2 + lcrOffsetV + depthOffsetV;; allignPnts[0, 2] = Parent.MidPoint - halfV2 - halfV3 + lcrOffsetV + depthOffsetV;; allignPnts[1, 2] = Parent.MidPoint - halfV3 + lcrOffsetV + depthOffsetV;; allignPnts[2, 2] = Parent.MidPoint + halfV2 - halfV3 + lcrOffsetV + depthOffsetV;; Transformation t = new Transformation(); t.Rotation(_rotationOffset.ToRadian(), Parent.V1, allignPnts[1, 1]); Parent.V2_curr.TransformBy(t); Parent.V3_curr.TransformBy(t); allingPntsRepresenter.Clear(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { allignPnts[i, j].TransformBy(t); var temp = Solid.CreateSphere(8, 10, 10); temp.Translate(new Vector3D(Point3D.Origin, allignPnts[i, j])); allingPntsRepresenter.Add(temp); } } pAllign.TransformBy(new Translation(new Vector3D(pAllign, allignPnts[DepthIndex, LCRIndex]))); var pAllignRep = Solid.CreateSphere(10, 10, 10); pAllignRep.Translate(new Vector3D(Point3D.Origin, pAllign)); pAllignRep.Color = System.Drawing.Color.Red; pAllignRep.ColorMethod = colorMethodType.byEntity; allingPntsRepresenter.Add(pAllignRep); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("RepresentPoints")); }
public static void Medal(Model model) { // materials Material alu = Material.Aluminium; alu.Diffuse = Color.White; alu.Environment = 0.4f; string medalMatName = "Alu"; alu.Name = medalMatName; model.Materials.Add(alu); string woodMatName = "Wood"; Material wood = new Material(woodMatName, new Bitmap(MainWindow.GetAssetsPath() + "Textures/Wenge.jpg")); model.Materials.Add(wood); // medal Solid sphere = Solid.CreateSphere(200, 120, 60); sphere.Rotate(Math.PI / 2, Vector3D.AxisY); sphere.Translate(0, 0, -190); Solid cylinder = Region.CreateCircle(Plane.XY, 0, 0, 50).ExtrudeAsSolid(100, 0.1); Solid[] intersection = Solid.Intersection(sphere, cylinder); Solid lens = intersection[0]; Text eyeshotText = new Text(-45.5, -8, 0, "eyeshot", 19); eyeshotText.Translate(0, 0, 2); List <Solid> solidItems = new List <Solid>(); solidItems.Add(lens); solidItems.AddRange(model.ExtrudeText(eyeshotText, 0.01, new Vector3D(0, 0, 10), true)); Solid medal = Solid.Union(solidItems.ToArray())[0]; medal.ColorMethod = colorMethodType.byEntity; medal.MaterialName = "alu"; medal.Translate(0, 0, 2); model.Entities.Add(medal, Color.White); // jewel case Solid b1 = Solid.CreateBox(140, 140, 12); b1.Translate(-70, -70, 0); Solid b2 = Solid.CreateBox(108, 108, 12); b2.Translate(-54, -54, 2); Solid[] diff1 = Solid.Difference(b1, b2); Plane pln = Plane.YZ; Line ln1 = new Line(pln, 0, 0, 4, 0); Line ln2 = new Line(pln, 4, 0, 4, 4); Line ln3 = new Line(pln, 4, 4, 8, 4); Arc a1 = new Arc(pln, new Point2D(12, 4), 4, Math.PI / 2, Math.PI); Line ln4 = new Line(pln, 12, 8, 12, 12); Line ln5 = new Line(pln, 12, 12, 0, 12); Line ln6 = new Line(pln, 0, 12, 0, 0); CompositeCurve sect = new CompositeCurve(ln1, ln2, ln3, a1, ln4, ln5, ln6); sect.Translate(0, -70, 0); devDept.Eyeshot.Entities.Region sectReg = new devDept.Eyeshot.Entities.Region(sect); LinearPath rail = new LinearPath(new Point3D[] { new Point3D(0, -70, 0), new Point3D(70, -70, 0), new Point3D(70, +70, 0), new Point3D(-70, +70, 0), new Point3D(-70, -70, 0), new Point3D(0, -70, 0) }); Solid frame = sectReg.SweepAsSolid(rail, 0.1); Solid[] diff2 = Solid.Difference(diff1[0], frame); Solid jewelCase = diff2[0]; jewelCase.ApplyMaterial(woodMatName, textureMappingType.Cubic, 1, 1); model.Entities.Add(jewelCase, Color.FromArgb(32, 0, 0)); }