/* Copyright 2010, 2012 Christian Matt
*
* This file is part of PonkOut.
*
* PonkOut is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PonkOut is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PonkOut. If not, see <http://www.gnu.org/licenses/>.
*/
package ponkOut.Menu;
import org.lwjgl.opengl.GL11;
import org.lwjgl.util.glu.Cylinder;
import org.lwjgl.util.glu.Sphere;
import org.lwjgl.util.vector.Vector3f;
import ponkOut.graphics.GraphicsObjectsManager;
import ponkOut.graphics.Lighting;
import ponkOut.graphics.PaddleGO;
public class PaddleSpinner extends Spinner {
private float length;
private float size;
private Vector3f position;
private float rotX;
private float rotY;
private float rotZ;
private boolean hCenter;
private boolean vCenter;
private Cylinder cylinder;
private Sphere sphere;
public PaddleSpinner(int length, float size, Vector3f position, float rotX, float rotY, float rotZ, Place place,
boolean hCenter, boolean vCenter, boolean enabled, SpinnerMediator mediator, MenuState menu,
GraphicsObjectsManager goManager) {
super(length, size, position, rotX, rotY, rotZ, place, hCenter, vCenter, enabled, mediator, menu, goManager);
this.length = length;
this.size = size;
this.position = new Vector3f(position);
this.rotX = rotX;
this.rotY = rotY;
this.rotZ = rotZ;
this.hCenter = hCenter;
this.vCenter = vCenter;
cylinder = new Cylinder();
sphere = new Sphere();
}
@Override
public void draw() {
// store current transformation matrix
GL11.glPushMatrix();
// translate to text position
GL11.glTranslatef(position.x, position.y, position.z);
// rotate
GL11.glRotatef(rotZ, 0.0f, 0.0f, 1.0f);
GL11.glRotatef(rotY, 0.0f, 1.0f, 0.0f);
GL11.glRotatef(rotX, 1.0f, 0.0f, 0.0f);
Lighting.enable(false);
// set color
PaddleGO.getMaterial(getValue()).use();
// draw it
GL11.glTranslatef(hCenter ? -size * length / 2.0f : size * length / 2.0f, vCenter ? 0.0f : -getHeight() / 2.0f,
0.0f);
GL11.glRotatef(90.0f, 0.0f, 1.0f, 0.0f);
float radius = size / 4.0f;
cylinder.draw(radius, radius, size * length, 8, 1);
sphere.draw(radius, 8, 8);
GL11.glTranslatef(0.0f, 0.0f, size * length);
sphere.draw(radius, 8, 8);
Lighting.disable();
// restore transformation matrix
GL11.glPopMatrix();
}
}