public Axis(float[] Begin, float[] End,Vector3 Position, float radius, int slices, int stacks, Device dev) { shapes = new SimpleShape[2]; float[] middlePoint = new float[Begin.Length]; for (int i=0;i<Begin.Length;i++) { middlePoint[i] = 0.8f*End[i]+0.2f*Begin[i]; } shapes[0] = new Cylinder(Begin, middlePoint, radius, radius, slices, stacks, dev); shapes[1] = new Cylinder(middlePoint, End, 1.6f*radius, 0.0f, slices, stacks, dev); for (int i = 0; i < shapes.Length; i++) shapes[i].MovingMatrix *= Matrix.Translation(Position); }
public Hypercube(Color SphereColor, Color CylinderColor, Device dev) { device = dev; spheres = new LinkedList<Sphere>(); cylinders = new LinkedList<Cylinder>(); cubants = new LinkedList<string>(); cubantColors = new LinkedList<Color>(); squares = new LinkedList<Square>(); BasisElements = new int[Basis.Length][]; for (int i = 0; i < BasisElements.Length; i++) { BasisElements[i] = new int[Basis.Length]; for (int j = 0; j < BasisElements[i].Length; j++) if (i != j) BasisElements[i][j] = 0; else BasisElements[i][j] = 1; } int[] nullcoord = CoordinatesActions.getNullIntCoord(Basis.Length); Sphere first = new Sphere(nullcoord, Constants.SphereRadius, Constants.SphereSlices, Constants.SphereStacks, dev); first.paint(SphereColor); spheres.AddLast(first); for (int i = 0; i < Basis.Length; i++) { LinkedList<Sphere> newSpheres = new LinkedList<Sphere>(); LinkedList<Cylinder> newCylinders = new LinkedList<Cylinder>(); foreach(Sphere s in spheres) { Sphere newsphere = new Sphere(CoordinatesActions.add(s.position, BasisElements[i]), Constants.SphereRadius, Constants.SphereSlices, Constants.SphereStacks, device); newsphere.paint(SphereColor); newSpheres.AddLast(newsphere); Cylinder newcylinder = new Cylinder(s.position, CoordinatesActions.add(s.position, BasisElements[i]), Constants.CylinderRadius, Constants.CylinderRadius, Constants.CylinderSlices, Constants.CylinderStacks, device); newcylinder.paint(CylinderColor); newCylinders.AddLast(newcylinder); } foreach(Cylinder c in cylinders) { Cylinder newCylinder = new Cylinder(CoordinatesActions.add(c.int_coordinates[0], BasisElements[i]), CoordinatesActions.add(c.int_coordinates[1], BasisElements[i]), Constants.CylinderRadius, Constants.CylinderRadius, Constants.CylinderSlices, Constants.CylinderStacks, device); newCylinder.paint(CylinderColor); newCylinders.AddLast(newCylinder); } foreach (Sphere s in newSpheres) spheres.AddLast(s); foreach (Cylinder c in newCylinders) cylinders.AddLast(c); } float[] camerapos = new float[Basis.Length]; if (setCamera) { for (int i = 0; i < camerapos.Length; i++) camerapos[i] = 0.5f; Vector3 cameraposition = CoordinatesActions.getVector(camerapos, Basis); Vector3 tmp1 = new Vector3(-cameraposition.X, cameraposition.Y, -cameraposition.Z); Camera.Position = tmp1; Camera.Target = cameraposition; } setCamera = false; }