⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractogreapplication.java

📁 使用stl技术,(还没看,是听说的)
💻 JAVA
字号:
/*  Ogre4J
    Copyright (C) 2002 macross

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
package org.ogre4j.demo;

import org.ogre4j.Camera;
import org.ogre4j.IOgreApp;
import org.ogre4j.OgreConsts;
import org.ogre4j.Root;
import org.ogre4j.SceneManager;
import org.ogre4j.Viewport;
import org.ogre4j.event.IFrameListener;

/**
 * AbstractOgreApplication
 * 
 * @author Ivica Aracic <ivica.aracic@bytelords.de>
 */
public abstract class AbstractOgreApplication
implements IOgreApp, IFrameListener {
    
    private DefaultBehaviour defaultBehaviour;
    
    protected Root         root;   
    protected SceneManager sceneMgr;
    protected Camera       camera;   
    
    protected ConfigSheet  configSheet = ConfigSheet.instance();    

    public AbstractOgreApplication() {
        root = Root.instance();
        
        root.addFrameListener(this);
    }
    
    public void appStarted() {
        chooseSceneManager();
        createCamera();
        createViewports();

        defaultBehaviour = new DefaultBehaviour(camera);        
        root.addKeyListener(defaultBehaviour);
        root.addFrameListener(defaultBehaviour);

        createScene();
    }
    
    public void appEnded() {
        destroyScene();
    }
    
    protected void chooseSceneManager() {        
        sceneMgr = root.getSceneManager(OgreConsts.ST_GENERIC);
    }
    
    protected void createCamera() {
        // Create the camera
        camera = sceneMgr.createCamera("PlayerCam");

        // Position it at 500 in Z direction
        camera.setPosition(0, 0, 500);
        // Look back along -Z
        camera.lookAt(0,0,-1);              
        
        // not supported yet
        camera.setNearClipDistance(5);

    }
    
    protected abstract void createScene();
    protected abstract void destroyScene();

    protected void createViewports() {
        // Create one viewport, entire window
        Viewport vp = root.addViewport(camera);
        //vp.setBackgroundColour(0,0,0);
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -