?? brick.java
字號:
import javax.microedition.m3g.Group;
import javax.microedition.m3g.Loader;
import javax.microedition.m3g.Mesh;
import javax.microedition.m3g.Node;
import javax.microedition.m3g.Object3D;
import javax.microedition.m3g.World;
public class Brick {
private Node gBrick;
private final int BRICK_ID = 32;
private World world;
public Brick() {
load();
}
public Node getBrick(){
return gBrick;
}
public void load() {
try {
// world = new World();
Object3D[] list = Loader.load("/gogo.m3g");
for (int i = 0; i < list.length; i++) {
if (list[i] instanceof World) {
world = (World) list[i];
break;
}
}
// Group group = new Group();
// while(world.getChildCount() > 0){
// Node node = world.getChild(0);
// world.removeChild(node);
// group.addChild(node);
// }
// Group root = (Group)list[1];
// System.out.println(gBrick.toString());
// System.out.println("world.find():"+ world.find(31).toString());
gBrick = (Node)world.find(BRICK_ID);
// gBrick = new Group();
// System.out.println(gBrick.toString());
// Group parent =(Node)gBrick.getParent();
// parent.removeChild(gBrick);
world.removeChild(gBrick);
// System.out.println(gBrick.toString());
// gBrick = new Group();
// gBrick.addChild(group);
// gBrick = (Group)gBrick.find(BRICK_ID);
// gBrick = (Group) world.find(BRICK_ID);
// world.removeChild(gBrick);
// Group group = new Group();
// while (gBrick.getChildCount() > 0) {
// Node node = gBrick.getChild(0);
// gBrick.removeChild(node);
// group.addChild(node);
// }
//
// gBrick.addChild(group);
} catch (Exception e) {
e.printStackTrace();
}
}
public World createMap(World world){
int num = Map.maps.length/2;
for(int i = 1; i < num; i++){
float x = Map.maps[i*2-1];
float z = Map.maps[i*2-2];
Node brick = (Node)getBrick().duplicate();
brick.setScale(1.5f, 1.5f, 1.5f);
brick.translate(x, 0, z);
world.addChild(brick);
}
return world;
}
// private static void removeLightAndCamera(World world) {
// for (int i = 0; i < world.getChildCount(); i++) {
// Node node = world.getChild(i);
// if (node instanceof Light || node instanceof Camera) {
// world.removeChild(node);
// i--;
// }
// }
// }
//
// private static void cleanNodeTranslation(Node node) {
// float[] data = new float[3];
// node.getTranslation(data);
// node.translate(-data[0], -data[1], -data[2]);
// }
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -