本文整理匯總了Java中javax.media.opengl.GL2.glRotatef方法的典型用法代碼示例。如果您正苦於以下問題:Java GL2.glRotatef方法的具體用法?Java GL2.glRotatef怎麽用?Java GL2.glRotatef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL2
的用法示例。
在下文中一共展示了GL2.glRotatef方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawCylinder
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCylinder(Vector3f from, Vector3f to, GL2 gl, GLUT glut) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector.length();
vector.normalize();
float angle = zAxis.angle(vector);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector);
float convert = (float) (180f / Math.PI);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(info.getPointSize() / 4.5, length - info.getPointSize(), 20, 20);
gl.glPopMatrix();
}
示例2: drawCylinder
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawCylinder(GLUT glut, GL2 gl, Vector3f from, Vector3f to) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector1 = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector1.length();
vector1.normalize();
float angle = zAxis.angle(vector1);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector1);
float convert = (float) (180f / Math.PI);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(0.5f, length - 0.5f, 20, 5);
//glut.glutSolidCylinder(0.5f, 10, 20, 5);
gl.glPopMatrix();
}
示例3: drawArrow
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void drawArrow(Vector3f from, Vector3f to, float[] color, GL2 gl, GLUT glut) {
Vector3f zAxis = new Vector3f(0, 0, 1);
Vector3f vector = new Vector3f(to.x - from.x, to.y - from.y, to.z - from.z);
float length = vector.length();
vector.normalize();
float angle = zAxis.angle(vector);
Vector3f axis = new Vector3f();
axis.cross(zAxis, vector);
float convert = (float) (180f / Math.PI);
gl.glPushAttrib(GL2.GL_LIGHTING_BIT);
gl.glDisable(GL2.GL_TEXTURE_2D);
gl.glEnable(GL2.GL_LIGHTING);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, color, 0);
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, color, 0);
gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 10);
gl.glPushMatrix();
gl.glTranslatef(from.x, from.y, from.z);
gl.glRotatef(angle * convert, axis.x, axis.y, axis.z);
glut.glutSolidCylinder(info.getPointSize() / 3, length - info.getPointSize(), 20, 20);
gl.glTranslatef(0, 0, length - info.getPointSize());
glut.glutSolidCone(info.getPointSize(), info.getPointSize(), 20, 20);
gl.glPopMatrix();
gl.glEnable(GL2.GL_TEXTURE_2D);
gl.glDisable(GL2.GL_LIGHTING);
gl.glPopAttrib();
}
示例4: setupCamera
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void setupCamera(GL2 gl, GLU glu, float x, float y, float z,
int width, int height) {
if(state != null) {
// Change to projection matrix.
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
gl.glViewport(0, 0, width, height);
FloatBoundingBox bbox = state.getOrthogonalBBox();
float glWidth = Math.abs(bbox.getUpperRight().getX()
- bbox.getUpperLeft().getX());
float glHeight = Math.abs(bbox.getUpperRight().getY()
- bbox.getLowerRight().getY());
FloatVector3D glCenter = state.getPosition();
gl.glOrthof(glCenter.getX() - glWidth / 2.0f, glCenter.getX() + glWidth
/ 2.0f, glCenter.getY() - glHeight / 2.0f, glCenter.getY()
+ glHeight / 2.0f, -10000, 10000);
gl.glTranslatef(glCenter.getX(), glCenter.getY(), 0);
gl.glRotatef(state.getRotation().getX(), 1, 0, 0);
gl.glRotatef(state.getRotation().getZ(), 0, 0, 1);
gl.glTranslatef(-glCenter.getX(), -glCenter.getY(), 0);
// Change back to model view matrix.
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
}
示例5: compileFMS
import javax.media.opengl.GL2; //導入方法依賴的package包/類
private void compileFMS(DrawContext dc, float strike, float dip, float rake, float strike2, float dip2, float rake2)
{
GLU glu = dc.getGLU();
//GL gl = dc.getGL();
GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility.
double[] a = {0,0,1, 0};
double[] b = {0,0,-1, 0};
double radius = .95;
int slices = 36;
int stacks = 18;
double[][][] planes
= new double[][][] { {a,a}, {b,a}, {a,b}, {b,b}};
for (int i = 0; i < 4; i++)
{
gl.glNewList(glListId + i, GL2.GL_COMPILE);
gl.glPushMatrix();
gl.glRotatef(strike, 0, 0, -1);
gl.glRotatef(dip, 0, -1, 0);
gl.glClipPlane(GL2.GL_CLIP_PLANE0, planes[i][0], 0);
gl.glPopMatrix();
gl.glPushMatrix();
gl.glRotatef(strike2, 0, 0, -1);
gl.glRotatef(dip2, 0, -1, 0);
gl.glClipPlane(GL2.GL_CLIP_PLANE1, planes[i][1], 0);
gl.glPopMatrix();
gl.glEnable(GL2.GL_CLIP_PLANE0);
gl.glEnable(GL2.GL_CLIP_PLANE1);
glu.gluSphere(quadric, radius, slices, stacks);
gl.glDisable(GL2.GL_CLIP_PLANE0);
gl.glDisable(GL2.GL_CLIP_PLANE1);
gl.glEndList();
}
}
示例6: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0) {
return;
}
assert (initialized_context_ != null);
final float[] vertex_data = {
//tu, tv, x, y, z
0.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, -1.0f, 1.0f, 0.0f };
FloatBuffer vertices = FloatBuffer.wrap(vertex_data);
gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);
gl2.glMatrixMode(gl2.GL_MODELVIEW);
gl2.glLoadIdentity();
// Match GL units to screen coordinates.
gl2.glViewport(0, 0, view_width_, view_height_);
gl2.glMatrixMode(gl2.GL_PROJECTION);
gl2.glLoadIdentity();
// Draw the background gradient.
gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
gl2.glBegin(gl2.GL_QUADS);
gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // red
gl2.glVertex2f(-1.0f, -1.0f);
gl2.glVertex2f(1.0f, -1.0f);
gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // blue
gl2.glVertex2f(1.0f, 1.0f);
gl2.glVertex2f(-1.0f, 1.0f);
gl2.glEnd();
gl2.glPopAttrib();
// Rotate the view based on the mouse spin.
if (spin_x_ != 0) {
gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
}
if (spin_y_ != 0) {
gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
}
if (transparent_) {
// Alpha blending style. Texture values have premultiplied alpha.
gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending.
gl2.glEnable(gl2.GL_BLEND);
}
// Enable 2D textures.
gl2.glEnable(gl2.GL_TEXTURE_2D);
// Draw the facets with the texture.
assert (texture_id_[0] != 0);
gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);
// Disable 2D textures.
gl2.glDisable(gl2.GL_TEXTURE_2D);
if (transparent_) {
// Disable alpha blending.
gl2.glDisable(gl2.GL_BLEND);
}
}
示例7: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
protected void render(GL2 gl2) {
if (use_draw_pixels_ || view_width_ == 0 || view_height_ == 0)
return;
assert(initialized_context_ != null);
final float[] vertex_data = {
//tu, tv, x, y, z
0.0f, 1.0f, -1.0f, -1.0f, 0.0f,
1.0f, 1.0f, 1.0f, -1.0f, 0.0f,
1.0f, 0.0f, 1.0f, 1.0f, 0.0f,
0.0f, 0.0f, -1.0f, 1.0f, 0.0f
};
FloatBuffer vertices = FloatBuffer.wrap(vertex_data);
gl2.glClear(gl2.GL_COLOR_BUFFER_BIT | gl2.GL_DEPTH_BUFFER_BIT);
gl2.glMatrixMode(gl2.GL_MODELVIEW);
gl2.glLoadIdentity();
// Match GL units to screen coordinates.
gl2.glViewport(0, 0, view_width_, view_height_);
gl2.glMatrixMode(gl2.GL_PROJECTION);
gl2.glLoadIdentity();
gl2.glOrtho(0, 0, view_width_, view_height_, 0.1, 100.0);
// Draw the background gradient.
gl2.glPushAttrib(gl2.GL_ALL_ATTRIB_BITS);
gl2.glBegin(gl2.GL_QUADS);
gl2.glColor4f(1.0f, 0.0f, 0.0f, 1.0f); // red
gl2.glVertex2f(-1.0f, -1.0f);
gl2.glVertex2f(1.0f, -1.0f);
gl2.glColor4f(0.0f, 0.0f, 1.0f, 1.0f); // blue
gl2.glVertex2f(1.0f, 1.0f);
gl2.glVertex2f(-1.0f, 1.0f);
gl2.glEnd();
gl2.glPopAttrib();
// Rotate the view based on the mouse spin.
if (spin_x_ != 0)
gl2.glRotatef(-spin_x_, 1.0f, 0.0f, 0.0f);
if (spin_y_ != 0)
gl2.glRotatef(-spin_y_, 0.0f, 1.0f, 0.0f);
if (transparent_) {
// Alpha blending style. Texture values have premultiplied alpha.
gl2.glBlendFunc(gl2.GL_ONE, gl2.GL_ONE_MINUS_SRC_ALPHA);
// Enable alpha blending.
gl2.glEnable(gl2.GL_BLEND);
}
// Enable 2D textures.
gl2.glEnable(gl2.GL_TEXTURE_2D);
// Draw the facets with the texture.
assert(texture_id_[0] != 0);
gl2.glBindTexture(gl2.GL_TEXTURE_2D, texture_id_[0]);
gl2.glInterleavedArrays(gl2.GL_T2F_V3F, 0, vertices);
gl2.glDrawArrays(gl2.GL_QUADS, 0, 4);
// Disable 2D textures.
gl2.glDisable(gl2.GL_TEXTURE_2D);
if (transparent_) {
// Disable alpha blending.
gl2.glDisable(gl2.GL_BLEND);
}
}
示例8: render
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void render(GL2 gl) {
// Create the credits texture if not done yet:
if(creditsTexture == null) {
createTexture();
}
if(creditsTexture != null) {
// Activate alpha:
gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_SRC_ALPHA, GL2.GL_ONE_MINUS_SRC_ALPHA);
// Bind the texture for use:
creditsTexture.bind(gl);
// The textures 2D-coordinates:
TextureCoords texCoords = creditsTexture.getImageTexCoords();
// Backup current matrix:
gl.glPushMatrix();
gl.glLoadIdentity();
// Apply transformation:
gl.glRotatef(rotation, 1, 0, 0);
gl.glTranslatef(0, -2, position);
gl.glRotatef(-90, 1, 0, 0);
// Draw vertices and pass uv-coords.
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(texCoords.right(), texCoords.top());
gl.glVertex3f(CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.left(), texCoords.top());
gl.glVertex3f(-CREDITS_PANE_WIDTH/2, CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.left(), texCoords.bottom());
gl.glVertex3f(-CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
gl.glTexCoord2f(texCoords.right(), texCoords.bottom());
gl.glVertex3f(CREDITS_PANE_WIDTH/2, -CREDITS_PANE_HEIGHT/2, 0);
gl.glEnd();
// Restore matrix:
gl.glPopMatrix();
}
}
示例9: draw
import javax.media.opengl.GL2; //導入方法依賴的package包/類
@Override
public void draw(GL2 gl) {
boolean lastFrame2D = wasLastFrame2D();
super.draw(gl);
// Clear the color-buffer to white:
gl.glClearColor(0x0, 0x0, 0x0, 0);
gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
this.setCamera(gl, this.glu, this.width, this.height);
// this.setLights(gl);
gl.glLoadIdentity();
if(state.is2DMode() != lastFrame2D) {
oldRotation = new FloatVector3D(0, 0, 0);
System.arraycopy(IDENTITY, 0, modelViewMatrix, 0, IDENTITY.length);
gl.glRotatef(-90, 1, 0, 0);
gl.glMultMatrixf(modelViewMatrix, 0);
gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);
gl.glLoadIdentity();
}
FloatVector3D relativeRotation = new FloatVector3D(oldRotation);
relativeRotation.sub(state.getRotation());
// rotate the globe
gl.glRotatef(relativeRotation.getX(), 1, 0, 0);
gl.glRotatef(relativeRotation.getY(), 0, 1, 0);
// compute 'old' rotation
gl.glMultMatrixf(modelViewMatrix, 0);
// reset the rotations
oldRotation = new FloatVector3D(state.getRotation());
// store the current rotation in the GL-state
gl.glGetFloatv(GL2.GL_MODELVIEW_MATRIX, modelViewMatrix, 0);
this.drawEarth(gl);
}
示例10: interact
import javax.media.opengl.GL2; //導入方法依賴的package包/類
public void interact(GL2 gl) {
gl.glTranslatef(0, 0, z);
gl.glRotatef(rotx, 1f, 0f, 0f);
gl.glRotatef(roty, 0f, 1.0f, 0f);
}
示例11: rotateAround
import javax.media.opengl.GL2; //導入方法依賴的package包/類
/**
*
* @param openGl
*/
public void rotateAround(final GL2 openGl) {
openGl.glRotatef((float) rotation, point[0], point[1], point[2]);
}