Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (int i = 0; i < axiom.length(); i++) {
- char c = axiom.charAt(i);
- Matrix4f tempRotation = new Matrix4f();
- tempRotation.setIdentity();
- switch (c) {
- case 'G':
- case 'F':
- // Tree trunk
- view.setBlock(posX + (int) position.x + 1, posY + (int) position.y, posZ + (int) position.z, barkType, view.getBlock(posX + (int) position.x + 1, posY + (int) position.y, posZ + (int) position.z));
- view.setBlock(posX + (int) position.x - 1, posY + (int) position.y, posZ + (int) position.z, barkType, view.getBlock(posX + (int) position.x - 1, posY + (int) position.y, posZ + (int) position.z));
- view.setBlock(posX + (int) position.x, posY + (int) position.y, posZ + (int) position.z + 1, barkType, view.getBlock(posX + (int) position.x, posY + (int) position.y, posZ + (int) position.z + 1));
- view.setBlock(posX + (int) position.x, posY + (int) position.y, posZ + (int) position.z - 1, barkType, view.getBlock(posX + (int) position.x, posY + (int) position.y, posZ + (int) position.z - 1));
- // Generate leaves
- if (_stackOrientation.size() > 1) {
- int size = 1;
- for (int x = -size; x <= size; x++) {
- for (int y = -size; y <= size; y++) {
- for (int z = -size; z <= size; z++) {
- if (Math.abs(x) == size && Math.abs(y) == size && Math.abs(z) == size)
- continue;
- view.setBlock(posX + (int) position.x + x + 1, posY + (int) position.y + y, posZ + z + (int) position.z, leafType, air);
- view.setBlock(posX + (int) position.x + x - 1, posY + (int) position.y + y, posZ + z + (int) position.z, leafType, air);
- view.setBlock(posX + (int) position.x + x, posY + (int) position.y + y, posZ + z + (int) position.z + 1, leafType, air);
- view.setBlock(posX + (int) position.x + x, posY + (int) position.y + y, posZ + z + (int) position.z - 1, leafType, air);
- }
- }
- }
- }
- Vector3f dir = new Vector3f(1, 0, 0);
- rotation.transform(dir);
- position.add(dir);
- break;
- case '[':
- _stackOrientation.push(new Matrix4f(rotation));
- _stackPosition.push(new Vector3f(position));
- break;
- case ']':
- rotation = _stackOrientation.pop();
- position = _stackPosition.pop();
- break;
- case '+':
- tempRotation.setIdentity();
- tempRotation.setRotation(new AxisAngle4f(new Vector3f(0, 0, 1), (float) Math.toRadians(angleInDegree + angleOffset)));
- rotation.mul(tempRotation);
- break;
- case '-':
- tempRotation.setIdentity();
- tempRotation.setRotation(new AxisAngle4f(new Vector3f(0, 0, -1), (float) Math.toRadians(angleInDegree + angleOffset)));
- rotation.mul(tempRotation);
- break;
- case '&':
- tempRotation.setIdentity();
- tempRotation.setRotation(new AxisAngle4f(new Vector3f(0, 1, 0), (float) Math.toRadians(angleInDegree + angleOffset)));
- rotation.mul(tempRotation);
- break;
- case '^':
- tempRotation.setIdentity();
- tempRotation.setRotation(new AxisAngle4f(new Vector3f(0, -1, 0), (float) Math.toRadians(angleInDegree + angleOffset)));
- rotation.mul(tempRotation);
- break;
- case '*':
- tempRotation.setIdentity();
- tempRotation.setRotation(new AxisAngle4f(new Vector3f(1, 0, 0), (float) Math.toRadians(angleInDegree)));
- rotation.mul(tempRotation);
- break;
- case '/':
- tempRotation.setIdentity();
- tempRotation.setRotation(new AxisAngle4f(new Vector3f(-1, 0, 0), (float) Math.toRadians(angleInDegree)));
- rotation.mul(tempRotation);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement