00001 package edu.tum.cs.vis.model.util; 00002 00003 import javax.vecmath.Point2f; 00004 import javax.vecmath.Point3f; 00005 00006 import processing.core.PApplet; 00007 import processing.core.PConstants; 00008 00015 public class Triangle extends DrawObject { 00016 00020 public Point2f texPosition[]; 00021 00025 public Appearance appearance; 00026 00030 public Triangle() { 00031 position = new Point3f[3]; 00032 } 00033 00038 public void draw(PApplet applet) 00039 { 00040 if (!appearance.containsTexture) 00041 { 00042 applet.fill(appearance.colour.red * 255, 00043 appearance.colour.green * 255, 00044 appearance.colour.blue * 255, 00045 appearance.colour.transparency * 255); 00046 applet.beginShape(PConstants.TRIANGLES); 00047 00048 applet.vertex(position[0].x, position[0].y, position[0].z); 00049 applet.vertex(position[1].x, position[1].y, position[1].z); 00050 applet.vertex(position[2].x, position[2].y, position[2].z); 00051 00052 applet.endShape(); 00053 00054 } else 00055 { 00056 applet.beginShape(PConstants.TRIANGLES); 00057 applet.texture(appearance.imageReference); 00058 00059 applet.vertex(position[0].x, position[0].y, position[0].z, 00060 texPosition[0].x, texPosition[0].y); 00061 applet.vertex(position[1].x, position[1].y, position[1].z, 00062 texPosition[1].x, texPosition[1].y); 00063 applet.vertex(position[2].x, position[2].y, position[2].z, 00064 texPosition[2].x, texPosition[2].y); 00065 00066 applet.endShape(); 00067 00068 } 00069 } 00070 }