private void AddBoxAndBoxBooleanTest() { RayTracer.BoxShape box1 = new RayTracer.BoxShape(new Vector3(.5, .5, .5), new Vector3(1.5, 1.5, 1.5), new RayTracer.SolidMaterial(RGBA_Floats.Green, .01, 0.0, 2.0)); List <RayTracer.IRayTraceable> subtractShapes = new List <RayTracer.IRayTraceable>(); RayTracer.SolidMaterial material = new RayTracer.SolidMaterial(RGBA_Floats.Red, 0, 0, 0); subtractShapes.Add(new BoxShape(new Vector3(), new Vector3(1, 1, 1), material)); RayTracer.IRayTraceable subtractGroup = RayTracer.BoundingVolumeHierarchy.CreateNewHierachy(subtractShapes); Difference merge = new Difference(box1, subtractGroup); renderCollection.Add(merge); }
private void AddBoxAndSheresBooleanTest() { RayTracer.BoxShape box1 = new RayTracer.BoxShape(new Vector3(.5, .5, .5), new Vector3(1.5, 1.5, 1.5), new RayTracer.SolidMaterial(RGBA_Floats.Green, 0, 0, 0));//.01, 0.0, 2.0)); List <RayTracer.IRayTraceable> subtractShapes = new List <RayTracer.IRayTraceable>(); RayTracer.SolidMaterial material = new RayTracer.SolidMaterial(RGBA_Floats.Red, 0, 0, 0); #if true // two big spheres. Looks good. subtractShapes.Add(new RayTracer.SphereShape(new Vector3(.5, .5, 1), .6, material)); subtractShapes.Add(new RayTracer.SphereShape(new Vector3(1.5, .5, 1), .6, material)); Transform cylinder = new Transform(new RayTracer.CylinderShape(.1, 3, material)); cylinder.MoveToAbsolute(1, 1, 1); cylinder.RotateRelative(.1, .6, .6); //subtractShapes.Add(cylinder); //renderCollection.Add(cylinder); #else for (int z = 0; z < 6; z++) { for (int y = 0; y < 6; y++) { for (int x = 0; x < 6; x++) { subtractShapes.Add(new SphereShape(new Vector3(x * .2 + .5, y * .2 + .5, z * .2 + .5), .1, material)); //subtractShapes.Add(new SphereShape(new Vector3(x * .2 + .5, y * .2 + .5, z * .2 + .5), .13, material)); } } } #endif IRayTraceable subtractGroup = BoundingVolumeHierarchy.CreateNewHierachy(subtractShapes); Difference merge = new Difference(box1, subtractGroup); renderCollection.Add(merge); }
private void AddAxisMarker() { int count = 10; double size = .1; for (int i = 1; i < count + 1; i++) { RGBA_Floats xColor = new RGBA_Floats(1, i / (double)count, i / (double)count); RayTracer.SolidMaterial xMaterial = new RayTracer.SolidMaterial(xColor, 0, 0.0, 2.0); RayTracer.BoxShape xBox = new RayTracer.BoxShape(new Vector3(i * size, 0, 0), new Vector3(i * size + size, size, size), xMaterial); renderCollection.Add(xBox); RGBA_Floats yColor = new RGBA_Floats(i / (double)count, 1, i / (double)count); RayTracer.SolidMaterial yMaterial = new RayTracer.SolidMaterial(yColor, 0, 0.0, 2.0); RayTracer.BoxShape yBox = new RayTracer.BoxShape(new Vector3(0, i * size, 0), new Vector3(size, i * size + size, size), yMaterial); //yBox.Transform.Position += new Vector3D(1, 1, 1); renderCollection.Add(yBox); RGBA_Floats zColor = new RGBA_Floats(i / (double)count, i / (double)count, 1); RayTracer.SolidMaterial zMaterial = new RayTracer.SolidMaterial(zColor, 0, 0.0, 2.0); RayTracer.BoxShape zBox = new RayTracer.BoxShape(new Vector3(0, 0, i * size), new Vector3(size, size, i * size + size), zMaterial); renderCollection.Add(zBox); } }
private void AddBoxAndBoxBooleanTest() { RayTracer.BoxShape box1 = new RayTracer.BoxShape(new Vector3(.5, .5, .5), new Vector3(1.5, 1.5, 1.5), new RayTracer.SolidMaterial(RGBA_Floats.Green, .01, 0.0, 2.0)); List<RayTracer.IRayTraceable> subtractShapes = new List<RayTracer.IRayTraceable>(); RayTracer.SolidMaterial material = new RayTracer.SolidMaterial(RGBA_Floats.Red, 0, 0, 0); subtractShapes.Add(new BoxShape(new Vector3(), new Vector3(1, 1, 1), material)); RayTracer.IRayTraceable subtractGroup = RayTracer.BoundingVolumeHierarchy.CreateNewHierachy(subtractShapes); Difference merge = new Difference(box1, subtractGroup); renderCollection.Add(merge); }
private void AddBoxAndSheresBooleanTest() { RayTracer.BoxShape box1 = new RayTracer.BoxShape(new Vector3(.5, .5, .5), new Vector3(1.5, 1.5, 1.5), new RayTracer.SolidMaterial(RGBA_Floats.Green, 0, 0, 0));//.01, 0.0, 2.0)); List<RayTracer.IRayTraceable> subtractShapes = new List<RayTracer.IRayTraceable>(); RayTracer.SolidMaterial material = new RayTracer.SolidMaterial(RGBA_Floats.Red, 0, 0, 0); #if true // two big spheres. Looks good. subtractShapes.Add(new RayTracer.SphereShape(new Vector3(.5, .5, 1), .6, material)); subtractShapes.Add(new RayTracer.SphereShape(new Vector3(1.5, .5, 1), .6, material)); Transform cylinder = new Transform(new RayTracer.CylinderShape(.1, 3, material)); cylinder.MoveToAbsolute(1, 1, 1); cylinder.RotateRelative(.1, .6, .6); //subtractShapes.Add(cylinder); //renderCollection.Add(cylinder); #else for (int z = 0; z < 6; z++) { for (int y = 0; y < 6; y++) { for (int x = 0; x < 6; x++) { subtractShapes.Add(new SphereShape(new Vector3(x * .2 + .5, y * .2 + .5, z * .2 + .5), .1, material)); //subtractShapes.Add(new SphereShape(new Vector3(x * .2 + .5, y * .2 + .5, z * .2 + .5), .13, material)); } } } #endif IRayTraceable subtractGroup = BoundingVolumeHierarchy.CreateNewHierachy(subtractShapes); Difference merge = new Difference(box1, subtractGroup); renderCollection.Add(merge); }
public BaseShape() { position = new Vector(0, 0, 0); Material = new SolidMaterial(new Color(1, 0, 1), 0, 0, 0); }