List of usage examples for com.badlogic.gdx.graphics Color toFloatBits
public float toFloatBits()
From source file:com.andgate.ikou.render.TileMesh.java
License:Open Source License
public void addFace(Color color, Vector3 point0, Vector3 point1, Vector3 point2, Vector3 point3, Vector3 normal) {// w ww . ja va 2 s. c om int vertexOffset = vertices.size / NUM_COMPONENTS; float colorBits = color.toFloatBits(); vertices.addAll(point0.x, point0.y, point0.z, colorBits, normal.x, normal.y, normal.z, point1.x, point1.y, point1.z, colorBits, normal.x, normal.y, normal.z, point2.x, point2.y, point2.z, colorBits, normal.x, normal.y, normal.z, point3.x, point3.y, point3.z, colorBits, normal.x, normal.y, normal.z); indicies.addAll((short) (vertexOffset), (short) (1 + vertexOffset), (short) (2 + vertexOffset), (short) (2 + vertexOffset), (short) (3 + vertexOffset), (short) (vertexOffset)); }
From source file:com.anythingmachine.gdxwrapper.SpriteCache.java
License:Apache License
/** * Sets the color used to tint images when they are added to the * SpriteCache. Default is {@link Color#WHITE}. *//*w ww.j ava 2 s. c o m*/ public void setColor(Color tint) { color = tint.toFloatBits(); int size = mesh.getNumVertices() * 5; float[] verts = new float[size]; mesh.getVertices(verts); for (int i = 2; i < size; i += 5) { verts[i] = color; } mesh.setVertices(verts); }
From source file:com.balloongame.handlers.CustomSpriteBatch.java
License:Apache License
/** Sets the color used to tint images when they are added to the SpriteBatch. Default is {@link Color#WHITE}. */ public void setColor(Color tint) { color = tint.toFloatBits(); }
From source file:com.cyphercove.doublehelix.points.BillboardDecal.java
License:Apache License
/** Sets the color used to tint this decal. Default is {@link Color#WHITE}. */ public void setColor(Color tint) { color.set(tint);//from w w w .j a va 2 s . c o m float color = tint.toFloatBits(); vertices[C] = color; }
From source file:com.dongbat.game.stage.RadialSprite.java
public void setColor(final Color color) { setColor(color.toFloatBits()); }
From source file:com.doom.render.QuadBatch.java
License:Apache License
@Override public void setColor(Color tint) { color = tint.toFloatBits(); }
From source file:com.esotericsoftware.spine.utils.TwoColorPolygonBatch.java
License:Open Source License
@Override public void setColor(Color tint) { light.set(tint); lightPacked = tint.toFloatBits(); }
From source file:com.esotericsoftware.spine.utils.TwoColorPolygonBatch.java
License:Open Source License
public void setDarkColor(Color tint) { dark.set(tint); darkPacked = tint.toFloatBits(); }
From source file:com.iLoong.launcher.min3d.ObjLoader.java
License:Open Source License
/** * Loads a mesh from the given string in Wavefront OBJ format * /*ww w. j ava 2s. co m*/ * @param obj * The string * @param flipV * whether to flip the v texture coordinate or not * @param useIndices * whether to create an array of indices or not * @return The Mesh */ public static Mesh loadObjFromString(String obj, boolean flipV, boolean useIndices, float offsetX, float offsetY, float offsetZ, float scaleX, float scaleY, float scaleZ) { String[] lines = obj.split("\n"); float[] vertices = new float[lines.length * 3]; float[] normals = new float[lines.length * 3]; float[] uv = new float[lines.length * 3]; int numVertices = 0; int numNormals = 0; int numUV = 0; int numFaces = 0; int[] facesVerts = new int[lines.length * 3]; int[] facesNormals = new int[lines.length * 3]; int[] facesUV = new int[lines.length * 3]; int vertexIndex = 0; int normalIndex = 0; int uvIndex = 0; int faceIndex = 0; Color default_color = new Color(1.0f, 1.0f, 1.0f, 1.0f); for (int i = 0; i < lines.length; i++) { String line = lines[i]; if (line.startsWith("v ")) { String[] tokens = line.split("[ ]+"); float vertex_x = Float.parseFloat(tokens[1]); float vertex_y = Float.parseFloat(tokens[2]); float vertex_z = Float.parseFloat(tokens[3]); if (scaleX != 1f) { vertex_x = vertex_x * scaleX; } if (scaleY != 1f) { vertex_y = vertex_y * scaleY; } if (scaleZ != 1f) { vertex_z = vertex_z * scaleZ; } vertices[vertexIndex] = vertex_x + offsetX; vertices[vertexIndex + 1] = vertex_y + offsetY; vertices[vertexIndex + 2] = vertex_z + offsetZ; vertexIndex += 3; numVertices++; continue; } if (line.startsWith("vn ")) { String[] tokens = line.split("[ ]+"); normals[normalIndex] = Float.parseFloat(tokens[1]); normals[normalIndex + 1] = Float.parseFloat(tokens[2]); normals[normalIndex + 2] = Float.parseFloat(tokens[3]); normalIndex += 3; numNormals++; continue; } if (line.startsWith("vt")) { String[] tokens = line.split("[ ]+"); uv[uvIndex] = Float.parseFloat(tokens[1]); uv[uvIndex + 1] = flipV ? 1 - Float.parseFloat(tokens[2]) : Float.parseFloat(tokens[2]); uvIndex += 2; numUV++; continue; } if (line.startsWith("f ")) { String[] tokens = line.split("[ ]+"); if (tokens.length == 5) { String[] parts = tokens[1].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; parts = tokens[2].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; parts = tokens[4].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; numFaces++; parts = tokens[2].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; parts = tokens[3].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; parts = tokens[4].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; numFaces++; } else { String[] parts = tokens[1].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; parts = tokens[2].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; parts = tokens[3].split("/"); facesVerts[faceIndex] = getIndex(parts[0], numVertices); if (parts.length > 2) facesNormals[faceIndex] = getIndex(parts[2], numNormals); if (parts.length > 1) facesUV[faceIndex] = getIndex(parts[1], numUV); faceIndex++; numFaces++; } continue; } } Mesh mesh = null; ArrayList<VertexAttribute> attributes = new ArrayList<VertexAttribute>(); attributes.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE)); attributes.add(new VertexAttribute(Usage.ColorPacked, 4, ShaderProgram.COLOR_ATTRIBUTE)); if (numNormals > 0) attributes.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE)); if (numUV > 0) attributes .add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0")); if (useIndices) { int attrCount = 4 + (numNormals > 0 ? 3 : 0) + (numUV > 0 ? 2 : 0); int normOffset = 4; int uvOffset = 4 + (numNormals > 0 ? 3 : 0); float verts[] = new float[numVertices * attrCount]; for (int i = 0; i < numVertices; i++) { verts[i * attrCount] = vertices[i * 3]; verts[i * attrCount + 1] = vertices[i * 3 + 1]; verts[i * attrCount + 2] = vertices[i * 3 + 2]; verts[i * attrCount + 3] = default_color.toFloatBits(); } for (int i = 0; i < numFaces * 3; i++) { int vertexIdx = facesVerts[i]; if (numNormals > 0) { int normalIdx = facesNormals[i] * 3; verts[vertexIdx * attrCount + normOffset] = normals[normalIdx]; verts[vertexIdx * attrCount + normOffset + 1] = normals[normalIdx + 1]; verts[vertexIdx * attrCount + normOffset + 2] = normals[normalIdx + 2]; } if (numUV > 0) { int uvIdx = facesUV[i] * 2; verts[vertexIdx * attrCount + uvOffset] = uv[uvIdx]; verts[vertexIdx * attrCount + uvOffset + 1] = uv[uvIdx + 1]; } } short[] indices = new short[numFaces * 3]; for (int i = 0; i < indices.length; i++) indices[i] = (short) facesVerts[i]; mesh = new Mesh(null, true, verts.length, indices.length, attributes.toArray(new VertexAttribute[attributes.size()])); mesh.setVertices(verts); mesh.setIndices(indices); } else { float[] verts = new float[(numFaces * 3) * (4 + (numNormals > 0 ? 3 : 0) + (numUV > 0 ? 2 : 0))]; for (int i = 0, vi = 0; i < numFaces * 3; i++) { int vertexIdx = facesVerts[i] * 3; verts[vi++] = vertices[vertexIdx]; verts[vi++] = vertices[vertexIdx + 1]; verts[vi++] = vertices[vertexIdx + 2]; verts[vi++] = default_color.toFloatBits(); if (numNormals > 0) { int normalIdx = facesNormals[i] * 3; verts[vi++] = normals[normalIdx]; verts[vi++] = normals[normalIdx + 1]; verts[vi++] = normals[normalIdx + 2]; } if (numUV > 0) { int uvIdx = facesUV[i] * 2; verts[vi++] = uv[uvIdx]; verts[vi++] = uv[uvIdx + 1]; } } mesh = new Mesh(null, true, numFaces * 3, 0, attributes.toArray(new VertexAttribute[attributes.size()])); mesh.setVertices(verts); } return mesh; }
From source file:com.jwatson.omnigame.Sprite.java
License:Apache License
public void setColor(Color tint) { float color = tint.toFloatBits(); float[] vertices = this.vertices; vertices[C1] = color;/* w w w . ja va 2 s .com*/ vertices[C2] = color; vertices[C3] = color; vertices[C4] = color; }