JME基础教程代码分析1

有人还在问ecplisce的JME3开发环境怎么配,其实文档和教程已经说了:Using any other IDE, create a Java SE project and place jMonkeyEngine3.jar and all JARs from the lib directory on the Classpath. 使用其他IDE工具需要把jMonkeyEngine3.jar包和lib目录下的JARS包加到Classpath下,我的还是做个user lib好。

第一个程序
package jme3test.helloworld;

import com.jme3.app.SimpleApplication;

import com.jme3.material.Material;

import com.jme3.math.Vector3f;

import com.jme3.scene.Geometry;

import com.jme3.scene.shape.Box;

import com.jme3.math.ColorRGBA;

/** Sample 1 - how to get started with the most simple JME 3 application.

 * Display a blue 3D cube and view from all sides by

 * moving the mouse and pressing the WASD keys. */

public class HelloJME3 extends SimpleApplication {

    public static void main(String[] args){

        HelloJME3 app = new HelloJME3();

        app.start();

    }
//重载simpleInitApp方法,表示为场景添加初始化对象
    @Override

    public void simpleInitApp() {
//声明box立方体,做在世界坐标零点,在三个轴方向都是1倍

        Box b = new Box(Vector3f.ZERO, 1, 1, 1);

        Geometry geom = new Geometry("Box", b);
//加载材质和颜色

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

        mat.setColor("Color", ColorRGBA.Blue);

        geom.setMaterial(mat);
//附加到根节点,也就是附加到场景中

        rootNode.attachChild(geom);

    }

}

你可能感兴趣的:(基础)