( 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即可
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下):
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.
相关推荐
jme-3.0.10 兼容): 版本:1.+ 分支:jme_3.0 JME3-JFX 需要 java 8,但是可以使用 java 7 在纹理上绘制视频。对于 jME SDK,您应该创建一个 java 8 平台,但是 java8 支持非常糟糕(因为它基于 netbeans 7)。 ...
RPG手机游戏开发代码,是一个完整的开发代码
经过jbuilder调试,本列主要实现列表中的增加,删除等等操作
代码测试环境:JME-2核心板+1T指令周期的STC单片机(51内核 STC12LE5A60S2)+33M晶振 单片机工作电压3.3V 程序默认IO连接方式: 控制线:RS-P3^5; WR-P3^6; RD-P3^7; CS-P1^0; REST-P1^2; 数据线: DB0-DB7依次连接P0^0...
jme-remoterpiui-demo RemoteRPIUIControllerDemo MIDlet 该程序允许从JME Emulator远程控制在Raspberry Pi上运行的RPIUIDemoMIDlet应用程序(jme-rpiui-demo存储库)。 该程序连接到RPIUIDemoMIDlet的服务器套接...
jmasters JMasters 是一个简单的应用程序,遵循所有 JMonkeyEngine 3.x 教程。 可以说它是对网站上现有教程的翻译。 使用的平台: JMonkeyEngine 3.x 64 位; Oracle JDK 7; Kubuntu 14.04 LTS。
jme3-clj-aide JMonkeyEngine3 + Clojure-Android + AIDE 示例项目
jme3-样板 jMonkeyEngine 3.0 项目的 gradle 样板 桌面+安卓构建 maven 满足 jme3 依赖项 android sdk 必须在local.properties提供 安卓依赖 android sdk 构建工具 21.1.1 android 支持存储库 8 安卓支持库 21.0.1...
MultiverseKing_JME 使用JMonkeyEngine( )的开源战术动作RPG游戏所有图形均已在CC BY-SA 4.0下获得许可。 许可链接: : 该项目使用可以在以下位置找到的HexGridAPI:
jme-process-site
关于这个图书馆 该库提供了一些接口来与jMonkeyBuilder集成。 执照 请参阅名为LICENSE的文件。 如何使用 Gradle repositories { maven { url " ... <id>bintray-javasabr-maven</id>
适用于移动设备和 PC 的基于 Java 的 Commodore 64 模拟器。 如果你想在你的手机或 PC 上看到旧的 C64 变得活跃,那么试试这个模拟器。 有关更多信息,请参阅 Wiki 页面 ...
跑步 : gradle exec
com.jme3.animation com.jme3.app com.jme3.app.state com.jme3.asset com.jme3.asset.pack com.jme3.asset.plugins com.jme3.audio com.jme3.audio.joal ...jme3tools.preview
jme-cardboard-example 在Google Cardboard中运行的一些jMonkeyEngine示例您需要在使用此项目之前进行设置: :
标签:ant-jme.jar.zip,ant,jme,jar.zip包下载,依赖包
基于jmonkeyengine游戏引擎,纯java开发,单机3d小游戏demo
JME教程.rar
JME程序设计实例教程 JME程序设计实例教程 JME程序设计实例教程
JME Molecular Editor结构式在线编辑器