|
cam.translate(3.0f, 0.0f, 3.0f);
很简单的事!每个方法调用translate进一步调整照相机,因此上面两个调用实际上转变照相机在X和Z轴都是6个单位。旋转也是一样的简单,我会首先说明这个方法。它操作像3D API的所有旋转方法一样。有个参数,第一个是实际的旋转度数,剩下的三个组成一个方向向量(xAxis, yAxis, zAxis)在周围旋转。方向和方向向量在后面的丛书将会讲到,现在仅仅需要知道这些:
//Rotate camera 30 degrees around the X axis cam.setOrientation(30.0f, 1.0f, 0.0f, 0.0f);
//Rotate camera 30 degrees around the Y axis cam.setOrientation(30.0f, 0.0f, 1.0f, 0.0f);
//Rotate camera 30 degrees around the Z axis cam.setOrientation(30.0f, 0.0f, 0.0f, 1.0f);
注意名为setOrientation的方法,它实际意味着清除所有先前你做的旋转。我假设你已经知道了怎么围绕一个坐标轴旋转,在这里并不会提到关于这个主题的更多细节。
你现在知道如何移动和旋转照相机。我将告诉你如何从世界中提取照相机。
/** Loads our camera */ private void loadCamera() { // BAD! if(world == null) return; // Get the active camera from the world cam = world.getActiveCamera(); // Create a light Light l = new Light(); // Make sure it's AMBIENT l.setMode(Light.AMBIENT); // We want a little higher intensity
上一篇:使用Java蓝牙无线通讯技术API(第一部分 -API概览)(1)
下一篇:java多线程设计模式详解之四
|