本文整理匯總了Java中javax.media.opengl.GL.glRotatef方法的典型用法代碼示例。如果您正苦於以下問題:Java GL.glRotatef方法的具體用法?Java GL.glRotatef怎麽用?Java GL.glRotatef使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.GL
的用法示例。
在下文中一共展示了GL.glRotatef方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testRotation
import javax.media.opengl.GL; //導入方法依賴的package包/類
/**
* test the sketch plane rotation and CSG_Vertex rotation code.
* If things are working correctly, every line should end at
* a point of the same color. (purple lines -> purple points;
* orange lines -> orange/green points).S
* @param gl
*/
public static void testRotation(GL gl){
System.out.println(" ------ GL Rotation Test -------- ");
gl.glLoadIdentity();
gl.glLineWidth(2.0f);
gl.glPointSize(5.0f);
CSG_Vertex v1 = new CSG_Vertex(1.0, 1.0, 0.0);
CSG_Vertex v2 = new CSG_Vertex(2.0, 1.0, 0.0);
CSG_Vertex v3 = new CSG_Vertex(2.0, 2.0, 0.0);
CSG_Vertex v4 = new CSG_Vertex(1.0, 2.0, 0.0);
CSG_Vertex vX = new CSG_Vertex(1.0, 0.0, 0.0);
CSG_Vertex vY = new CSG_Vertex(0.0, 1.0, 0.0);
CSG_Vertex vZ = new CSG_Vertex(0.0, 0.0, 1.0);
vX.drawPointForDebug(gl);
vY.drawPointForDebug(gl);
vZ.drawPointForDebug(gl);
for(double yInc= -0.25; yInc<0.26; yInc+= 0.1){
for(double rot=-3.10; rot<3.14; rot+= 0.1){
CSG_Vertex normal = new CSG_Vertex(Math.sin(rot), yInc, Math.cos(rot)).getUnitLength();
//CSG_Vertex normal = new CSG_Vertex(1.0, 0.0, 0.0);
CSG_Plane plane = new CSG_Plane(normal, 0.0);
SketchPlane sP = new SketchPlane(plane);
//System.out.println("--> normal: " + normal);
Translation3D translation = new Translation3D(0.0, 0.0, 0.0);
Rotation3D rotation = new Rotation3D(sP.getRotationX(), sP.getRotationY(), sP.getRotationZ());
CSG_Face f1 = new CSG_Face(new CSG_Polygon(v1, v2, v3, v4));
CSG_Face f2 = f1.getTranslatedCopy(new CSG_Vertex(-3.0, 0.0, 0.0));
CSG_Face f3 = f1.getTranslatedCopy(new CSG_Vertex(-3.0, -3.0, 0.0));
CSG_Face f4 = f1.getTranslatedCopy(new CSG_Vertex( 0.0, -3.0, 0.0));
gl.glColor3d(rot, 0.5, 0.0);
gl.glPointSize(7.0f);
//vX.getTranslatedRotatedCopy(translation, rotation).glDrawVertex(gl);
//vY.getTranslatedRotatedCopy(translation, rotation).glDrawVertex(gl);
vZ.getTranslatedRotatedCopy(translation, rotation).glDrawVertex(gl);
f1.applyTranslationRotation(translation, rotation);
f2.applyTranslationRotation(translation, rotation);
f3.applyTranslationRotation(translation, rotation);
f4.applyTranslationRotation(translation, rotation);
//f1.glDrawFace(gl); //
//f2.glDrawFace(gl); // uncomment these faces to see how
//f3.glDrawFace(gl); // planar regions are rotated.
//f4.glDrawFace(gl); //
gl.glColor3d(0.8, 0.0, 0.8);
sP.getVar1Axis().glDrawVertex(gl);
plane.drawNormalFromOriginForDegug(gl);
gl.glRotatef((float)(rotation.getXRot()*180.0/Math.PI), 1.0f, 0.0f, 0.0f);
gl.glRotatef((float)(rotation.getYRot()*180.0/Math.PI), 0.0f, 1.0f, 0.0f);
gl.glRotatef((float)(rotation.getZRot()*180.0/Math.PI), 0.0f, 0.0f, 1.0f);
gl.glColor3d(0.9, 0.7, 0.3);
gl.glPointSize(5.0f);
//vZ.glDrawVertex(gl);
gl.glBegin(GL.GL_LINES);
gl.glColor3d(0.9, 0.7, 0.3); // normal
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(vZ.getX(), vZ.getY(), vZ.getZ());
gl.glColor3d(0.9, 0.3, 0.9); // x-axis
gl.glVertex3d(0.0, 0.0, 0.0);
gl.glVertex3d(1.0, 0.0, 0.0);
gl.glEnd();
gl.glLoadIdentity();
gl.glColor3d(0.7, 0.7, 0.7);
}
}
}