private RTree<T> triangles = new RTree<T>();
private PointSet<Vertex> vertices = new PointSet<Vertex>();
+ public boolean option_wireframe = false;
+ public boolean option_errorNormals = false;
+ public boolean option_selectable = true;
+
+ public void render(GL gl, Matrix m) {
+ if (option_wireframe) {
+ gl.glDisable(GL.GL_LIGHTING);
+ gl.glBegin(GL.GL_LINES);
+ gl.glColor3f(1, 1, 1);
+ for (T t : this) {
+ m.times(t.e1().p1.goodp).glVertex(gl);
+ m.times(t.e1().p2.goodp).glVertex(gl);
+ m.times(t.e2().p1.goodp).glVertex(gl);
+ m.times(t.e2().p2.goodp).glVertex(gl);
+ m.times(t.e3().p1.goodp).glVertex(gl);
+ m.times(t.e3().p2.goodp).glVertex(gl);
+ }
+ gl.glEnd();
+ gl.glEnable(GL.GL_LIGHTING);
+ return;
+ }
+ for(T t : this) {
+ gl.glColor4f((float)(0.25+(0.05*t.color)),
+ (float)(0.25+(0.05*t.color)),
+ (float)(0.75+(0.05*t.color)),
+ (float)0.3);
+ t.glTriangle(gl, m);
+ }
+ if (option_errorNormals)
+ for(T t : this)
+ for(Mesh.Vertex p : new Mesh.Vertex[] { t.v1(), t.v2(), t.v3() }) {
+ if (p.ok) {
+ gl.glBegin(GL.GL_LINES);
+ gl.glColor3f(1, 1, 1);
+ p.p.glVertex(gl);
+ p.p.plus(p.norm().times((float)p.error()*10)).glVertex(gl);
+ gl.glEnd();
+ }
+ }
+ }
+
public boolean immutableVertices;
public Mesh error_against = null;
public double error = 0;
error += olderror;
}
+ /*
+ public Vertex hack(GL gl, Point mouse) {
+ double dist = Double.MAX_VALUE;
+ Vertex cur = null;
+ for(E e = this.e; e!=null; e=e.pair.next==this.e?null:e.pair.next) {
+ Vertex v = e.getOther(this);
+ double dist2 = v.getPoint().glProject(gl).distance(mouse);
+ if ((cur==null || dist2 < dist) && v.visible) {
+ dist = dist2;
+ cur = v;
+ }
+ }
+ return cur;
+ }
+ */
+
public float averageTriangleArea() {
int count = 0;
float ret = 0;
setError(nerror);
}
- public boolean move(Matrix m, boolean ignoreProblems) {
+ public boolean move(Vec vv, boolean ignoreProblems) {
boolean good = true;
// M * t1 = M * t1.getMatrix(t2) * t2
if (bindingGroup!=null && this != bindingGroup.getMaster()) {
- Matrix v = getBindingMatrix(bindingGroup.getMaster());
- return ((Vertex)bindingGroup.getMaster()).move(v.inverse().times(m).times(v), ignoreProblems);
+ Matrix m2 = getBindingMatrix(bindingGroup.getMaster());
+ Vec v2 = m2.times(vv.plus(getPoint())).minus(m2.times(getPoint()));
+ return ((Vertex)bindingGroup.getMaster()).move(v2, ignoreProblems);
}
+ Point op = this.p;
+ Point pp = vv.plus(getPoint());
if (bindingGroup != null) {
- Matrix m2 = null;
- for(int i=0; i<20 && !m.equals(m2); i++) {
- m2 = m.times(getConstraint());
+ /*
+ for(int i=0; i<20 ; i++) {
+ Point p2 = getConstraint().times(pp);
+ pp = pp.midpoint(p2);
//System.out.println(m.minus(m2));
}
- if (!m.equals(m2)) return true;
+ */
+ pp = getConstraint().times(pp);
}
+ pp = pp.minus(op).norm().times(vv.mag()).plus(op);
ok = false;
- Point op = this.p;
- Point pt = m.times(this.p);
+ Point pt = pp;
for(Vertex v : (Iterable<Vertex>)getBoundPeers()) {
Point pt2 = v.getBindingMatrix(this).times(pt);
/*
unApplyQuadricToNeighbor();
-
boolean illegalbefore = illegal;
illegal = false;
/*
return !illegal;
}
+ public E getEdge() { return e; }
public E getFreeIncident() {
E ret = getFreeIncident(e, e);
if (ret != null) return ret;
public boolean intersects(T t) { return t.intersects(p1.p, p2.p); }
+ public Segment getSegment() { return new Segment(p1.getPoint(), p2.getPoint()); }
+
public void bindingGroupChanged(edu.berkeley.qfat.geom.BindingGroup newBindingGroup_) {
edu.berkeley.qfat.geom.BindingGroup<E> newBindingGroup =
return Math.acos(v1.norm().dot(v2.norm()));
}
+ public Vertex getOther(Vertex v) {
+ if (this.p1 == v) return p2;
+ if (this.p2 == v) return p1;
+ throw new Error();
+ }
+
public void makeAdjacent(E e) {
if (this.next == e) return;
if (p2 != e.p1) throw new Error("cannot make adjacent -- no shared vertex");