List of usage examples for com.badlogic.gdx.graphics.g3d.utils MeshPartBuilder rect
public void rect(float x00, float y00, float z00, float x10, float y10, float z10, float x11, float y11, float z11, float x01, float y01, float z01, float normalX, float normalY, float normalZ);
From source file:com.bladecoder.engine.util.Utils3D.java
License:Apache License
public static void createFloor() { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin();/*from ww w .j a v a2 s.co m*/ 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, -0.1f, 0, 10, .2f, 10); mpb.rect(-10, 0, -10, -10, 0, 10, 10, 0, 10, 10, 0, -10, 0, 1, 0); floorModel = modelBuilder.end(); floorInstance = new ModelInstance(floorModel); // TODO Set only when FBO is active floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)); }
From source file:com.mygdx.game.utilities.ModelFactory.java
License:Apache License
public static Model buildPlaneModel(final float width, final float height, final Material material, final float u1, final float v1, final float u2, final float v2) { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin();//from www . j a va 2 s.c o m MeshPartBuilder bPartBuilder = modelBuilder.part("rect", GL20.GL_TRIANGLES, VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates, material); bPartBuilder.setUVRange(u1, v1, u2, v2); bPartBuilder.rect(-(width * 0.5f), -(height * 0.5f), 0, (width * 0.5f), -(height * 0.5f), 0, (width * 0.5f), (height * 0.5f), 0, -(width * 0.5f), (height * 0.5f), 0, 0, 0, -1); return (modelBuilder.end()); }
From source file:org.bladecoder.bladeengine.util.Utils3D.java
License:Apache License
public static void createFloor() { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin();//from w w w. j a v a2 s . co m MeshPartBuilder mpb = modelBuilder.part("parts", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal | Usage.Color, new Material(ColorAttribute.createDiffuse(Color.WHITE))); mpb.setColor(1f, 1f, 1f, 1f); // mpb.box(0, -0.1f, 0, 10, .2f, 10); mpb.rect(-10, 0, -10, -10, 0, 10, 10, 0, 10, 10, 0, -10, 0, 1, 0); floorModel = modelBuilder.end(); floorInstance = new ModelInstance(floorModel); // TODO Set only when FBO is active floorInstance.materials.get(0).set(new BlendingAttribute(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)); }
From source file:scene3d.demo.Scene3dDemo.java
License:Apache License
@Override public void create() { //2d stuff//from w w w .j av a 2s. c o m stage2d = new Stage(); skin = new Skin(Gdx.files.internal("skin/uiskin.json")); fpsLabel = new Label("ff", skin); fpsLabel.setPosition(Gdx.graphics.getWidth() - 260, Gdx.graphics.getHeight() - 40); visibleLabel = new Label("ff", skin); visibleLabel.setPosition(Gdx.graphics.getWidth() - 260, Gdx.graphics.getHeight() - 60); positionLabel = new Label("Position", skin); positionLabel.setPosition(Gdx.graphics.getWidth() - 260, Gdx.graphics.getHeight() - 80); rotationLabel = new Label("Rotation", skin); rotationLabel.setPosition(Gdx.graphics.getWidth() - 260, Gdx.graphics.getHeight() - 100); positionCameraLabel = new Label("Position", skin); positionCameraLabel.setPosition(20, Gdx.graphics.getHeight() - 40); rotationCameraLabel = new Label("Rotation", skin); rotationCameraLabel.setPosition(20, Gdx.graphics.getHeight() - 60); stage2d.addActor(fpsLabel); stage2d.addActor(visibleLabel); stage2d.addActor(positionLabel); stage2d.addActor(rotationLabel); stage2d.addActor(positionCameraLabel); stage2d.addActor(rotationCameraLabel); stage2d.addListener(new InputListener() { @Override public boolean keyUp(InputEvent event, int keycode) { if (keycode == Keys.LEFT) leftKey = false; if (keycode == Keys.RIGHT) rightKey = false; if (keycode == Keys.UP) upKey = false; if (keycode == Keys.DOWN) downKey = false; if (keycode == Keys.SPACE) spaceKey = false; return super.keyUp(event, keycode); } @Override public boolean keyDown(InputEvent event, int keycode) { if (keycode == Keys.LEFT) leftKey = true; if (keycode == Keys.RIGHT) rightKey = true; if (keycode == Keys.UP) upKey = true; if (keycode == Keys.DOWN) downKey = true; if (keycode == Keys.SPACE) spaceKey = true; return super.keyDown(event, keycode); } }); //3dstuff stage3d = new Stage3d(); modelBuilder = new ModelBuilder(); model = modelBuilder.createBox(5f, 5f, 5f, new Material("Color", ColorAttribute.createDiffuse(Color.WHITE)), Usage.Position | Usage.Normal); model2 = modelBuilder.createBox(2f, 2f, 2f, new Material("Color", ColorAttribute.createDiffuse(Color.WHITE)), Usage.Position | Usage.Normal); actor2 = new Actor3d(model2, 10f, 0f, 0f); model3 = modelBuilder.createBox(2f, 2f, 2f, new Material("Color", ColorAttribute.createDiffuse(Color.ORANGE)), Usage.Position | Usage.Normal); actor3 = new Actor3d(model3, -10f, 0f, 0f); actor2.setColor(Color.RED); actor2.setName("actor2"); actor3.setName("actor3"); camController = new CameraInputController(stage3d.getCamera()); InputMultiplexer im = new InputMultiplexer(); im.addProcessor(stage2d);// 2d should get click events first //im.addProcessor(stage3d); im.addProcessor(camController); Gdx.input.setInputProcessor(im); stage3d.touchable = Touchable.enabled; // only then will it detect hit actor3d ModelBuilder builder = new ModelBuilder(); builder.begin(); MeshPartBuilder part = builder.part("floor", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal, new Material()); for (float x = -200f; x < 200f; x += 10f) { for (float z = -200f; z < 200f; z += 10f) { part.rect(x, 0, z + 10f, x + 10f, 0, z + 10f, x + 10f, 0, z, x, 0, z, 0, 1, 0); } } floor = new Actor3d(builder.end()); AssetManager am = new AssetManager(); am.load("data/g3d/knight.g3db", Model.class); am.load("data/g3d/skydome.g3db", Model.class); am.load("data/g3d/concrete.png", Texture.class); am.finishLoading(); knight = new Actor3d(am.get("data/g3d/knight.g3db", Model.class), 0f, 18f, 0f); knight.getAnimation().inAction = true; knight.getAnimation().animate("Walk", -1, 1f, null, 0.2f); skydome = new Actor3d(am.get("data/g3d/skydome.g3db", Model.class)); floor.materials.get(0).set(TextureAttribute.createDiffuse(am.get("data/g3d/concrete.png", Texture.class))); stage3d.addActor3d(skydome); stage3d.addActor3d(floor); knight.setPitch(-90f); knight.setYaw(-130f); testActor3d(); //stage3d.addAction3d(Actions3d.rotateBy(0f, 90f, 0f, 2f)); //testGroup3d(); //testStage3d(); }