Learning_JME2-Tutorial_1

本文介绍了使用jME游戏引擎创建简单游戏的基本步骤。通过创建一个名为“Mybox”的立方体对象并将其添加到场景图中,演示了如何进行基本的游戏设置。此外,还详细解释了SimpleGame类的作用以及如何使用它来快速启动程序。

Learning_JME2-Tutorial_1

 

请浏览:http://peigen.info/2010/1/29/Learning-Jme2-tutorial_1/
以后在http://peigen.info/category/JME/更新

1) Hello World

( Note: the starter tutorials in this wiki are not always up to date with the latest development version of jME. You can find up to date source files for the tutorials here: http://code.google.com/p/jmonkeyengine/source/browse/#svn/trunk/src/jmetest/TutorialGuide )

Here we’ll learn the basics of creating a jME program, by exploring SimpleGame , Box , and rootNode. OK, let’s just dive in. Here’s as basic a program as you can get:

 

(注解:这份指南在wiki上并不一定是跟最新的jME开发版本一样.你可以在http://code.google.com/p/jmonkeyengine/source/browse/#svn/trunk/src/jmetest/TutorialGuide 找到最新的源码文件)

这里我们将通过探索SimpleGame,Box,rootNode学习基本的创建一个jME程序.OK,开始了,下面是一个简单的程序:


import com.jme.app.SimpleGame;
import com.jme.scene.shape.Box;
import com.jme.math.Vector3f;
/**
 * Started Date: Jul 20, 2004<br><br>
 * Simple HelloWorld program for jME
 *
 * @author Jack Lindamood
 */
public class HelloWorld extends SimpleGame{
 public static void main(String[] args) {
 HelloWorld app = new HelloWorld(); // Create Object
 // Signal to show properties dialog
 app.setConfigShowMode(ConfigShowMode.AlwaysShow);
 app.start(); // Start the program
 }
 protected void simpleInitGame() {
 // Make a box
 Box b = new Box("Mybox", new Vector3f(0,0,0), new Vector3f(1,1,1));
 rootNode.attachChild(b); // Put it in the scene graph
 }
}
 

Pretty short, right? The real meat of our program begins with the following:

 

是不是很精炼?我们的程序从这里开始:

public class HelloWorld extends SimpleGame{
 

SimpleGame does a lot of initialization for us behind our back. If you really want to, you can look at its code, but for now just understand that it creates all the basics needed for rendering. It's a great class to start with for prototyping and testing.

 

SimpleGame在后面帮我们干了很多初始化工作.如果你想细致的了解,请看源码,现在只需要了解它创建了很多基础的需要渲染的东西.这是个很好的原型和测试的类.

app.setConfigShowMode(ConfigShowMode.AlwaysShow);
 

You know the picture of a monkey you see when the program is first run, the one that lets you select the resolution?

 

就像你看到的那样,程序一开始有一个猴子,下面有让我们选择分辨率的选项

 

Well, this command makes it appear. As the name suggests, it always shows the properties dialog on every run. You’ll never see that dialog box if you change it to the following:

 

是 app.setConfigShowMode ( ConfigShowMode.AlwaysShow ) ;让它显示出来的,就像它的名字一样每当运行的时候配置框都会出来,如果你不想看到的话写成 ConfigShowMode.NeverShow即可


ConfigShowMode.NeverShow
 

Not too difficult.

也不太困难嘛.

app.start(); // Start the program启动程序
 

The function start() is a while loop. First, it initializes the jME system. Then, the while loop does two things per iteration: first, it tells everything in your game that it needs to move, and second, it renders everything. Basically, it gets the game going.

 

start()是循环执行的.首先,初始化jME系统.然后,每次循环都重复两件事情:第一,它告诉所有程序哪些要移动,第二,它负责渲染.基本上,是它让程序运行的.

protected void simpleInitGame() {
 // Make a box
 Box b = new Box("Mybox",
 new Vector3f(0,0,0),
 new Vector3f(1,1,1));
 rootNode.attachChild(b); // Put it in the scene graph
}
  

The function simpleInitGame() is abstract in SimpleGame , so you’re forced to implement it every time you extend SimpleGame . Looking at the code we can see that two things happen. First, I make a box (it’s the thing you saw on the screen). Second, I attach the box to the root of my scene graph. The object rootNode is of class Node which is created by SimpleGame for you. You’ll attach everything to it or one of its children. Notice I gave b 3 parameters: a string and two Vector3f objects. Every Node , Box , Circle, Person or anything in your scene graph will have a name. Usually you want the name to be specific for each object. I called this one “My box”, but really you could have called it anything. The next two parameters specify the corners of the Box. It has one corner at the origin, and another at x=1, y=1, z=1. Basically, it’s a unit cube.

 

simpleInitGame() 方法是SimpleGame的抽象方法,所有你每次继承SimpleGame的时候都必须重载它.通过代码我们可以看到,两件事发生,第一,我创建了一个 Box(就是你在屏幕上看到的那个东西).第二,我把box附给了我的场景图.对象rootNode是Node类的实例是从SimpleGame里面创建 的.你可以把所有的东西(组件)都附给rootNode或者其他子节点.注意我给了b(Box)3个参数:一个String和两个Vector3f对象. 每个Node,Box,Circle,Person或者任何在你场景里面的东西都必须有一个名字.通常你需要为每个对象命名专用名字.就像"My box"一样,当然你可以随意给它起名子.另外两个参数指定了Box的两个角.从一个角开始(new Vector3f( 0 ,0 ,0 ) ),到另一个角(new Vector3f( 1 ,1 ,1 ) ),在x=1,y=1,z=1的地方,这就是一个方块单位.

 

OK, I’ve created the Box, but I have to tell it I want it rendered, too. That’s why I attach it to the rootNode object. Your scene graph basically looks like this:

 

OK,我们已经创建了一个Box了,我必须告诉程序我们要渲染它.这就是我为什么把它附给rootNode对象.你的场景看起来像这样(Mybox在rootNode下):

rootNode
My box

 

The object rootNode is at the top and “My box” is below it. So, when SimpleGame tries to draw rootNode it will try to draw “My box” as well. That’s it! Now, on to something more complex.

标题基于Spring Boot的音乐播放网站设计与实现研究AI更换标题第1章引言介绍音乐播放网站的研究背景、意义、国内外现状及论文方法与创新点。1.1研究背景与意义阐述音乐播放网站在当今数字化时代的重要性与市场需求。1.2国内外研究现状分析国内外音乐播放网站的发展现状及技术特点。1.3研究方法以及创新点概述论文采用的研究方法及在设计与实现上的创新点。第2章相关理论与技术基础总结音乐播放网站设计与实现所需的相关理论和技术。2.1Spring Boot框架介绍介绍Spring Boot框架的基本原理、特点及其在Web开发中的应用。2.2音乐播放技术概述概述音乐播放的基本原理、流媒体技术及音频处理技术。2.3数据库技术选型分析适合音乐播放网站的数据库技术,如MySQL、MongoDB等。第3章系统设计详细介绍音乐播放网站的整体设计方案。3.1系统架构设计阐述系统的层次结构、模块划分及各模块的功能。3.2数据库设计介绍数据库表结构、关系及数据存储方式。3.3界面设计用户界面的设计原则、布局及交互方式。第4章系统实现详细介绍音乐播放网站的具体实现过程。4.1开发环境与工具介绍开发所需的软件、硬件环境及开发工具。4.2核心功能实现阐述音乐播放、搜索、推荐等核心功能的实现细节。4.3系统测试与优化介绍系统测试的方法、过程及性能优化策略。第5章研究结果与分析呈现音乐播放网站设计与实现的研究结果。5.1系统功能测试结果展示系统各项功能的测试结果,包括功能完整性、稳定性等。5.2用户反馈与评价收集并分析用户对音乐播放网站的使用反馈与评价。5.3对比方法分析将本设计与实现与其他类似系统进行对比分析,突出优势与不足。第6章结论与展望总结音乐播放网站设计与实现的研究成果,并展望未来发展方向。6.1研究结论概括音乐播放网站设计与实现的主要成果及创新点。6.2展望指出当前研究的不足,提出未来改进方向及可
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值