• 大小: 3.28MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-10
  • 语言: 其他
  • 标签: OpenGL  Java  Skybox  Camera  

资源简介

基于OpenGL实现的3D飞机上下左右移动 通过上下左右前后六个摄像头分别观察飞机模型

资源截图

代码片段和文件信息


import java.awt.Color;
import java.awt.frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
import java.io.IOException;
import java.util.Random;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;

import com.sun.opengl.util.Animator;
import com.sun.opengl.util.GLUT;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureIO;

import Helicopter.HelicopterRotors;
import RainParticle.ParticleSystem;
import SceneGraph.CameraNode;
import SceneGraph.LightNode;
import SceneGraph.Material;
import SceneGraph.Point3D;
import SceneGraph.Scene;
import SceneGraph.Vector3D;
import SceneGraph.Camera.*;
import SceneGraph.Light.DirectionalLight;
import SceneGraph.Light.PointLight;
import SceneGraph.Model.ObjModel;
import SceneGraph.Renderables.*;
import Terrain.AbstractTerrain;
import Terrain.HeightmapTerrain;


public class Main implements GLEventListener {

private Scene scene = null;
    HelicopterRotors helicopter = null;
    private double lastTick;
    private GLUT glut = new GLUT();
    private int windowWidth;
    private int windowHeight;
    
private CameraNode[] camera;

     private AbstractTerrain terrain;
     private Texture terrainTexture;
    
     private SmallPond pond;
     private LightNode light = null;
     private double clock = 0.0f; // the clock ranges from 0 to 24 - denoting hour of a day
     GL gl;
     
     private ParticleSystem particleSystem;
     
  private ObjModel model;
    @Override 
    // called when OpenGL is initialised
    public void init(GLAutoDrawable drawable) {
        gl = drawable.getGL();
     lastTick = System.currentTimeMillis() / 1000.0;
     scene = new Scene();
     glut = new GLUT();
       scene.setAmbientLightColour(Color.BLACK);
        Origin origin = new Origin(“Axes“ scene.getRootNode());
        origin.setScale(2.0f 2.0f 2.0f);
        
        Ground ground = new Ground(“Grid“ scene.getRootNode() 98 1 drawable);
        ground.getOrientation().setPitch(90.0f);
        
     Skybox skybox = null;
     Texture[] sky = new Texture[6];
     try {
     sky[0]= TextureIO.newTexture(new File(“data/textures/cloudy_noon_DN.jpg“) true);
     sky[1]= TextureIO.newTexture(new File(“data/textures/sky_forward.png“) true);
     sky[2]= TextureIO.newTexture(new File(“data/textures/sky_right.png“) true);
     sky[3]= TextureIO.newTexture(new File(“data/textures/sky_back.png“) true);
     sky[4]= TextureIO.newTexture(new File(“data/textures/sky_left.png“) true);
     sky[5]= TextureIO.newTexture(new File(“data/textures/sky_up.png“) true);
     skybox = new Skybox(“lovely day“ scene.getRootNode() sky);
     } catch (IOException e) {
            throw new RuntimeException(e);
        }
     skybox.setScale(100.0f 100.0f 100.0f);
  

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-06-16 17:37  A2- 14871088\
     目录           0  2018-03-01 23:36  A2- 14871088\bin\
     目录           0  2018-03-01 23:36  A2- 14871088\bin\RainParticle\
     文件        2452  2018-03-01 23:36  A2- 14871088\bin\RainParticle\RainParticle.class
     文件        2278  2018-03-01 23:36  A2- 14871088\bin\RainParticle\ParticleSystem.class
     文件         804  2018-03-01 23:36  A2- 14871088\bin\Main$1.class
     文件         746  2018-03-01 23:36  A2- 14871088\bin\Main$1$1.class
     目录           0  2018-03-01 23:36  A2- 14871088\bin\Helicopter\
     文件       10244  2018-03-01 23:36  A2- 14871088\bin\Helicopter\HelicopterRotors.class
     文件        4656  2018-03-01 23:36  A2- 14871088\bin\Helicopter\HelicopterBody.class
     目录           0  2018-03-01 23:36  A2- 14871088\bin\Terrain\
     文件        1469  2018-03-01 23:36  A2- 14871088\bin\Terrain\HeightmapTerrain.class
     文件        2796  2018-03-01 23:36  A2- 14871088\bin\Terrain\Vector.class
     文件        5525  2018-03-01 23:36  A2- 14871088\bin\Terrain\AbstractTerrain.class
     文件       11336  2018-03-01 23:36  A2- 14871088\bin\Main.class
     目录           0  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\
     文件        2162  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Scene.class
     文件        1706  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Vector3D.class
     目录           0  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\
     文件        3574  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Skybox.class
     文件        1229  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Cylinder.class
     文件        1792  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Tree$Trunk.class
     文件        1051  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Quadrics.class
     文件        4858  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Ground.class
     文件        1390  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\BallTree.class
     文件        1622  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\SharpTree$SharpTreeHead.class
     文件        1725  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Cube.class
     文件        1108  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Sphere.class
     文件         780  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Tree.class
     文件        1472  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\SphereTree.class
     文件        1162  2018-03-01 23:36  A2- 14871088\bin\SceneGraph\Renderables\Disc.class
............此处省略115个文件信息

评论

共有 条评论