本文整理匯總了Java中javax.media.opengl.glu.GLU.gluLookAt方法的典型用法代碼示例。如果您正苦於以下問題:Java GLU.gluLookAt方法的具體用法?Java GLU.gluLookAt怎麽用?Java GLU.gluLookAt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.media.opengl.glu.GLU
的用法示例。
在下文中一共展示了GLU.gluLookAt方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public void init(GLAutoDrawable drawable) {
System.out.println("--init--");
GL2 gl = drawable.getGL().getGL2();
glu = new GLU();
System.out.println("INIT GL IS: " + gl.getClass().getName());
if (!bDoNurbs) {
gl.glMap2f(GL2.GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, ctlarray, 0);
}
gl.glEnable(GL2.GL_MAP2_VERTEX_3);
gl.glEnable(GL2.GL_AUTO_NORMAL);
gl.glMapGrid2f(20, 0.0f, 1.0f, 20, 0.0f, 1.0f);
setupLighting(drawable, gl);
float fovy=40.f;
float aspect=1.f;
float znear=1.f;
float zfar=20f;
glu.gluPerspective(fovy, aspect, znear, zfar);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(cameraLoc.x, cameraLoc.y, cameraLoc.z,
lookAtPt.x, lookAtPt.y, lookAtPt.z,
cameraUpDirection.x, cameraUpDirection.y, cameraUpDirection.z);
}
示例2: setView
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public void setView(GL2 gl, GLU glu, GlobalState gs) {
// Select part of window.
gl.glViewport(0, 0, gs.w, gs.h);
// Set projection matrix.
gl.glMatrixMode(GL_PROJECTION);
//Load the identity matrix.
gl.glLoadIdentity();
glu.gluPerspective(fovAngle, (float) gs.w / gs.h, planeNear, planeFar);
// Set camera.
gl.glMatrixMode(GL_MODELVIEW);
//Load the identity matrix.
gl.glLoadIdentity();
glu.gluLookAt(eye.x(), eye.y(), eye.z(),
center.x(), center.y(), center.z(),
up.x(), up.y(), up.z());
}
示例3: set
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public void set(GL2 g, MapPanel panel) {
int width = panel.getWidth();
int height = panel.getHeight();
GLU glu = GLU.createGLU(g);
g.glViewport(0, 0, width, height);
g.glMatrixMode(GL2.GL_PROJECTION);
g.glLoadIdentity();
float fwidth = width;
float fheight = height;
glu.gluPerspective(70, fwidth / fheight, 0.1f, 600.0f);
g.glMatrixMode(GL2.GL_MODELVIEW);
g.glLoadIdentity();
glu.gluLookAt((float) posx, (float) posy, (float) posz, (float) posx + dirx, (float) posy + diry, (float) posz + dirz, 0, 1, 0);
g.glMultMatrixf(matrix);
}
示例4: setLookAt
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public void setLookAt(GL2 gl, GLU glu){
double moved = 0;
double location[] = ReadZBuffer.getOGLPos(gl, glu, width / 2, height / 2); //what you're moving towards
if (mobile&&eyeX + dx > 0 && eyeZ + dz > 0 && eyeX + dx < 600 && eyeZ + dz < 600 && (eyeX + dx < 300 || eyeZ + dz < 500)) {
if (Math.abs(location[0] - eyeX) > Math.abs(dx) + 1) {
eyeX += dx;
moved += dx;
}//if you have room to move in the x direction, move in the x direction
if (Math.abs(location[2] - eyeZ) > Math.abs(dz) + 1) {
eyeZ += dz;
moved += dz;
}//ditto z
}
gl.glLoadIdentity();
glu.gluLookAt(eyeX, eyeY, eyeZ, // eye location
eyeX + Math.cos(Math.toRadians(theta)) * Math.cos(Math.toRadians(gamma)), eyeY + Math.sin(Math.toRadians(gamma)), eyeZ + -Math.sin(Math.toRadians(theta)) * Math.cos(Math.toRadians(gamma)), // point to look at (near middle of pyramid)
0, 1, 0); // the "up" direction
if (mobile&&(moved != 0 || qdown || edown || idown || kdown || dgamma != 0 || dtheta != 0)) {
notifyObservers();
}
}
示例5: setCamera
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
private void setCamera(GL2 gl, GLU glu, float width, float height) {
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
// float dist = state.getZoom() / 100f;
// perspective
float widthHeightRatio = width / height;
glu.gluPerspective(45, widthHeightRatio, 1, 1000);
glu.gluLookAt(0, 0, CAMERA_DISTANCE, 0, 0, 0, 0, 1, 0);
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例6: init
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
@Override
public void init(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
// Global settings.
gl.glEnable(GL2.GL_DEPTH_TEST);
gl.glDepthFunc(GL2.GL_LEQUAL);
gl.glEnable(GL2.GL_POINT_SMOOTH);
gl.glEnable(GL2.GL_LINE_SMOOTH);
gl.glEnable(GL2.GL_FOG);
gl.glEnable(GL2.GL_DITHER);
gl.glHint(GL2.GL_FOG_HINT, GL2.GL_NICEST);
gl.glColor3d(0, 0, 0);
glut = new GLUT();
// We want a nice perspective.
// Create GLU.
glu = new GLU();
// Change to projection matrix.
gl.glMatrixMode(GL2.GL_PROJECTION);
gl.glLoadIdentity();
// Perspective.
glu.gluPerspective(45, 1, 1, 100);
glu.gluLookAt(2.3, 0.5, 1.8, 0.5, 0.5, 0.5, 0, 1, 0);
// Change back to model view matrix.
gl.glMatrixMode(GL2.GL_MODELVIEW);
gl.glLoadIdentity();
}
示例7: cameraView
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public void cameraView(GL gl, GLU glu)
{
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// glu.gluLookAt(0, 100, 200,
// 0, 0, 0,
// 0, 1, 0);
glu.gluLookAt(0, 100, 100, 0, 0, 0, 0, 1, 0);
}
示例8: display
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
public void display(GLAutoDrawable drawable) {
GL2 gl = drawable.getGL().getGL2();
GLU glu = new GLU();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // Clear
// the
// drawing
// area
if (pick)
startPicking(gl, mousePos.x, mousePos.y);
gl.glLoadIdentity(); // Reset the current matrix to the "identity"
glu.gluLookAt(camera.getPosX(), camera.getPosY(), camera.getPosZ(), camera.getViewX(), camera.getViewY(),
camera.getViewZ(), camera.getUpX(), camera.getUpY(), camera.getUpZ());
if (wireFrame) {
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_LINE);
} else {
gl.glPolygonMode(GL.GL_FRONT, GL2.GL_FILL);
}
gl.glRotatef(270, 1.0f, 0.0f, 0.0f);
if (displayMap) {
renderMap.display(gl);
}
if (displayWater){
renderWater.display(gl);
}
if (displayCars) {
renderCars.display(gl);
}
if (pick) {
stopPicking(gl);
pick = false;
}
if (takeScreen) {
takeScreenshot(gl);
takeScreen = false;
}
updateFPS();
}
示例9: GLDisplay
import javax.media.opengl.glu.GLU; //導入方法依賴的package包/類
private void GLDisplay(GLAutoDrawable glad) {
GL gl = glad.getGL();
if(scene.isUpdating()) {
loadingTextures = true;
ArrayList<String> newTextures = (loader).getNewTextures();
for(int i = 0; i < newTextures.size(); i++)
textureLoader.getTexture(newTextures.get(i));
textureLoader.loadTextures(gl);
loadingTextures = false;
return;
}
GLU glu = new GLU();
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
gl.glShadeModel(GL.GL_SMOOTH);
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glLoadIdentity();
glu.gluPerspective(
camera.getFOV(),
((float) renderer.getWidth() / (float) renderer.getHeight()),
camera.getNearest(),
camera.getFarthest());
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
glu.gluLookAt(
0, 0, 0,
0, 0, 1,
0, 1, 0);
try {
render(gl);
}
catch(Exception exception) {
exception.printStackTrace();
}
frame.updateCursor();
clock.incrementFrameCount();
}