Java Code Examples for com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder#rect()
The following examples show how to use
com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder#rect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModelFactory.java From GdxDemo3D with Apache License 2.0 | 6 votes |
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(); 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()); }
Example 2
Source File: Utils3D.java From bladecoder-adventure-engine with Apache License 2.0 | 6 votes |
public static void createFloor() { 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, -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)); }
Example 3
Source File: ModelManager.java From gdx-proto with Apache License 2.0 | 6 votes |
public void createBillboardTest() { ModelBuilder mb = new ModelBuilder(); mb.begin(); long attr = Usage.TextureCoordinates | Usage.Position | Usage.Normal; TextureRegion region = Assets.getAtlas().findRegion("sprites/test-guy"); Material mat = new Material(TextureAttribute.createDiffuse(region.getTexture())); boolean blended = true; float opacity = 1f; mat.set(new BlendingAttribute(blended, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, opacity)); MeshPartBuilder mpb = mb.part("rect", GL20.GL_TRIANGLES, attr, mat); mpb.setUVRange(region); // the coordinates are offset so that we can easily set the center position to align with the entity's body float sz = 2f; // size float b = -sz/2; // base float max = sz/2; // max Vector3 bl = new Vector3(b, b, 0f); Vector3 br = new Vector3(b, max, 0f); Vector3 tr = new Vector3(max, max, 0f); Vector3 tl = new Vector3(max, b, 0f); Vector3 norm = new Vector3(0f, 0f, 1f); mpb.rect(bl, tl, tr, br, norm); billboardTestModel = mb.end(); }
Example 4
Source File: UsefulMeshs.java From Mundus with Apache License 2.0 | 4 votes |
public static Model torus(Material mat, float width, float height, int divisionsU, int divisionsV) { ModelBuilder modelBuilder = new ModelBuilder(); modelBuilder.begin(); MeshPartBuilder builder = modelBuilder.part("torus", GL20.GL_TRIANGLES, VertexAttributes.Usage.Position, mat); // builder.setColor(Color.LIGHT_GRAY); MeshPartBuilder.VertexInfo curr1 = v0.set(null, null, null, null); curr1.hasUV = curr1.hasNormal = false; curr1.hasPosition = true; MeshPartBuilder.VertexInfo curr2 = v1.set(null, null, null, null); curr2.hasUV = curr2.hasNormal = false; curr2.hasPosition = true; short i1, i2, i3 = 0, i4 = 0; int i, j, k; double s, t, twopi; twopi = 2 * Math.PI; for (i = 0; i < divisionsV; i++) { for (j = 0; j <= divisionsU; j++) { for (k = 1; k >= 0; k--) { s = (i + k) % divisionsV + 0.5; t = j % divisionsU; curr1.position.set( (float) ((width + height * Math.cos(s * twopi / divisionsV)) * Math.cos(t * twopi / divisionsU)), (float) ((width + height * Math.cos(s * twopi / divisionsV)) * Math.sin(t * twopi / divisionsU)), (float) (height * Math.sin(s * twopi / divisionsV))); k--; s = (i + k) % divisionsV + 0.5; curr2.position.set( (float) ((width + height * Math.cos(s * twopi / divisionsV)) * Math.cos(t * twopi / divisionsU)), (float) ((width + height * Math.cos(s * twopi / divisionsV)) * Math.sin(t * twopi / divisionsU)), (float) (height * Math.sin(s * twopi / divisionsV))); // curr2.uv.set((float) s, 0); i1 = builder.vertex(curr1); i2 = builder.vertex(curr2); builder.rect(i4, i2, i1, i3); i4 = i2; i3 = i1; } } } return modelBuilder.end(); }