JME学习笔记(0005)flagrushtut

上传人:re****.1 文档编号:511911203 上传时间:2023-12-18 格式:DOCX 页数:103 大小:902.29KB
返回 下载 相关 举报
JME学习笔记(0005)flagrushtut_第1页
第1页 / 共103页
JME学习笔记(0005)flagrushtut_第2页
第2页 / 共103页
JME学习笔记(0005)flagrushtut_第3页
第3页 / 共103页
JME学习笔记(0005)flagrushtut_第4页
第4页 / 共103页
JME学习笔记(0005)flagrushtut_第5页
第5页 / 共103页
点击查看更多>>
资源描述

《JME学习笔记(0005)flagrushtut》由会员分享,可在线阅读,更多相关《JME学习笔记(0005)flagrushtut(103页珍藏版)》请在金锄头文库上搜索。

1、JME(java Monkey Engine) 学习笔记 bianerJME是一个高性能的3D图形API,采用LWJGL作为底层支持。它的后续版本将支持JOGL。JME和Java 3D具有类似的场景结构,开发者必须以树状方式组织自己的场景。JME有一套很好的优化机制,这使得它得运行速度要比Java 3D快很多。 JME(java Monkey Engine),一个非常棒的Java 3D游戏引擎.通过学习,然后把相关的理解写下来,供有需要的朋友参考。虽然,对于我们来说,无法编写如此优秀的操作引擎。但希望有更多像从事游戏制作、开发的朋友,能提供帮助,开发出让大众喜欢的游戏。希望读者喜欢,希望读者能

2、有所收获。谨以此一系列的学习笔记,送给我最爱的小银猪。希望她快乐、幸福。bianer 2011春Lesson1/*通过SimpleGame建立游戏场景,并显示创建的对象*/public class Lesson1 extends SimpleGame /* * Main method is the entry point for this lesson. It creates a * SimpleGame and tells the dialog to always appear. It then * starts the main loop. * param args */public st

3、atic void main(String args) Lesson1 app = new Lesson1(); app.setConfigShowMode(ConfigShowMode.AlwaysShow); app.start();/* * sets the title of the window, creates a sphere and textures it * with the monkey. * see com.jme.app.SimpleGame#initGame() */ protected void simpleInitGame() /* * 设置窗口标题 */ disp

4、lay.setTitle(Tutorial 1); /* * 创建球体 * 名称 * zSamples * 光滑度 * 半径 * */ Sphere s = new Sphere(Sphere, 30, 30, 25); /* * 场景位置 */ s.setLocalTranslation(new Vector3f(0,0,-40); s.setModelBound(new BoundingBox(); s.updateModelBound(); /* * 建立纹理,加载纹理图片 */ TextureState ts = display.getRenderer().createTextureS

5、tate(); /让纹理生效 ts.setEnabled(true); ts.setTexture( TextureManager.loadTexture( Lesson1.class.getClassLoader().getResource( jmetest/data/images/Monkey.jpg), Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear); /* * 纹理赋给小球 */ s.setRenderState(ts); /* * 小球添加到场景,显示 */ rootNode.at

6、tachChild(s); Lesson2/* * 实现Lession1的功能,但Lession2继承BaseGame * * */public class Lesson2 extends BaseGame private static final Logger logger = Logger.getLogger(Lesson2.class .getName(); /* * 时钟 */protected Timer timer;/相机,观察场景private Camera cam;/场景对象private Node scene;/小球的纹理private TextureState ts;/屏幕

7、高度,高度,深度,刷新频率private int width, height, depth, freq;/* * 是否全屏 */private boolean fullscreen;/* * Main entry point of the application */public static void main(String args) Lesson2 app = new Lesson2();/* * 窗口属性 * 是否出现 * 窗口的图片 */app.setConfigShowMode(ConfigShowMode.AlwaysShow, Lesson2.class.getClassLoa

8、der().getResource(jmetest/data/images/FlagRush.png);app.start();/* * During an update we only look for the escape button and update the timer * to get the framerate. * * see com.jme.app.BaseGame#update(float) */protected void update(float interpolation) /update the time to get the frameratetimer.upd

9、ate();interpolation = timer.getTimePerFrame();/判断键盘输入if (KeyBindingManager.getKeyBindingManager().isValidCommand(exit) finished = true;/* * draws the scene graph * * see com.jme.app.BaseGame#render(float) */protected void render(float interpolation) /清空屏幕display.getRenderer().clearBuffers();/* * 输出

10、*/display.getRenderer().draw(scene);/* * initializes the display and camera. * * see com.jme.app.BaseGame#initSystem() */protected void initSystem() /store the settings informationwidth = settings.getWidth();height = settings.getHeight();depth = settings.getDepth();freq = settings.getFrequency();ful

11、lscreen = settings.isFullscreen();try display = DisplaySystem.getDisplaySystem(settings.getRenderer();display.createWindow(width, height, depth, freq, fullscreen);cam = display.getRenderer().createCamera(width, height); catch (JmeException e) logger.log(Level.SEVERE, Could not create displaySystem,

12、e);System.exit(1);/set the background to blackdisplay.getRenderer().setBackgroundColor(ColorRGBA.black.clone();/initialize the cameracam.setFrustumPerspective(45.0f, (float)width / (float)height, 1, 1000);Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);

13、Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);/ Move our camera to a correct place and orientation.cam.setFrame(loc, left, up, dir);/* Signal that weve changed our cameras location/frustum. */cam.update(); /* Get a high resolution timer for FPS updates. */ timer = Timer.getTimer();display.getRenderer().setCamera(cam);KeyBindingManager.getKeyBindingMa

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 营销创新

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号