Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.ractoc.fs.invasion.appstates;
- import com.jme3.app.Application;
- import com.jme3.app.state.AbstractAppState;
- import com.jme3.app.state.AppStateManager;
- import com.jme3.material.Material;
- import com.jme3.math.ColorRGBA;
- import com.jme3.scene.Geometry;
- import com.jme3.scene.shape.Quad;
- import com.jme3.texture.Image;
- import com.jme3.texture.Texture2D;
- import com.ractoc.fs.invasion.GameClient;
- import java.io.ByteArrayOutputStream;
- import java.io.IOException;
- import java.nio.ByteBuffer;
- /**
- *
- * @author ractoc
- */
- public class StarField extends AbstractAppState {
- private Geometry starField;
- private int width, height, density, layers;
- private GameClient gameClient;
- public StarField(int width, int height, int density, int layers) {
- this.width = width;
- this.height = height;
- this.density = density;
- this.layers = layers;
- }
- @Override
- public final void initialize(final AppStateManager stateManager,
- final Application app) {
- super.initialize(stateManager, app);
- this.gameClient = (GameClient) app;
- Quad starQ = new Quad(width, height);
- starField = new Geometry("starField", starQ);
- Material mat = new Material(gameClient.getAssetManager(),
- "Common/MatDefs/Misc/Unshaded.j3md");
- mat.setColor("Color", ColorRGBA.Blue);
- Texture2D t = new Texture2D();
- Image i = new Image(Image.Format.RGBA8, width, height, null);
- t.setImage(i);
- mat.setTexture("stars", t);
- starField.setMaterial(mat);
- gameClient.getRootNode().attachChild(starField);
- }
- private ByteBuffer addStars() throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- for (int i = 0; i < layers; i++) {
- for (int j = 0; j < density; j++) {
- baos.write(createStar());
- }
- }
- return ByteBuffer.wrap(baos.toByteArray());
- }
- private byte[] createStar() {
- return null;
- }
- }
Add Comment
Please, Sign In to add comment