com.badlogic.gdx.graphics.VertexAttributes Java Examples

The following examples show how to use com.badlogic.gdx.graphics.VertexAttributes. 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: NavMeshGraph.java    From GdxDemo3D with Apache License 2.0 6 votes vote down vote up
/**
 * Creates Vector3 objects from the vertices of the mesh. The resulting array follows the ordering of the provided
 * index array.
 *
 * @param mesh
 * @param indices
 * @return
 */
private static Vector3[] createVertexVectors(Mesh mesh, short[] indices) {
	FloatBuffer verticesBuffer = mesh.getVerticesBuffer();
	int positionOffset = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Position).offset / 4;
	int vertexSize = mesh.getVertexSize() / 4;
	Vector3[] vertexVectors = new Vector3[mesh.getNumIndices()];
	for (int i = 0; i < indices.length; i++) {
		short index = indices[i];
		int a = index * vertexSize + positionOffset;
		float x = verticesBuffer.get(a++);
		float y = verticesBuffer.get(a++);
		float z = verticesBuffer.get(a);
		vertexVectors[index] = new Vector3(x, y, z);
	}
	return vertexVectors;
}
 
Example #2
Source File: ScaleTool.java    From Mundus with Apache License 2.0 6 votes vote down vote up
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 };
}
 
Example #3
Source File: UsefulMeshs.java    From Mundus with Apache License 2.0 6 votes vote down vote up
public static Model createAxes() {
    final float GRID_MIN = -10f;
    final float GRID_MAX = 10f;
    final float GRID_STEP = 1f;
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder builder = modelBuilder.part("grid", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.LIGHT_GRAY);
    for (float t = GRID_MIN; t <= GRID_MAX; t += GRID_STEP) {
        builder.line(t, 0, GRID_MIN, t, 0, GRID_MAX);
        builder.line(GRID_MIN, 0, t, GRID_MAX, 0, t);
    }
    builder = modelBuilder.part("axes", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, new Material());
    builder.setColor(Color.RED);
    builder.line(0, 0, 0, 100, 0, 0);
    builder.setColor(Color.GREEN);
    builder.line(0, 0, 0, 0, 100, 0);
    builder.setColor(Color.BLUE);
    builder.line(0, 0, 0, 0, 0, 100);
    return modelBuilder.end();
}
 
Example #4
Source File: Terrain.java    From Mundus with Apache License 2.0 6 votes vote down vote up
private Terrain(int vertexResolution) {
    this.transform = new Matrix4();
    this.attribs = MeshBuilder.createAttributes(VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal
            | VertexAttributes.Usage.TextureCoordinates);
    this.posPos = attribs.getOffset(VertexAttributes.Usage.Position, -1);
    this.norPos = attribs.getOffset(VertexAttributes.Usage.Normal, -1);
    this.uvPos = attribs.getOffset(VertexAttributes.Usage.TextureCoordinates, -1);
    this.stride = attribs.vertexSize / 4;

    this.vertexResolution = vertexResolution;
    this.heightData = new float[vertexResolution * vertexResolution];

    this.terrainTexture = new TerrainTexture();
    this.terrainTexture.setTerrain(this);
    material = new Material();
    material.set(new TerrainTextureAttribute(TerrainTextureAttribute.ATTRIBUTE_SPLAT0, terrainTexture));
}
 
