我想在自己的類中繪製一個多邊形作爲自己的對象,而不是顯示方法的一部分。我對此沒有多少發現,希望有人能幫助我。jogl,多邊形作爲自己的對象/類
public PolygonalGameObject(GameObject parent, double points[],
double[] fillColour, double[] lineColour) {
super(parent);
myPoints = points;
myFillColour = fillColour;
myLineColour = lineColour;
}
public void drawSelf(GL2 gl) {
// TODO: Write this method
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glBegin(GL2.GL_POLYGON);{
for (int i = 0; i < myPoints.length; i += 2) {
double x = myPoints[i];
double y = myPoints[i + 1];
gl.glVertex2d(x, y);
}
}gl.glEnd();
}
一個遊戲物體包含在場景圖/樹
我在這(編程和圖形)相當新的,所以如果有人得到了一些很好的教程,請張貼那麼幾個polygonalGameObjects!
非常感謝!