@Override public int attachChild(Spatial child) { if (!(child instanceof Geometry)) { throw new UnsupportedOperationException("BatchNode is BatchMode.Simple only support child of type Geometry, use BatchMode.Complex to use a complex structure"); } return super.attachChild(child); }
public void randomGenerator() { for (int i = startAt; i < maxCubes - 1; i++) { randomize(); Geometry box = new Geometry("Box" + i, new Box(1, 1, 1)); box.setLocalTranslation(new Vector3f(xPosition.get(xPosition.size() - 1), yPosition.get(yPosition.size() - 1), zPosition.get(zPosition.size() - 1))); batchNode.attachChild(box); if (i < 500) { box.setMaterial(mat1); } else if (i < 1000) { box.setMaterial(mat2); } else if (i < 1500) { box.setMaterial(mat3); } else { box.setMaterial(mat4); } } }
public void addBrick(Vector3f ori) { Geometry reBoxg = new Geometry("brick", brick); reBoxg.setMaterial(mat); reBoxg.setLocalTranslation(ori); reBoxg.rotate(0f, (float)Math.toRadians(angle) , 0f ); reBoxg.addControl(new RigidBodyControl(1.5f)); reBoxg.setShadowMode(ShadowMode.CastAndReceive); reBoxg.getControl(RigidBodyControl.class).setFriction(1.6f); this.batchNode.attachChild(reBoxg); this.getPhysicsSpace().add(reBoxg); nbBrick++; }
this.attachChild(batch.geometry);
@Override public void simpleUpdate(float tpf) { if (!done) { done = true; batch.attachChild(cube2); batch.batch(); } updateBoindPoints(points); frustum.update(points); time += tpf; dl.setDirection(cam.getDirection()); cube2.setLocalTranslation(FastMath.sin(-time) * 3, FastMath.cos(time) * 3, 0); cube2.setLocalRotation(new Quaternion().fromAngleAxis(time, Vector3f.UNIT_Z)); cube2.setLocalScale(Math.max(FastMath.sin(time), 0.5f)); // batch.setLocalRotation(new Quaternion().fromAngleAxis(time, Vector3f.UNIT_Z)); } //
batch.attachChild(cube);
@Override public int attachChild(Spatial child) { if (!(child instanceof Geometry)) { throw new UnsupportedOperationException("BatchNode is BatchMode.Simple only support child of type Geometry, use BatchMode.Complex to use a complex structure"); } return super.attachChild(child); }
@Override public int attachChild(Spatial child) { if (!(child instanceof Geometry)) { throw new UnsupportedOperationException("BatchNode is BatchMode.Simple only support child of type Geometry, use BatchMode.Complex to use a complex structure"); } return super.attachChild(child); }
/** * Create tile nodes inside a page * * @param pageBatch the page * @param pageX page x * @param pageY page y */ private void generateTileNodes(BatchNode pageBatch, int pageX, int pageY) { for (int y = 0; y < PAGE_SQUARE_SIZE; y++) { for (int x = 0; x < PAGE_SQUARE_SIZE; x++) { pageBatch.attachChild(new Node((x + pageX * PAGE_SQUARE_SIZE) + "_" + (y + pageY * PAGE_SQUARE_SIZE))); } } }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); //Point start = roomInstance.getCoordinates().get(0); // Contruct the tiles for (Point p : roomInstance.getCoordinates()) { // Figure out which peace by seeing the neighbours boolean N = roomInstance.hasCoordinate(new Point(p.x, p.y - 1)); boolean NE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y - 1)); boolean E = roomInstance.hasCoordinate(new Point(p.x + 1, p.y)); boolean SE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y + 1)); boolean S = roomInstance.hasCoordinate(new Point(p.x, p.y + 1)); boolean SW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y + 1)); boolean W = roomInstance.hasCoordinate(new Point(p.x - 1, p.y)); boolean NW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y - 1)); // 2x2 Node model = constructQuad(assetManager, modelName, N, NE, E, SE, S, SW, W, NW); //AssetUtils.scale(model); AssetUtils.translateToTile(model, p); root.attachChild(model); } return root; }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); //Point start = roomInstance.getCoordinates().get(0); // Contruct the tiles for (Point p : roomInstance.getCoordinates()) { // Figure out which peace by seeing the neighbours boolean N = roomInstance.hasCoordinate(new Point(p.x, p.y - 1)); boolean NE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y - 1)); boolean E = roomInstance.hasCoordinate(new Point(p.x + 1, p.y)); boolean SE = roomInstance.hasCoordinate(new Point(p.x + 1, p.y + 1)); boolean S = roomInstance.hasCoordinate(new Point(p.x, p.y + 1)); boolean SW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y + 1)); boolean W = roomInstance.hasCoordinate(new Point(p.x - 1, p.y)); boolean NW = roomInstance.hasCoordinate(new Point(p.x - 1, p.y - 1)); // 2x2 Node model = constructQuad(assetManager, modelName, N, NE, E, SE, S, SW, W, NW); //AssetUtils.scale(model); AssetUtils.translateToTile(model, p); root.attachChild(model); } // Set the transform and scale to our scale and 0 the transform //AssetUtils.scale(root); //AssetUtils.moveToTile(root, start); return root; }
Spatial part = objectLoader.load(assetManager, centre.x, centre.y, OBJECT_TEMPLE_HAND_ID, roomInstance.getOwnerId()); part.move(0, - 3 * MapLoader.FLOOR_HEIGHT / 2, MapLoader.TILE_WIDTH / 4); root.attachChild(part); root.attachChild(model);
root.attachChild(part); continue; root.attachChild(model);
root.attachChild(part); root.attachChild(part); moveSpatial(part, p); root.attachChild(part); door = p; continue; root.attachChild(model);
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); // Contruct the tiles int i = 0; Point start = roomInstance.getCoordinates().get(0); for (Point p : roomInstance.getCoordinates()) { Spatial tile = AssetUtils.loadModel(assetManager, modelName + i++, false, true); // Reset moveSpatial(tile, start, p); root.attachChild(tile); } // Set the transform and scale to our scale and 0 the transform AssetUtils.translateToTile(root, start); return root; }
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); // 3 by 3, a simple case int i = 0; Point start = roomInstance.getCoordinates().get(0); for (Point p : roomInstance.getCoordinates()) { Spatial tile = (Spatial) AssetUtils.loadModel(assetManager, roomInstance.getRoom().getCompleteResource().getName() + i, false, true); moveSpatial(tile, start, p); root.attachChild(tile); i++; } // Set the transform and scale to our scale and 0 the transform //AssetUtils.scale(root); AssetUtils.translateToTile(root, start); return root; }
root.attachChild(tile);
root.attachChild(part);
@Override protected BatchNode constructFloor() { BatchNode root = new BatchNode(); String modelName = roomInstance.getRoom().getCompleteResource().getName(); //Point center = roomInstance.getCenter(); // Contruct the tiles int j = 0; for (Point p : roomInstance.getCoordinates()) { int piece = (roomInstance.getDirection() == Direction.WEST || roomInstance.getDirection() == Direction.SOUTH) ? j + 3 : 5 - j; Spatial tile = AssetUtils.loadModel(assetManager, modelName + piece, false, true); j++; moveSpatial(tile, p); root.attachChild(tile); // Set the transform and scale to our scale and 0 the transform switch (roomInstance.getDirection()) { case NORTH: tile.rotate(0, -FastMath.HALF_PI, 0); break; case EAST: tile.rotate(0, FastMath.PI, 0); break; case SOUTH: tile.rotate(0, FastMath.HALF_PI, 0); break; } } //root.move(-MapLoader.TILE_WIDTH / 2, 0, -MapLoader.TILE_WIDTH / 2); return root; }