Example #5
Source File: Main.java    From graphicsfuzz with Apache License 2.0 5 votes vote down vote up
private Mesh buildMeshFromVerticesAndTexCoords(List<Double> vertexCoords, List<Double> texCoords) {
  if ((vertexCoords.size() % 3) != 0) {
    throw new RuntimeException("Vertex coordinates size is " + vertexCoords.size() + "; must be a multiple of 3");
  }
  if ((texCoords.size() % 2) != 0) {
    throw new RuntimeException("Texture coordinates size is " + texCoords.size() + "; must be a multiple of 2");
  }
  if (vertexCoords.size() / 3 != texCoords.size() / 2) {
    throw new RuntimeException("There is vertex data for " + vertexCoords.size() / 3 + " triangle(s), "
            + "and texture data for " + texCoords.size() / 2 + " triangle(s) -- these should match");
  }

  float[] data = new float[vertexCoords.size() + texCoords.size()];
  int vertexIndex = 0;
  int texIndex = 0;
  int dataIndex = 0;
  for (int i = 0; i < vertexCoords.size() / 3; i++) {
    data[dataIndex++] = (float) vertexCoords.get(vertexIndex++).doubleValue();
    data[dataIndex++] = (float) vertexCoords.get(vertexIndex++).doubleValue();
    data[dataIndex++] = (float) vertexCoords.get(vertexIndex++).doubleValue();
    data[dataIndex++] = (float) texCoords.get(texIndex++).doubleValue();
    data[dataIndex++] = (float) texCoords.get(texIndex++).doubleValue();
  }
  Mesh mesh = new Mesh( true, vertexCoords.size() / 3, 0,
          new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE),
          new VertexAttribute(VertexAttributes.Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
  mesh.setVertices(data);
  return mesh;
}
 
Example #6
Source File: AreaMesh.java    From Cubes with MIT License 5 votes vote down vote up
public AreaMesh(VertexAttributes vertexAttributes) {
  mesh = new Mesh(true, MAX_VERTICES, MAX_INDICES, vertexAttributes);
  meshPart = new MeshPart();
  meshPart.mesh = mesh;
  meshPart.primitiveType = GL20.GL_TRIANGLES;
  meshPart.offset = 0;
  mesh.setIndices(indices);

  int components = CubesVertexAttributes.components(vertexAttributes);
  maxVertexOffset = MAX_VERTICES * components;

  renderable.material = Assets.blockItemSheet.getMaterial();
  renderable.name = "AreaMesh";
}
 
Example #7
Source File: NavMeshGraph.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
/**
 * Get an array of the vertex indices from the mesh. Any vertices which share the same position will be counted
 * as a single vertex and share the same index. That is, position duplicates will be filtered out.
 *
 * @param mesh
 * @return
 */
private static short[] getUniquePositionVertexIndices(Mesh mesh) {
	FloatBuffer verticesBuffer = mesh.getVerticesBuffer();
	int positionOffset = mesh.getVertexAttributes().findByUsage(VertexAttributes.Usage.Position).offset / 4;
	// Number of array elements which make up a vertex
	int vertexSize = mesh.getVertexSize() / 4;
	// The indices tell us which vertices are part of a triangle.
	short[] indices = new short[mesh.getNumIndices()];
	mesh.getIndices(indices);
	// Marks true if an index has already been compared to avoid unnecessary comparisons
	Bits handledIndices = new Bits(mesh.getNumIndices());

	for (int i = 0; i < indices.length; i++) {
		short indexI = indices[i];
		if (handledIndices.get(indexI)) {
			// Index handled in an earlier iteration
			continue;
		}
		int vBufIndexI = indexI * vertexSize + positionOffset;
		float xi = verticesBuffer.get(vBufIndexI++);
		float yi = verticesBuffer.get(vBufIndexI++);
		float zi = verticesBuffer.get(vBufIndexI++);
		for (int j = i + 1; j < indices.length; j++) {
			short indexJ = indices[j];
			int vBufIndexJ = indexJ * vertexSize + positionOffset;
			float xj = verticesBuffer.get(vBufIndexJ++);
			float yj = verticesBuffer.get(vBufIndexJ++);
			float zj = verticesBuffer.get(vBufIndexJ++);
			if (xi == xj && yi == yj && zi == zj) {
				indices[j] = indexI;
			}
		}
		handledIndices.set(indexI);
	}
	return indices;
}
 
Example #8
Source File: TranslateTool.java    From Mundus with Apache License 2.0 5 votes vote down vote up
public TranslateTool(ProjectManager projectManager, GameObjectPicker goPicker, ToolHandlePicker handlePicker,
        ModelBatch batch, CommandHistory history) {

    super(projectManager, goPicker, handlePicker, batch, history);

    ModelBuilder modelBuilder = new ModelBuilder();

    Model xHandleModel = modelBuilder.createArrow(0, 0, 0, 1, 0, 0, ARROW_CAP_SIZE, ARROW_THIKNESS, ARROW_DIVISIONS,
            GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(COLOR_X)),
            VertexAttributes.Usage.Position);
    Model yHandleModel = modelBuilder.createArrow(0, 0, 0, 0, 1, 0, ARROW_CAP_SIZE, ARROW_THIKNESS, ARROW_DIVISIONS,
            GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(COLOR_Y)),
            VertexAttributes.Usage.Position);
    Model zHandleModel = modelBuilder.createArrow(0, 0, 0, 0, 0, 1, ARROW_CAP_SIZE, ARROW_THIKNESS, ARROW_DIVISIONS,
            GL20.GL_TRIANGLES, new Material(ColorAttribute.createDiffuse(COLOR_Z)),
            VertexAttributes.Usage.Position);
    Model xzPlaneHandleModel = modelBuilder.createSphere(1, 1, 1, 20, 20,
            new Material(ColorAttribute.createDiffuse(COLOR_XZ)), VertexAttributes.Usage.Position);

    xHandle = new TranslateHandle(X_HANDLE_ID, xHandleModel);
    yHandle = new TranslateHandle(Y_HANDLE_ID, yHandleModel);
    zHandle = new TranslateHandle(Z_HANDLE_ID, zHandleModel);
    xzPlaneHandle = new TranslateHandle(XZ_HANDLE_ID, xzPlaneHandleModel);
    handles = new TranslateHandle[] { xHandle, yHandle, zHandle, xzPlaneHandle };

    gameObjectModifiedEvent = new GameObjectModifiedEvent(null);
}
 
