Exemple #1
0
 private void setSliderValue(double val)
 {
     this.toRender = this.modelClone.Clone();
     var faceToExtrude = this.toRender.Faces.First();
     this.toRender.RemoveFace(faceToExtrude);
     Vec3 normal = faceToExtrude.GetNormal();
     List<Vec3> newPositions = new List<Vec3>();
     List<int> newIndices = new List<int>();
     foreach (var v in faceToExtrude.GetVertexPositions()) {
         var newVertex = v + normal * val;
         newPositions.Add(newVertex);
         var idx = this.toRender.AddVertex(newVertex);
         newIndices.Add(idx);
     }
     this.toRender.AddFace(newIndices.ToArray());
     var indices = faceToExtrude.GetVertexIndices();
     int ct = newIndices.Count;
     for (int i = 0; i < ct; i++) {
         var a1 = newIndices[i];
         var a2 = newIndices[(i + 1) % ct];
         var b1 = indices[i];
         var b2 = indices[(i + 1) % ct];
         this.toRender.AddFace(a1, a2, b1, b2);
     }
 }
Exemple #2
0
 public ExtrudeState(Model m, FullScene scene)
 {
     this.modelClone = m.Clone();
     var s = new Slider() {
         Minimum = -100,
         Maximum = 100,
         Value = 0,
         Orientation = Orientation.Vertical
     };
     s.ValueChanged += s_ValueChanged;
     this.Widgets.Add(s);
 }
Exemple #3
0
        public Face(List<int> vertices, Model m)
        {
            this.vertices = vertices;
            this.model = m;

            Dictionary<Vec3, int> mapping = new Dictionary<Vec3, int>();
            for (int i = 0; i < vertices.Count; i++) {
                int idx = vertices[i];
                mapping[this.getVertexPosition(idx)] = idx;
            }
            var ordered = LinearAlgebra.OrderVertices(this.GetVertexPositions());
            ordered.Reverse();
            this.vertices = ordered.Select(i => mapping[i]).ToList();
        }
Exemple #4
0
 private void setSliderValue(double val)
 {
     this.toRender = this.modelClone.Clone();
     this.faceToElevate = this.toRender.Faces.First();
     this.faceCenter = this.toRender.GetFaceCenter(this.faceToElevate);
     this.toRender.RemoveFace(this.faceToElevate);
     Vec3 newVertex = this.faceCenter.Extend(val);
     var faceVertexIndices = this.faceToElevate.GetVertexIndices();
     int ct = faceVertexIndices.Count;
     for (int i = 0; i < ct; i++) {
         int idx1 = faceVertexIndices[i];
         int idx2 = faceVertexIndices[(i + 1) % ct];
         int vIndex = this.toRender.AddVertex(newVertex);
         this.toRender.AddFace(idx1, idx2, vIndex);
         this.toRender.AddFace(vIndex, idx2, idx1);
     }
     //Get the center of the face
     //Determine the new vertex position
     //Add n new triangular faces
     //remove the old face
 }
Exemple #5
0
 public LightingState(Model model, FullScene scene)
 {
     this.model = model;
     this.scene = scene;
     this.addWidgets();
 }
Exemple #6
0
 public static Model ConstructFromVerticesAndIndices(List<Vec3> vertices, params List<int>[] indices)
 {
     Model toReturn = new Model();
     toReturn.vertices = vertices;
     foreach (var faceSet in indices) {
         var newFace = new Face(faceSet, toReturn);
         toReturn.faces.Add(newFace);
         for (int i = 0; i < faceSet.Count; i++) {
             var idx1 = i;
             var idx2 = (i + 1) % faceSet.Count;
             var e = new Edge(idx1, idx2);
             toReturn.edges.Add(e);
             toReturn.addEdgeVert(e, i);
             toReturn.addFaceVert(newFace, i);
         }
     }
     return toReturn;
 }
Exemple #7
0
 public Model Clone()
 {
     Model toReturn = new Model();
     toReturn.vertices = this.vertices.Select(i => i.Clone()).ToList();
     toReturn.vertexToEdge = this.vertexToEdge.ToDictionary(i => i.Key, i => i.Value.Select(j => j.Clone()).ToList());
     toReturn.vertexToFace = this.vertexToFace.ToDictionary(i => i.Key, i => i.Value.Select(j => j.Clone()).ToList());
     toReturn.edges = new ListHash<Edge>(this.edges.ToList());
     toReturn.faces = this.faces.Select(i => i.Clone()).ToList();
     return toReturn;
 }
Exemple #8
0
 public static Model ConstructFromFaces(List<Face> faces)
 {
     Model toReturn = new Model();
     toReturn.faces = faces;
     foreach (var f in faces) {
         var edges = f.GetEdges();
         edges.ForEach(e => toReturn.AddEdge(e));
     }
     return toReturn;
 }
Exemple #9
0
        public void Add(Model model)
        {
            this.mesh = new MeshGeometry3D();
            this.mesh.Positions = new Point3DCollection(model.Vertices.Select(i => new Point3D(i.X, i.Y, i.Z)));
            this.mesh.TriangleIndices = new Int32Collection(model.FaceTriangleIndices);
            this.geometry = new GeometryModel3D();
            this.geometry.Geometry = this.mesh;
            this.modelGroup.Children.Add(this.geometry);

            var m1 = new DiffuseMaterial(Brushes.Red);
            MaterialGroup material = new MaterialGroup();
            material.Children.Add(m1);

            geometry.Material = material;
            geometry.BackMaterial = material;
        }
Exemple #10
0
 public void DrawModel(Model model)
 {
     this.modelGroup.Children.Remove(this.geometry);
     this.Add(model);
     this.setRotation();
 }
Exemple #11
0
 public ViewerState(Model model)
 {
     this.model = model;
 }
 public FaceSelectionState(Model model)
 {
     this.model = model;
 }