/** 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, final Material material, final long attributes) { return createBox(width, height, depth, GL20.GL_TRIANGLES, material, attributes); }
/** 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, final Material material, final long attributes) { return createBox(width, height, depth, GL20.GL_TRIANGLES, material, attributes); }
super.create(); final Model barModel = modelBuilder.createBox(10f, 1f, 1f, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE)), Usage.Position | Usage.Normal); disposables.add(barModel);
@Override public void create () { modelBatch = new ModelBatch(new DefaultShaderProvider()); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(10f, 10f, 10f); cam.lookAt(0, 0, 0); cam.near = 1f; cam.far = 30f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model); Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam))); }
@Override public void create () { modelBatch = new ModelBatch(); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); environment.set(new ColorAttribute(ColorAttribute.Fog, 0.13f, 0.13f, 0.13f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(30f, 10f, 30f); cam.lookAt(0, 0, 0); cam.near = 0.1f; cam.far = 45f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model); Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam))); }
world.addConstructor("capsule", new BulletConstructor(capsule, 10f, new btCapsuleShape(2f, 2f))); final Model box = modelBuilder.createBox(4f, 4f, 2f, material, attributes); disposables.add(box); world.addConstructor("box2", new BulletConstructor(box, 10f, new btBoxShape(tmpV1.set(2f, 2f, 1f))));
@Override public void create () { texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true); // Create material attributes. Each material can contain x-number of attributes. textureAttribute = new TextureAttribute(TextureAttribute.Diffuse, texture); colorAttribute = new ColorAttribute(ColorAttribute.Diffuse, Color.ORANGE); blendingAttribute = new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); ModelBuilder builder = new ModelBuilder(); model = builder.createBox(1, 1, 1, new Material(), Usage.Position | Usage.Normal | Usage.TextureCoordinates); model.manageDisposable(texture); modelInstance = new ModelInstance(model); modelInstance.transform.rotate(Vector3.X, 45); material = modelInstance.materials.get(0); builder.begin(); MeshPartBuilder mpb = builder.part("back", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates, new Material( textureAttribute)); mpb.rect(-2, -2, -2, 2, -2, -2, 2, 2, -2, -2, 2, -2, 0, 0, 1); backModel = builder.end(); background = new ModelInstance(backModel); modelBatch = new ModelBatch(); camera = new PerspectiveCamera(45, 4, 4); camera.position.set(0, 0, 3); camera.direction.set(0, 0, -1); camera.update(); Gdx.input.setInputProcessor(this); }
Model boxModel = modelBuilder.createBox(50f, 50f, 50f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); boxInstance = new ModelInstance(boxModel);
@Override public void create () { Gdx.gl.glClearColor(0.2f, 0.3f, 1.0f, 0.f); atlas = new TextureAtlas(Gdx.files.internal("data/testpack")); regions = atlas.getRegions(); modelBatch = new ModelBatch(new DefaultShaderProvider()); environment = new Environment(); environment.set(new ColorAttribute(ColorAttribute.AmbientLight, .4f, .4f, .4f, 1f)); environment.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -0.8f, -0.2f)); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(10f, 10f, 10f); cam.lookAt(0, 0, 0); cam.near = 0.1f; cam.far = 300f; cam.update(); ModelBuilder modelBuilder = new ModelBuilder(); final Material material = new Material(ColorAttribute.createDiffuse(1f, 1f, 1f, 1f), new TextureAttribute(TextureAttribute.Diffuse)); model = modelBuilder.createBox(5f, 5f, 5f, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates); instance = new ModelInstance(model); attribute = instance.materials.get(0).get(TextureAttribute.class, TextureAttribute.Diffuse); Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam))); }
model = builder.createBox(1, 1, 1, material, Usage.Position | Usage.Normal | Usage.TextureCoordinates); model.manageDisposable(diffuseTexture); model.manageDisposable(emissiveTexture);
.createShininess(16f)), Usage.Position | Usage.Normal); disposables.add(groundModel); final Model boxModel = modelBuilder.createBox(1f, 1f, 1f, new Material(ColorAttribute.createDiffuse(Color.WHITE), ColorAttribute.createSpecular(Color.WHITE), FloatAttribute.createShininess(64f)), Usage.Position | Usage.Normal); disposables.add(boxModel);
final Model occluderModel = modelBuilder.createBox(OCCLUDER_DIM.x, OCCLUDER_DIM.y, OCCLUDER_DIM.z, new Material(ColorAttribute.createDiffuse(Color.WHITE)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal); final Model groundModel = modelBuilder.createBox(GROUND_DIM.x, GROUND_DIM.y, GROUND_DIM.z, new Material(ColorAttribute.createDiffuse(Color.WHITE)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal); instance = new ModelInstance(model);
FloatAttribute.createShininess(128)); Texture checkboard = new Texture(Gdx.files.internal("data/g3d/checkboard.png")); final Model largeGroundModel = modelBuilder.createBox( 200f, 2f,
/** 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, final Material material, final long attributes) { return createBox(width, height, depth, GL20.GL_TRIANGLES, material, attributes); }
private Model createModel() { ModelBuilder modelBuilder = new ModelBuilder(); Model model = modelBuilder.createBox(1, 1, 1, new Material(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap)), VertexAttributes.Usage.Position); return model; }
private void drawBlockSelection() { int curProgressInt = Math.round(RadixClient.getInstance().getPlayer().getBreakPercent() * 10) - 1; if ((blockBreakModel == null || blockBreakStage != curProgressInt) && curProgressInt >= 0) { if (blockBreakModel != null) blockBreakModel.dispose(); blockBreakStage = curProgressInt; ModelBuilder builder = new ModelBuilder(); blockBreakModel = builder.createBox(1f, 1f, 1f, new Material(TextureAttribute.createDiffuse(blockBreakStages[blockBreakStage]), new BlendingAttribute(), FloatAttribute.createAlphaTest(0.25f)), VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates); blockBreakModelInstance = new ModelInstance(blockBreakModel); } Vec3i curBlk = RadixClient.getInstance().getSelectedBlock(); if (curBlk != null && curProgressInt >= 0) { Gdx.gl.glPolygonOffset(100000, 2000000); blockOverlayBatch.begin(RadixClient.getInstance().getCamera()); blockBreakModelInstance.transform.translate(curBlk.x + 0.5f, curBlk.y + 0.5f, curBlk.z + 0.5f); blockOverlayBatch.render(blockBreakModelInstance); blockBreakModelInstance.transform.translate(-(curBlk.x + 0.5f), -(curBlk.y + 0.5f), -(curBlk.z + 0.5f)); blockOverlayBatch.end(); Gdx.gl.glPolygonOffset(100000, -2000000); } }
public ScaleTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker, ShapeRenderer shapeRenderer, ModelBatch batch, CommandHistory history) { super(projectManager, goPicker, handlePicker, batch, history); this.shapeRenderer = shapeRenderer; ModelBuilder modelBuilder = new ModelBuilder(); Model xPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_X)), Vector3.Zero, new Vector3(15, 0, 0)); Model yPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Y)), Vector3.Zero, new Vector3(0, 15, 0)); Model zPlaneHandleModel = UsefulMeshs.createArrowStub(new Material(ColorAttribute.createDiffuse(COLOR_Z)), Vector3.Zero, new Vector3(0, 0, 15)); Model xyzPlaneHandleModel = modelBuilder.createBox(3, 3, 3, new Material(ColorAttribute.createDiffuse(COLOR_XYZ)), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal); xHandle = new ScaleHandle(X_HANDLE_ID, xPlaneHandleModel); yHandle = new ScaleHandle(Y_HANDLE_ID, yPlaneHandleModel); zHandle = new ScaleHandle(Z_HANDLE_ID, zPlaneHandleModel); xyzHandle = new ScaleHandle(XYZ_HANDLE_ID, xyzPlaneHandleModel); handles = new ScaleHandle[] { xHandle, yHandle, zHandle, xyzHandle }; }