/* (non-Javadoc)
* @see org.mt4j.components.visibleComponents.AbstractVisibleComponent#drawComponent(processing.core.PGraphics)
*/
@Override
public void drawComponent(PGraphics g) {
PApplet pa = this.getRenderer();
if (this.isUseDirectGL()){
GL gl=((PGraphicsOpenGL)g).beginGL();
this.drawComponent(gl);
((PGraphicsOpenGL)this.getRenderer().g).endGL();
}else{ //Draw with pure proccessing...
pa.strokeWeight(this.getStrokeWeight());
// if (ConstantsAndSettings.getInstance().isOpenGlMode()){
if (this.isDrawSmooth())
pa.smooth();
else
pa.noSmooth();
// }
//NOTE: if noFill() and noStroke()->absolutely nothing will be drawn-even when texture is set
if (this.isNoFill())
pa.noFill();
else{
MTColor fillColor = this.getFillColor();
pa.fill(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha());
}
if (this.isNoStroke())
pa.noStroke();
else{
MTColor strokeColor = this.getStrokeColor();
pa.stroke(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha());
}
//Set the tint values
MTColor fillColor = this.getFillColor();
pa.tint(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha());
//handles the drawing of the vertices with the texture coordinates
//try doing a smoothed poly outline with opengl
// if (
//// ConstantsAndSettings.getInstance().isOpenGlMode() &&
// this.isDrawSmooth() &&
// !this.isNoStroke()
// ){
// pa.noStroke();
// pa.noSmooth();
//
// //draw insided of polygon, without smooth or stroke
// this.drawWithProcessing(pa, this.getVerticesObjSpace(), PApplet.TRIANGLES, true);
//
// pa.smooth();
// pa.noFill();
// pa.stroke(this.getStrokeRed(), this.getStrokeGreen(), this.getStrokeBlue(), this.getStrokeAlpha());
//
// // DRAW SMOOTHED THE OUTLINE SHAPE OF THE POLYGON WIHTOUT FILL OR TEXTURE
//// drawWithProcessing(pa);
//
// for (Vertex[] outline : this.outlineContours){
// this.drawWithProcessing(pa, outline, PApplet.LINE, false);
// }
// }else{
if (!this.isNoStroke()){
pa.noFill();
MTColor strokeColor = this.getStrokeColor();
pa.stroke(strokeColor.getR(), strokeColor.getG(), strokeColor.getB(), strokeColor.getAlpha());
pa.strokeWeight(2);
if (this.isDrawSmooth())
pa.smooth();
for (Vertex[] outline : this.outlineContours){
this.drawWithProcessing(pa, outline, PApplet.POLYGON, false);
}
}
if (!this.isNoFill()){
pa.noStroke();
pa.noSmooth();
pa.fill(fillColor.getR(), fillColor.getG(), fillColor.getB(), fillColor.getAlpha());
this.drawWithProcessing(pa, this.getVerticesLocal(), PApplet.TRIANGLES, true);
}
// }//end if gl and smooth
//reSet the tint values to defaults
pa.tint(255, 255, 255, 255);
if (/*ConstantsAndSettings.getInstance().isOpenGlMode() && */
this.isDrawSmooth())
pa.noSmooth(); //because of tesselation bug
}
if (drawNormals)
this.drawNormals();
}