Example #9
Source File: UsefulMeshs.java    From Mundus with Apache License 2.0 5 votes vote down vote up
public static Model createArrowStub(Material mat, Vector3 from, Vector3 to) {
    ModelBuilder modelBuilder = new ModelBuilder();
    modelBuilder.begin();
    MeshPartBuilder meshBuilder;
    // line
    meshBuilder = modelBuilder.part("line", GL20.GL_LINES,
            VertexAttributes.Usage.Position | VertexAttributes.Usage.ColorUnpacked, mat);
    meshBuilder.line(from.x, from.y, from.z, to.x, to.y, to.z);
    // stub
    Node node = modelBuilder.node();
    node.translation.set(to.x, to.y, to.z);
    meshBuilder = modelBuilder.part("stub", GL20.GL_TRIANGLES, Usage.Position | Usage.Normal, mat);
    BoxShapeBuilder.build(meshBuilder, 2, 2, 2);
    return modelBuilder.end();
}
 
Example #10
Source File: Skybox.java    From Mundus with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example #11
Source File: GreedyMesher.java    From Radix with MIT License 5 votes vote down vote up
public Mesh meshFaces(List<Face> faces, MeshBuilder builder) {
    builder.begin(VertexAttributes.Usage.Position | VertexAttributes.Usage.TextureCoordinates | VertexAttributes.Usage.ColorPacked | VertexAttributes.Usage.Normal, GL20.GL_TRIANGLES);

    builder.ensureVertices(faces.size() * 4);
    for (Face f : faces) {
        f.render(builder);
    }
    return builder.end();
}
 
Example #12
Source File: GameRenderer.java    From Radix with MIT License 5 votes vote down vote up
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);
    }
}
 
