/** Convenience method to create a model with a single node containing a box shape. The resources the Material might contain are * not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createBox (float width, float height, float depth, int primitiveType, final Material material, final long attributes) { begin(); part("box", primitiveType, attributes, material).box(width, height, depth); return end(); }
/** Convenience method to create a model with a single node containing a box shape. The resources the Material might contain are * not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createBox (float width, float height, float depth, int primitiveType, final Material material, final long attributes) { begin(); part("box", primitiveType, attributes, material).box(width, height, depth); return end(); }
/** Build a box with the shape of the specified {@link BoundingBox}. * @param box */ public static void build (MeshPartBuilder builder, BoundingBox box) { builder.box(box.getCorner000(obtainV3()), box.getCorner010(obtainV3()), box.getCorner100(obtainV3()), box.getCorner110(obtainV3()), box.getCorner001(obtainV3()), box.getCorner011(obtainV3()), box.getCorner101(obtainV3()), box.getCorner111(obtainV3())); freeAll(); }
/** Build a box with the shape of the specified {@link BoundingBox}. * @param box */ public static void build (MeshPartBuilder builder, BoundingBox box) { builder.box(box.getCorner000(obtainV3()), box.getCorner010(obtainV3()), box.getCorner100(obtainV3()), box.getCorner110(obtainV3()), box.getCorner001(obtainV3()), box.getCorner011(obtainV3()), box.getCorner101(obtainV3()), box.getCorner111(obtainV3())); freeAll(); }
@Override public void create () { modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f)); environment.add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f, 0.8f, -1f, -.8f, -.2f)); environment.shadowMap = shadowLight; cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0f, 7f, 10f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 50f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.ColorUnpacked, new Material(ColorAttribute.createDiffuse(Color.WHITE))); mpb.setColor(1f, 1f, 1f, 1f); mpb.box(0, -1.5f, 0, 10, 1, 10); mpb.setColor(1f, 0f, 1f, 1f); mpb.sphere(2f, 2f, 2f, 10, 10); model = modelBuilder.end(); instance = new ModelInstance(model); shadowBatch = new ModelBatch(new DepthShaderProvider()); Gdx.input.setInputProcessor(camController = new CameraInputController(cam)); }
MeshPartBuilder meshPartBuilder = modelBuilder.part("floor", GL20.GL_TRIANGLES, VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorPacked | VertexAttributes.Usage.Normal, new Material()); meshPartBuilder.setColor(0.2f, 0.2f, 0.2f, 1f); meshPartBuilder.box(0, -0.1f, 0f, 20f, 0.1f, 20f); floorInstance = new ModelInstance(modelBuilder.end());
| Usage.ColorPacked, material); mpb.setColor(Color.RED); mpb.box(1f, 1f, 1f);
modelBuilder.begin(); MeshPartBuilder mpb = modelBuilder.part("box", primitiveType, attributes, material); mpb.setUVRange(yourRegion); mpb.box(width, height, depth); cube = modelBuilder.end();
int width = 5; int height = 5; int length = 5; int numCubes = width*height*length; ModelBuilder mb = new ModelBuilder(); mb.begin(); MeshPartBuilder mpb = mb.part("cubes", GL20.GL_TRIANGLES, (Usage.Position | Usage.Normal), new Material(ColorAttribute.createDiffuse(Color.GREEN))); for (int i=0; i<numCubes; i++){ mpb.box(1, 1, 1); } Model model = mb.end(); mBatchedCubesModelInstance = new ModelInstance(model);
/** Convenience method to create a model with a single node containing a box shape. The resources the Material might contain are * not managed, use {@link Model#manageDisposable(Disposable)} to add those to the model. * @param attributes bitwise mask of the {@link com.badlogic.gdx.graphics.VertexAttributes.Usage}, only Position, Color, Normal * and TextureCoordinates is supported. */ public Model createBox (float width, float height, float depth, int primitiveType, final Material material, final long attributes) { begin(); part("box", primitiveType, attributes, material).box(width, height, depth); return end(); }
/** Build a box with the shape of the specified {@link BoundingBox}. * @param box */ public static void build (MeshPartBuilder builder, BoundingBox box) { builder.box(box.getCorner000(obtainV3()), box.getCorner010(obtainV3()), box.getCorner100(obtainV3()), box.getCorner110(obtainV3()), box.getCorner001(obtainV3()), box.getCorner011(obtainV3()), box.getCorner101(obtainV3()), box.getCorner111(obtainV3())); freeAll(); }