00001 package edu.tum.cs.ias.knowrob.vis.items;
00002
00003 import javax.vecmath.Matrix4d;
00004 import javax.vecmath.Vector3d;
00005
00006 import edu.tum.cs.ias.knowrob.vis.Canvas;
00007
00011 public abstract class Item extends ItemBase {
00012
00013 Item(Matrix4d pose, Vector3d dim){
00014 if(pose!=null) {
00015 this.trafoMatrix = new float[] {
00016 (float) pose.m00, (float) pose.m01, (float) pose.m02, (float) pose.m03,
00017 (float) pose.m10, (float) pose.m11, (float) pose.m12, (float) pose.m13,
00018 (float) pose.m20, (float) pose.m21, (float) pose.m22, (float) pose.m23,
00019 (float) pose.m30, (float) pose.m31, (float) pose.m32, (float) pose.m33 };
00020 }
00021 if(dim!=null) {
00022 this.xdim=(float) dim.x;
00023 this.ydim=(float) dim.y;
00024 this.zdim=(float) dim.z;
00025 }
00026 this.color=defaultColor;
00027 }
00028
00029
00030 public Item(float m00,float m01,float m02,float m03,
00031 float m10,float m11,float m12,float m13,
00032 float m20,float m21,float m22,float m23,
00033 float m30,float m31,float m32,float m33,
00034 float xdim, float ydim, float zdim){
00035
00036 this.trafoMatrix = new float[] {
00037 m00, m01, m02, m03,
00038 m10, m11, m12, m13,
00039 m20, m21, m22, m23,
00040 m30, m31, m32, m33 };
00041 this.xdim=xdim;
00042 this.ydim=ydim;
00043 this.zdim=zdim;
00044
00045 this.color=defaultColor;
00046 }
00047
00048
00049 public Item(float m00,float m01,float m02,float m03,
00050 float m10,float m11,float m12,float m13,
00051 float m20,float m21,float m22,float m23,
00052 float m30,float m31,float m32,float m33,
00053 float xdim, float ydim, float zdim, int color){
00054
00055 this( m00, m01, m02, m03,
00056 m10, m11, m12, m13,
00057 m20, m21, m22, m23,
00058 m30, m31, m32, m33,
00059 xdim, ydim, zdim);
00060
00061 this.color=color;
00062 }
00063
00064
00065
00066 @Override
00067 public void draw(Canvas c) {
00068
00069 c.noStroke();
00070 c.pushMatrix();
00071
00072 if(trafoMatrix != null)
00073 c.applyMatrix(trafoMatrix[0], trafoMatrix[1], trafoMatrix[2], trafoMatrix[3],
00074 trafoMatrix[4], trafoMatrix[5], trafoMatrix[6], trafoMatrix[7],
00075 trafoMatrix[8], trafoMatrix[9], trafoMatrix[10], trafoMatrix[11],
00076 trafoMatrix[12], trafoMatrix[13], trafoMatrix[14], trafoMatrix[15]);
00077 if (drawSettings != null && drawSettings.getOverrideColor() != null)
00078 c.fill(drawSettings.getOverrideColor().getRed(), drawSettings.getOverrideColor().getGreen(), drawSettings.getOverrideColor().getBlue(), drawSettings.getOverrideColor().getAlpha());
00079 else
00080 c.fill(color);
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091 drawIt(c);
00092
00093 c.popMatrix();
00094 }
00095
00096
00097 public void draw(Canvas c, int step) {
00098 draw(c);
00099 }
00100
00101
00102 protected abstract void drawIt(Canvas c);
00103 }