Example #13
Source File: Benchmark.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
protected void assertConsistent(Model model) {
	
	final long expectedAttributes = VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal | VertexAttributes.Usage.TextureCoordinates;
	
	assertEquals(0, model.animations.size);
	// assertEquals(1, model.materials.size); TODO GLTF should collect that?
	assertEquals(4, model.meshes.size);
	// assertEquals(1, model.meshParts.size); TODO GLTF should collect that?
	assertEquals(4, model.nodes.size);
	
	for(Node node : model.nodes){
		assertEquals(0, node.getChildCount());
		assertEquals(1, node.parts.size);
		MeshPart mp = node.parts.first().meshPart;
		assertEquals(0, mp.offset);
		assertEquals(GL20.GL_TRIANGLES, mp.primitiveType); 
		assertEquals(36864, mp.size);
		assertEquals(expectedAttributes, mp.mesh.getVertexAttributes().getMask());
		boolean isIndexed = mp.mesh.getNumIndices() > 0;
		if(isIndexed){ // XXX OBJ doesn't have indexed meshes
			assertEquals(24576, mp.mesh.getNumVertices());
			assertEquals(36864, mp.mesh.getNumIndices());
		}else{
			assertEquals(36864, mp.mesh.getNumVertices());
		}
	}
}
 
Example #14
Source File: SceneSkybox.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public SceneSkybox(Cubemap cubemap){
	super();
	
	// create shader provider
	Config shaderConfig = new Config();
	String basePathName = "net/mgsx/gltf/shaders/skybox";
	shaderConfig.vertexShader = Gdx.files.classpath(basePathName + ".vs.glsl").readString();
	shaderConfig.fragmentShader = Gdx.files.classpath(basePathName + ".fs.glsl").readString();
	shaderProvider =  new DefaultShaderProvider(shaderConfig);
	
	// create box
	float boxScale = (float)(1.0 / Math.sqrt(2.0));
	boxModel = new ModelBuilder().createBox(boxScale, boxScale, boxScale, new Material(), VertexAttributes.Usage.Position);
	box = boxModel.nodes.first().parts.first().setRenderable(new Renderable());
	
	// assign environment
	Environment env = new Environment();
	env.set(new CubemapAttribute(CubemapAttribute.EnvironmentMap, cubemap));
	env.set(new ColorAttribute(ColorAttribute.AmbientLight, Color.WHITE));
	box.environment = env;
	
	// set hint to render last but before transparent ones
	box.userData = SceneRenderableSorter.Hints.OPAQUE_LAST;
	
	// set material options : preserve background depth
	box.material = new Material(ColorAttribute.createDiffuse(Color.WHITE));
	box.material.set(new DepthTestAttribute(false));
	
	
	// assign shader
	box.shader = shaderProvider.getShader(box);
}
 
Example #15
Source File: PBRDepthShader.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
protected long computeMorphTargetsMask(Renderable renderable){
	int morphTargetsFlag = 0;
	VertexAttributes vertexAttributes = renderable.meshPart.mesh.getVertexAttributes();
	final int n = vertexAttributes.size();
	for (int i = 0; i < n; i++) {
		final VertexAttribute attr = vertexAttributes.get(i);
		if (attr.usage == PBRVertexAttributes.Usage.PositionTarget) morphTargetsFlag |= (1 << attr.unit);
	}
	return morphTargetsFlag;
}
 
Example #16
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
public long computeMorphTargetsMask(Renderable renderable){
	int morphTargetsFlag = 0;
	VertexAttributes vertexAttributes = renderable.meshPart.mesh.getVertexAttributes();
	final int n = vertexAttributes.size();
	for (int i = 0; i < n; i++) {
		final VertexAttribute attr = vertexAttributes.get(i);
		if (attr.usage == PBRVertexAttributes.Usage.PositionTarget) morphTargetsFlag |= (1 << attr.unit);
		if (attr.usage == PBRVertexAttributes.Usage.NormalTarget) morphTargetsFlag |= (1 << (attr.unit + 8));
		if (attr.usage == PBRVertexAttributes.Usage.TangentTarget) morphTargetsFlag |= (1 << (attr.unit + 16));
	}
	return morphTargetsFlag;
}
 
