com.badlogic.gdx.graphics.Mesh Java Examples
The following examples show how to use
com.badlogic.gdx.graphics.Mesh.
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: PositionalLight.java From uracer-kotd with Apache License 2.0 | 6 votes |
PositionalLight( RayHandler rayHandler, int rays, Color color, float distance, float x, float y, float directionDegree ) { super( rayHandler, rays, color, directionDegree, distance ); start.x = x; start.y = y; sin = new float[ rays ]; cos = new float[ rays ]; endX = new float[ rays ]; endY = new float[ rays ]; lightMesh = new Mesh( VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute( Usage.Position, 2, "vertex_positions" ), new VertexAttribute( Usage.ColorPacked, 4, "quad_colors" ), new VertexAttribute( Usage.Generic, 1, "s" ) ); softShadowMesh = new Mesh( VertexDataType.VertexArray, staticLight, vertexNum * 2, 0, new VertexAttribute( Usage.Position, 2, "vertex_positions" ), new VertexAttribute( Usage.ColorPacked, 4, "quad_colors" ), new VertexAttribute( Usage.Generic, 1, "s" ) ); setMesh(); }
Example #2
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 6 votes |
private void renderCurrentShader(String name, Mesh mesh) throws com.graphicsfuzz.glesworker.GlErrorException { Gdx.app.log("Main", "renderCurrentShader " + name); program.begin(); checkForGlError(); UniformSetter.setUniforms(program, uniformDict, gl30); long start = System.nanoTime(); mesh.render(program, GL20.GL_TRIANGLES); long end = System.nanoTime(); Gdx.app.log("Main", "mesh.render: " + (end - start) + " ns"); checkForGlError(); program.end(); checkForGlError(); Gdx.gl.glFlush(); checkForGlError(); Gdx.gl.glFinish(); checkForGlError(); }
Example #3
Source File: Renderer20.java From fluid-simulator-v2 with Apache License 2.0 | 6 votes |
public Renderer20 (int maxVertices, boolean hasNormals, boolean hasColors, int numTexCoords, ShaderProgram shader) { this.maxVertices = maxVertices; this.numTexCoords = numTexCoords; this.shader = shader; VertexAttribute[] attribs = buildVertexAttributes(hasNormals, hasColors, numTexCoords); mesh = new Mesh(false, maxVertices, 0, attribs); vertices = new float[maxVertices * (mesh.getVertexAttributes().vertexSize / 4)]; vertexSize = mesh.getVertexAttributes().vertexSize / 4; normalOffset = mesh.getVertexAttribute(Usage.Normal) != null ? mesh.getVertexAttribute(Usage.Normal).offset / 4 : 0; colorOffset = mesh.getVertexAttribute(Usage.ColorPacked) != null ? mesh.getVertexAttribute(Usage.ColorPacked).offset / 4 : 0; texCoordOffset = mesh.getVertexAttribute(Usage.TextureCoordinates) != null ? mesh .getVertexAttribute(Usage.TextureCoordinates).offset / 4 : 0; }
Example #4
Source File: Terrain.java From Mundus with Apache License 2.0 | 6 votes |
public void init() { final int numVertices = this.vertexResolution * vertexResolution; final int numIndices = (this.vertexResolution - 1) * (vertexResolution - 1) * 6; mesh = new Mesh(true, numVertices, numIndices, attribs); this.vertices = new float[numVertices * stride]; mesh.setIndices(buildIndices()); buildVertices(); mesh.setVertices(vertices); MeshPart meshPart = new MeshPart(null, mesh, 0, numIndices, GL20.GL_TRIANGLES); meshPart.update(); ModelBuilder mb = new ModelBuilder(); mb.begin(); mb.part(meshPart, material); model = mb.end(); modelInstance = new ModelInstance(model); modelInstance.transform = transform; }
Example #5
Source File: GLTFExporter.java From gdx-gltf with Apache License 2.0 | 6 votes |
/** convenient method to export a single mesh * primitiveType can be any of OpenGL primitive: * {@link com.badlogic.gdx.graphics.GL20#GL_POINTS}, * {@link com.badlogic.gdx.graphics.GL20#GL_LINES}, * {@link com.badlogic.gdx.graphics.GL20#GL_LINE_STRIP}, * {@link com.badlogic.gdx.graphics.GL20#GL_TRIANGLES}, * {@link com.badlogic.gdx.graphics.GL20#GL_TRIANGLE_STRIP}, * {@link com.badlogic.gdx.graphics.GL20#GL_TRIANGLE_FAN}, * etc.. * */ public void export(Mesh mesh, int primitiveType, FileHandle file){ GLTFScene scene = beginSingleScene(file); GLTFNode glNode = obtainNode(); scene.nodes = new Array<Integer>(); scene.nodes.add(root.nodes.size-1); GLTFMesh gltfMesh = obtainMesh(); glNode.mesh = root.meshes.size-1; MeshPart meshPart = new MeshPart(); meshPart.mesh = mesh; meshPart.offset = 0; meshPart.primitiveType = primitiveType; meshPart.size = mesh.getNumIndices(); if(meshPart.size == 0) meshPart.size = mesh.getNumVertices(); gltfMesh.primitives = new Array<GLTFPrimitive>(); GLTFPrimitive primitive = meshExporter.exportMeshPart(meshPart); gltfMesh.primitives.add(primitive); end(file); }
Example #6
Source File: NavMeshGraph.java From GdxDemo3D with Apache License 2.0 | 6 votes |
/** * 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 #7
Source File: ChainLight.java From box2dlights with Apache License 2.0 | 5 votes |
/** * Creates chain light from specified vertices * * @param rayHandler * not {@code null} instance of RayHandler * @param rays * number of rays - more rays make light to look more realistic * but will decrease performance, can't be less than MIN_RAYS * @param color * color, set to {@code null} to use the default color * @param distance * distance of light * @param rayDirection * direction of rays * <ul> * <li>1 = left</li> * <li>-1 = right</li> * </ul> * @param chain * float array of (x, y) vertices from which rays will be * evenly distributed */ public ChainLight(RayHandler rayHandler, int rays, Color color, float distance, int rayDirection, float[] chain) { super(rayHandler, rays, color, distance, 0f); rayStartOffset = ChainLight.defaultRayStartOffset; this.rayDirection = rayDirection; vertexNum = (vertexNum - 1) * 2; endX = new float[rays]; endY = new float[rays]; startX = new float[rays]; startY = new float[rays]; this.chain = (chain != null) ? new FloatArray(chain) : new FloatArray(); lightMesh = new Mesh( VertexDataType.VertexArray, false, vertexNum, 0, new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute(Usage.Generic, 1, "s")); softShadowMesh = new Mesh( VertexDataType.VertexArray, false, vertexNum * 2, 0, new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute(Usage.Generic, 1, "s")); setMesh(); }
Example #8
Source File: DirectionalLight.java From uracer-kotd with Apache License 2.0 | 5 votes |
/** * Directional lights simulate light source that locations is at infinite * distance. Direction and intensity is same everywhere. -90 direction is * straight from up. * * @param rayHandler * @param rays * @param color * @param directionDegree */ public DirectionalLight( RayHandler rayHandler, int rays, Color color, float directionDegree ) { super( rayHandler, rays, color, directionDegree, Float.POSITIVE_INFINITY ); vertexNum = (vertexNum - 1) * 2; start = new Vector2[ rayNum ]; end = new Vector2[ rayNum ]; for( int i = 0; i < rayNum; i++ ) { start[i] = new Vector2(); end[i] = new Vector2(); } setDirection( direction ); // lightMesh = new Mesh(staticLight, vertexNum, 0, new VertexAttribute( // Usage.Position, 2, "vertex_positions"), new VertexAttribute( // Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute( // Usage.Generic, 1, "s")); // // softShadowMesh = new Mesh(staticLight, vertexNum, 0, // new VertexAttribute(Usage.Position, 2, "vertex_positions"), // new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), // new VertexAttribute(Usage.Generic, 1, "s")); lightMesh = new Mesh( VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute( Usage.Position, 2, "vertex_positions" ), new VertexAttribute( Usage.ColorPacked, 4, "quad_colors" ), new VertexAttribute( Usage.Generic, 1, "s" ) ); softShadowMesh = new Mesh( VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute( Usage.Position, 2, "vertex_positions" ), new VertexAttribute( Usage.ColorPacked, 4, "quad_colors" ), new VertexAttribute( Usage.Generic, 1, "s" ) ); update(); }
Example #9
Source File: LightMap.java From uracer-kotd with Apache License 2.0 | 5 votes |
private Mesh createLightMapMesh() { // vertex coord verts[X1] = -1; verts[Y1] = -1; verts[X2] = 1; verts[Y2] = -1; verts[X3] = 1; verts[Y3] = 1; verts[X4] = -1; verts[Y4] = 1; // tex coords verts[U1] = 0f; verts[V1] = 0f; verts[U2] = 1f; verts[V2] = 0f; verts[U3] = 1f; verts[V3] = 1f; verts[U4] = 0f; verts[V4] = 1f; Mesh tmpMesh = new Mesh( true, 4, 0, new VertexAttribute( Usage.Position, 2, "a_position" ), new VertexAttribute( Usage.TextureCoordinates, 2, "a_texCoord" ) ); tmpMesh.setVertices( verts ); return tmpMesh; }
Example #10
Source File: GreedyMesher.java From Radix with MIT License | 5 votes |
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 #11
Source File: NavMeshGraph.java From GdxDemo3D with Apache License 2.0 | 5 votes |
/** * 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 #12
Source File: FullscreenQuad.java From RuinsOfRevenge with MIT License | 5 votes |
private Mesh createFullscreenQuad() { // vertex coord verts[X1] = -1; verts[Y1] = -1; verts[X2] = 1; verts[Y2] = -1; verts[X3] = 1; verts[Y3] = 1; verts[X4] = -1; verts[Y4] = 1; // tex coords verts[U1] = 0f; verts[V1] = 0f; verts[U2] = 1f; verts[V2] = 0f; verts[U3] = 1f; verts[V3] = 1f; verts[U4] = 0f; verts[V4] = 1f; Mesh tmpMesh = new Mesh( VertexDataType.VertexArray, true, 4, 0, new VertexAttribute( Usage.Position, 2, "a_position" ), new VertexAttribute( Usage.TextureCoordinates, 2, "a_texCoord0" ) ); tmpMesh.setVertices( verts ); return tmpMesh; }
Example #13
Source File: DirectionalLight.java From box2dlights with Apache License 2.0 | 5 votes |
/** * Creates directional light which source is at infinite distance, * direction and intensity is same everywhere * * <p>-90 direction is straight from up * * @param rayHandler * not {@code null} instance of RayHandler * @param rays * number of rays - more rays make light to look more realistic * but will decrease performance, can't be less than MIN_RAYS * @param color * color, set to {@code null} to use the default color * @param directionDegree * direction in degrees */ public DirectionalLight(RayHandler rayHandler, int rays, Color color, float directionDegree) { super(rayHandler, rays, color, Float.POSITIVE_INFINITY, directionDegree); vertexNum = (vertexNum - 1) * 2; start = new Vector2[rayNum]; end = new Vector2[rayNum]; for (int i = 0; i < rayNum; i++) { start[i] = new Vector2(); end[i] = new Vector2(); } lightMesh = new Mesh( VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute(Usage.Generic, 1, "s")); softShadowMesh = new Mesh( VertexDataType.VertexArray, staticLight, vertexNum, 0, new VertexAttribute(Usage.Position, 2, "vertex_positions"), new VertexAttribute(Usage.ColorPacked, 4, "quad_colors"), new VertexAttribute(Usage.Generic, 1, "s")); update(); }
Example #14
Source File: LightMap.java From box2dlights with Apache License 2.0 | 5 votes |
private Mesh createLightMapMesh() { float[] verts = new float[VERT_SIZE]; // vertex coord verts[X1] = -1; verts[Y1] = -1; verts[X2] = 1; verts[Y2] = -1; verts[X3] = 1; verts[Y3] = 1; verts[X4] = -1; verts[Y4] = 1; // tex coords verts[U1] = 0f; verts[V1] = 0f; verts[U2] = 1f; verts[V2] = 0f; verts[U3] = 1f; verts[V3] = 1f; verts[U4] = 0f; verts[V4] = 1f; Mesh tmpMesh = new Mesh(true, 4, 0, new VertexAttribute( Usage.Position, 2, "a_position"), new VertexAttribute( Usage.TextureCoordinates, 2, "a_texCoord")); tmpMesh.setVertices(verts); return tmpMesh; }
Example #15
Source File: RainRenderer.java From Cubes with MIT License | 5 votes |
private RainMesh() { mesh = new Mesh(true, MAX_VERTICES, MAX_INDICES, VERTEX_ATTRIBUTES); meshPart = new MeshPart(); meshPart.mesh = mesh; meshPart.primitiveType = GL20.GL_TRIANGLES; meshPart.offset = 0; mesh.setIndices(indices); }
Example #16
Source File: SunRenderer.java From Cubes with MIT License | 5 votes |
private SunRenderer(boolean moon) { this.moon = moon; String texturePath = moon ? moonTexturePath : sunTexturePath; material = Assets.getMaterial(texturePath); textureRegion = Assets.getTextureRegion(texturePath); indices = new short[6]; short j = 0; for (int i = 0; i < indices.length; i += 6, j += 4) { indices[i + 0] = (short) (j + 0); indices[i + 1] = (short) (j + 1); indices[i + 2] = (short) (j + 2); indices[i + 3] = (short) (j + 2); indices[i + 4] = (short) (j + 3); indices[i + 5] = (short) (j + 0); } vertices = new float[CubesVertexAttributes.COMPONENTS * 4]; mesh = new Mesh(false, 4, 6, CubesVertexAttributes.VERTEX_ATTRIBUTES); mesh.setIndices(indices); FaceVertices.createMinY(new Vector3(-0.5f, 0f, -0.5f), textureRegion, null, 0, 0, 0, FULL_LIGHT, vertices, 0); mesh.setVertices(vertices); renderable = new CubesRenderable(); renderable.meshPart.primitiveType = GL20.GL_TRIANGLES; renderable.meshPart.offset = 0; renderable.meshPart.size = 6; renderable.meshPart.mesh = mesh; renderable.material = material; renderable.setFogEnabled(false); }
Example #17
Source File: AreaMesh.java From Cubes with MIT License | 5 votes |
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 #18
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 5 votes |
private Mesh getMeshFromJob() { Mesh mesh; if (job.imageJob.isSetPoints()) { if (job.imageJob.isSetTexturePoints()) { mesh = buildMeshFromVerticesAndTexCoords(job.imageJob.points, job.imageJob.texturePoints); } else { mesh = buildMeshFromVertices(job.imageJob.points); } } else { mesh = standardMesh; } return mesh; }
Example #19
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 5 votes |
private Mesh buildFullScreenQuadMesh() { List<Double> vertices = new ArrayList<Double>(); vertices.add( -1.0); // x1 vertices.add( -1.0); // y1 vertices.add( 0.0); vertices.add( 1.0); // x2 vertices.add( -1.0); // y2 vertices.add( 0.0); vertices.add( 1.0); // x3 vertices.add( 1.0); // y2 vertices.add( 0.0); vertices.add( -1.0); // x1 vertices.add( -1.0); // y1 vertices.add( 0.0); vertices.add( -1.0); // x4 vertices.add( 1.0); // y4 vertices.add( 0.0); vertices.add( 1.0); // x3 vertices.add( 1.0); // y2 vertices.add( 0.0); return buildMeshFromVertices(vertices); }
Example #20
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 5 votes |
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 #21
Source File: Main.java From graphicsfuzz with Apache License 2.0 | 5 votes |
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 #22
Source File: GameWorldRenderer.java From uracer-kotd with Apache License 2.0 | 5 votes |
private void createBackPlane () { plane = new Mesh(true, 4, 4, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)); // @formatter:off float size = 10f; float verts[] = {-size / 2, 0, size / 2, size / 2, 0, size / 2, size / 2, 0, -size / 2, -size / 2, 0, -size / 2}; // float verts[] = {size, 0, size, size, 0, 0, 0, 0, 0, 0, 0, size}; float normals[] = {0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0}; // @formatter:on int vidx = 0, nidx = 0; int length = 6 * 4; float[] vertices = new float[length]; for (int i = 0; i < length;) { vertices[i++] = verts[vidx++]; vertices[i++] = verts[vidx++]; vertices[i++] = verts[vidx++]; vertices[i++] = normals[nidx++]; vertices[i++] = normals[nidx++]; vertices[i++] = normals[nidx++]; } plane.setVertices(vertices); plane.setIndices(new short[] {0, 1, 2, 3}); }
Example #23
Source File: GLTFMeshExporter.java From gdx-gltf with Apache License 2.0 | 5 votes |
GLTFPrimitive exportMeshPart(MeshPart meshPart) { Mesh mesh = meshPart.mesh; GLTFPrimitive primitive = new GLTFPrimitive(); primitive.attributes = new ObjectMap<String, Integer>(); primitive.mode = mapPrimitiveMode(meshPart.primitiveType); GLTFPrimitive layout = layouts.get(mesh); if(layout != null){ copyLayout(primitive, layout); }else{ layouts.put(mesh, primitive); exportMesh(primitive, mesh); } // mesh may not have indices if(mesh.getNumIndices() > 0) { ShortBuffer outBuffer = base.binManager.beginShorts(meshPart.size); ShortBuffer inBuffer = mesh.getIndicesBuffer(); if(meshPart.offset == 0 && meshPart.size == mesh.getNumIndices()){ outBuffer.put(mesh.getIndicesBuffer()); }else{ short[] localIndices = new short[meshPart.size]; inBuffer.position(meshPart.offset); inBuffer.get(localIndices); outBuffer.put(localIndices); } inBuffer.rewind(); GLTFAccessor accessor = base.obtainAccessor(); accessor.type = GLTFTypes.TYPE_SCALAR; accessor.componentType = GLTFTypes.C_SHORT; accessor.count = meshPart.size; accessor.bufferView = base.binManager.end(); primitive.indices = base.root.accessors.size-1; } return primitive; }
Example #24
Source File: FullscreenQuad.java From uracer-kotd with Apache License 2.0 | 5 votes |
private Mesh createFullscreenQuad () { // vertex coord verts[X1] = -1; verts[Y1] = -1; verts[X2] = 1; verts[Y2] = -1; verts[X3] = 1; verts[Y3] = 1; verts[X4] = -1; verts[Y4] = 1; // tex coords verts[U1] = 0f; verts[V1] = 0f; verts[U2] = 1f; verts[V2] = 0f; verts[U3] = 1f; verts[V3] = 1f; verts[U4] = 0f; verts[V4] = 1f; Mesh tmpMesh = new Mesh(VertexDataType.VertexArray, true, 4, 0, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoord0")); tmpMesh.setVertices(verts); return tmpMesh; }
Example #25
Source File: ViewportQuadMesh.java From gdx-vfx with Apache License 2.0 | 4 votes |
public ViewportQuadMesh(VertexAttribute... vertexAttributes) { mesh = new Mesh(true, 4, 0, vertexAttributes); mesh.setVertices(verts); }
Example #26
Source File: SubMesh.java From uracer-kotd with Apache License 2.0 | 4 votes |
public SubMesh (String name, Mesh mesh, int primitiveType) { this(name, mesh, primitiveType, null); }
Example #27
Source File: ViewportQuadMesh.java From gdx-vfx with Apache License 2.0 | 4 votes |
public Mesh getMesh() { return mesh; }
Example #28
Source File: GLTFInspector.java From gdx-gltf with Apache License 2.0 | 4 votes |
private void logScenes(SceneAsset asset) { int nBones = 0; int nNodes = 0; int meshNodes = 0; int nMeshParts = 0; int nMesh = 0; int nVert = 0; int nTri = 0; int nRealTri = 0; ObjectSet<Material> mapSet = new ObjectSet<Material>(); for(SceneModel scene : asset.scenes){ nMesh += scene.model.meshes.size; allCameras.addAll(scene.cameras.values().toArray()); allLights.addAll(scene.lights.values().toArray()); for(Mesh mesh : scene.model.meshes ){ nVert += mesh.getNumVertices(); nTri += mesh.getNumIndices() / 3; } Array<Node> nodes = NodeUtil.getAllNodes(new Array<Node>(), scene.model); nNodes += nodes.size; for(Node node : nodes){ if(node.parts.size > 0){ nMeshParts += node.parts.size; for(NodePart np : node.parts){ nRealTri += np.meshPart.size / 3; mapSet.add(np.material); nBones += np.bones != null ? np.bones.length : 0; } meshNodes++; } } } int nMaterials = mapSet.size; log("Scene Graph", "scenes", asset.scenes.size, "nodes", nNodes, "empty", nNodes - meshNodes); if(nMesh > 0) log("Mesh", "count", nMesh, "parts", nMeshParts, "Vertices", nVert, "Tris", nTri, "Rendered", nRealTri); if(nMaterials > 0) log("Materials", "count", nMaterials); if(asset.maxBones > 0) log("Bones", "max", asset.maxBones, "count", nBones); }
Example #29
Source File: MeshLoader.java From gdx-gltf with Apache License 2.0 | 4 votes |
public Array<? extends Mesh> getMeshes() { return meshes; }
Example #30
Source File: CardboardDistortion.java From gdx-vr with Apache License 2.0 | 4 votes |
@Override public Mesh getAntiDistortionMesh() { // TODO Auto-generated method stub return null; }