Example #17
Source File: PBRShader.java    From gdx-gltf with Apache License 2.0 5 votes vote down vote up
private int computeVertexColorLayers(Renderable renderable) {
	int num = 0;
	VertexAttributes vertexAttributes = renderable.meshPart.mesh.getVertexAttributes();
	final int n = vertexAttributes.size();
	for (int i = 0; i < n; i++) {
		final VertexAttribute attr = vertexAttributes.get(i);
		if (attr.usage == VertexAttributes.Usage.ColorUnpacked) num++;
	}
	return num;
}
 
Example #18
Source File: Main.java    From graphicsfuzz with Apache License 2.0 5 votes vote down vote up
private Mesh buildMeshFromVertices(List<Double> vertexCoords) {
  if ((vertexCoords.size() % 3) != 0) {
    throw new RuntimeException("Vertex coordinates size is " + vertexCoords.size() + "; must be a multiple of 3");
  }
  float[] data = new float[vertexCoords.size()];
  for (int i = 0; i < vertexCoords.size(); i++) {
    data[i] = (float) vertexCoords.get(i).doubleValue();
  }
  Mesh mesh = new Mesh( true, vertexCoords.size() / 3, 0,
          new VertexAttribute(VertexAttributes.Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
  mesh.setVertices(data);
  return mesh;
}
 
Example #19
Source File: G3dtLoader.java    From uracer-kotd with Apache License 2.0 4 votes vote down vote up
private static StillSubMesh readStillSubMesh (BufferedReader in, boolean flipV) throws IOException {
	String name = readString(in);
	IntArray indices = readFaces(in);
	int numVertices = readInt(in);
	int numAttributes = readInt(in);

	if (!readString(in).equals("position")) throw new GdxRuntimeException("first attribute must be position.");
	int numUvs = 0;
	boolean hasNormals = false;
	for (int i = 1; i < numAttributes; i++) {
		String attributeType = readString(in);

		if (!attributeType.equals("normal") && !attributeType.equals("uv"))
			throw new GdxRuntimeException("attribute name must be normal or uv");

		if (attributeType.equals("normal")) {
			if (i != 1) throw new GdxRuntimeException("attribute normal must be second attribute");
			hasNormals = true;
		}
		if (attributeType.equals("uv")) {
			numUvs++;
		}
	}
	VertexAttribute[] vertexAttributes = createVertexAttributes(hasNormals, numUvs);
	int vertexSize = new VertexAttributes(vertexAttributes).vertexSize / 4;
	float[] vertices = new float[numVertices * vertexSize];
	int idx = 0;
	int uvOffset = hasNormals ? 6 : 3;
	for (int i = 0; i < numVertices; i++) {
		readFloatArray(in, vertices, idx);
		if (flipV) {
			for (int j = idx + uvOffset + 1; j < idx + uvOffset + numUvs * 2; j += 2) {
				vertices[j] = 1 - vertices[j];
			}
		}
		idx += vertexSize;
	}

	Mesh mesh = new Mesh(true, numVertices, indices.size, vertexAttributes);
	mesh.setVertices(vertices);
	mesh.setIndices(convertToShortArray(indices));
	return new StillSubMesh(name, mesh, GL20.GL_TRIANGLES);
}
 
Example #20
Source File: UsefulMeshs.java    From Mundus with Apache License 2.0 4 votes vote down vote up
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();
    }
 
Example #21
Source File: CubesVertexAttributes.java    From Cubes with MIT License 4 votes vote down vote up
public static VertexAttributes getVertexAttributes() {
  if (AmbientOcclusion.isEnabled()) return VERTEX_ATTRIBUTES_AO;
  return VERTEX_ATTRIBUTES;
}