本文整理汇总了Java中com.badlogic.gdx.utils.FloatArray类的典型用法代码示例。如果您正苦于以下问题:Java FloatArray类的具体用法?Java FloatArray怎么用?Java FloatArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FloatArray类属于com.badlogic.gdx.utils包,在下文中一共展示了FloatArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aabbCompute
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
private void aabbCompute () {
float minX = Integer.MAX_VALUE, minY = Integer.MAX_VALUE, maxX = Integer.MIN_VALUE, maxY = Integer.MIN_VALUE;
Array<FloatArray> polygons = this.polygons;
for (int i = 0, n = polygons.size; i < n; i++) {
FloatArray polygon = polygons.get(i);
float[] vertices = polygon.items;
for (int ii = 0, nn = polygon.size; ii < nn; ii += 2) {
float x = vertices[ii];
float y = vertices[ii + 1];
minX = Math.min(minX, x);
minY = Math.min(minY, y);
maxX = Math.max(maxX, x);
maxY = Math.max(maxY, y);
}
}
this.minX = minX;
this.minY = minY;
this.maxX = maxX;
this.maxY = maxY;
}
示例2: containsPoint
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/** Returns true if the polygon contains the point. */
public boolean containsPoint (FloatArray polygon, float x, float y) {
float[] vertices = polygon.items;
int nn = polygon.size;
int prevIndex = nn - 2;
boolean inside = false;
for (int ii = 0; ii < nn; ii += 2) {
float vertexY = vertices[ii + 1];
float prevY = vertices[prevIndex + 1];
if ((vertexY < y && prevY >= y) || (prevY < y && vertexY >= y)) {
float vertexX = vertices[ii];
if (vertexX + (y - vertexY) / (prevY - vertexY) * (vertices[prevIndex] - vertexX) < x) inside = !inside;
}
prevIndex = ii;
}
return inside;
}
示例3: intersectsSegment
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/** Returns true if the polygon contains any part of the line segment. */
public boolean intersectsSegment (FloatArray polygon, float x1, float y1, float x2, float y2) {
float[] vertices = polygon.items;
int nn = polygon.size;
float width12 = x1 - x2, height12 = y1 - y2;
float det1 = x1 * y2 - y1 * x2;
float x3 = vertices[nn - 2], y3 = vertices[nn - 1];
for (int ii = 0; ii < nn; ii += 2) {
float x4 = vertices[ii], y4 = vertices[ii + 1];
float det2 = x3 * y4 - y3 * x4;
float width34 = x3 - x4, height34 = y3 - y4;
float det3 = width12 * height34 - height12 * width34;
float x = (det1 * width34 - width12 * det2) / det3;
if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
float y = (det1 * height34 - height12 * det2) / det3;
if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true;
}
x3 = x4;
y3 = y4;
}
return false;
}
示例4: readVertices
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
private Vertices readVertices (DataInput input, int vertexCount) throws IOException {
int verticesLength = vertexCount << 1;
Vertices vertices = new Vertices();
if (!input.readBoolean()) {
vertices.vertices = readFloatArray(input, verticesLength, scale);
return vertices;
}
FloatArray weights = new FloatArray(verticesLength * 3 * 3);
IntArray bonesArray = new IntArray(verticesLength * 3);
for (int i = 0; i < vertexCount; i++) {
int boneCount = input.readInt(true);
bonesArray.add(boneCount);
for (int ii = 0; ii < boneCount; ii++) {
bonesArray.add(input.readInt(true));
weights.add(input.readFloat() * scale);
weights.add(input.readFloat() * scale);
weights.add(input.readFloat());
}
}
vertices.vertices = weights.toArray();
vertices.bones = bonesArray.toArray();
return vertices;
}
示例5: readVertices
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
private void readVertices (JsonValue map, VertexAttachment attachment, int verticesLength) {
attachment.setWorldVerticesLength(verticesLength);
float[] vertices = map.require("vertices").asFloatArray();
if (verticesLength == vertices.length) {
if (scale != 1) {
for (int i = 0, n = vertices.length; i < n; i++)
vertices[i] *= scale;
}
attachment.setVertices(vertices);
return;
}
FloatArray weights = new FloatArray(verticesLength * 3 * 3);
IntArray bones = new IntArray(verticesLength * 3);
for (int i = 0, n = vertices.length; i < n;) {
int boneCount = (int)vertices[i++];
bones.add(boneCount);
for (int nn = i + boneCount * 4; i < nn; i += 4) {
bones.add((int)vertices[i]);
weights.add(vertices[i + 1] * scale);
weights.add(vertices[i + 2] * scale);
weights.add(vertices[i + 3]);
}
}
attachment.setBones(bones.toArray());
attachment.setVertices(weights.toArray());
}
示例6: getFlatPixelArray
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
public float[] getFlatPixelArray() {
FloatArray floats = new FloatArray();
flatPixelArray = new float[width * height * 3];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
float r = pixels[y][x][0];
float g = pixels[y][x][1];
float b = pixels[y][x][2];
floats.addAll(r, g, b);
}
}
for (int i = 0; i < floats.size; i++) {
flatPixelArray[i] = floats.get(i);
}
floats.clear();
return flatPixelArray;
}
示例7: RavChainLight
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/** 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 RavChainLight (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();
}
示例8: debugRender
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/** Draws a polygon, using ray start and end points as vertices */
public void debugRender (PolygonShapeRenderer shapeRenderer) {
shapeRenderer.setColor(Color.BLUE);
FloatArray vertices = Pools.obtain(FloatArray.class);
vertices.clear();
for (int i = 0; i < rayNum; i++) {
vertices.addAll(mx[i], my[i]);
}
for (int i = rayNum - 1; i > -1; i--) {
vertices.addAll(startX[i], startY[i]);
}
vertices.add(vertices.get(0));
vertices.add(vertices.get(1));
shapeRenderer.polyline(vertices.shrink());
Pools.free(vertices);
}
示例9: intersectsSegment
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/** Returns true if the polygon contains the line segment. */
public boolean intersectsSegment (FloatArray polygon, float x1, float y1, float x2, float y2) {
float[] vertices = polygon.items;
int nn = polygon.size;
float width12 = x1 - x2, height12 = y1 - y2;
float det1 = x1 * y2 - y1 * x2;
float x3 = vertices[nn - 2], y3 = vertices[nn - 1];
for (int ii = 0; ii < nn; ii += 2) {
float x4 = vertices[ii], y4 = vertices[ii + 1];
float det2 = x3 * y4 - y3 * x4;
float width34 = x3 - x4, height34 = y3 - y4;
float det3 = width12 * height34 - height12 * width34;
float x = (det1 * width34 - width12 * det2) / det3;
if (((x >= x3 && x <= x4) || (x >= x4 && x <= x3)) && ((x >= x1 && x <= x2) || (x >= x2 && x <= x1))) {
float y = (det1 * height34 - height12 * det2) / det3;
if (((y >= y3 && y <= y4) || (y >= y4 && y <= y3)) && ((y >= y1 && y <= y2) || (y >= y2 && y <= y1))) return true;
}
x3 = x4;
y3 = y4;
}
return false;
}
示例10: intersectSegments
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/** @see #intersectSegments(float, float, float, float, float[], boolean, com.badlogic.gdx.utils.FloatArray) */
public static void intersectSegments(Vector2 a, Vector2 b, float[] segments, boolean polygon, Array<Vector2> intersections) {
FloatArray fa = Pools.obtain(FloatArray.class);
intersectSegments(a.x, a.y, b.x, b.y, segments, polygon, fa);
if(fa.size < 1) {
intersections.clear();
Pools.free(fa);
return;
}
intersections.ensureCapacity(fa.size / 2 - intersections.size);
for(int i = 1; i < fa.size; i += 2)
if(intersections.size > i / 2)
intersections.get(i / 2).set(fa.get(i - 1), fa.get(i));
else
intersections.add(new Vector2(fa.get(i - 1), fa.get(i)));
Pools.free(fa);
}
示例11: mesh
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
@Override
public void mesh() {
if (meshRequest && !meshing) {
if (!loaded) return;
meshing = true;
opaqueMeshData = new FloatArray();
transpMeshData = new FloatArray();
try {
getVertices();
int opaqueNumVerts = opaqueMeshData.size / VERTEX_SIZE;
int transpNumVerts = transpMeshData.size / VERTEX_SIZE;
opaqueVerts = opaqueNumVerts / 4 * 6;
transpVerts = transpNumVerts / 4 * 6;
meshRequest = false;
doneMeshing = true;
meshing = false;
} catch (Exception e) {
meshing = true;
}
}
}
示例12: buildMeshes
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
public static void buildMeshes() {
if (indices == null) {
int len = 3 * 6 * 6 / 3;
indices = new short[len];
short j = 0;
for (int i = 0; i < len; 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);
}
}
for (Voxel v : voxels.values()) {
v.mesh = new Mesh(true, 24, indices.length, VertexAttribute.Position(), VertexAttribute.Normal(), VertexAttribute.ColorPacked(), VertexAttribute.TexCoords(0), VertexAttribute.TexCoords(1));
v.mesh.setIndices(indices);
verts = new FloatArray();
for (Direction d : Direction.values())
new TextureFace(d, new Vector3(), v.getTextureUV(0, 0, 0, d)).getVertexData(verts);
v.mesh.setVertices(verts.items, 0, verts.size);
}
}
示例13: update
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
public void update (Skeleton skeleton, boolean updateAabb) {
if (skeleton == null) throw new IllegalArgumentException("skeleton cannot be null.");
Array<BoundingBoxAttachment> boundingBoxes = this.boundingBoxes;
Array<FloatArray> polygons = this.polygons;
Array<Slot> slots = skeleton.slots;
int slotCount = slots.size;
boundingBoxes.clear();
polygonPool.freeAll(polygons);
polygons.clear();
for (int i = 0; i < slotCount; i++) {
Slot slot = slots.get(i);
Attachment attachment = slot.attachment;
if (attachment instanceof BoundingBoxAttachment) {
BoundingBoxAttachment boundingBox = (BoundingBoxAttachment)attachment;
boundingBoxes.add(boundingBox);
FloatArray polygon = polygonPool.obtain();
polygons.add(polygon);
boundingBox.computeWorldVertices(slot, polygon.setSize(boundingBox.getWorldVerticesLength()));
}
}
if (updateAabb) aabbCompute();
}
示例14: calculateTimes
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
/**
* Calculates the travel time of each segment to allow for
* smooth lerping along the path between 0 and 1
*/
private void calculateTimes()
{
//find total length of the path
float length = 0, dst = 0;
for (int i = 1; i < points.size; i++)
{
dst = points.get(i).dst(points.get(i-1));
length += dst;
}
//calculate percentage that each segment takes of the path's total length
times = new FloatArray();
times.add(0);
float l = 0;
for (int i = 1; i < points.size; i++)
{
dst = points.get(i).dst(points.get(i-1));
l += dst;
times.add(l/length);
}
}
示例15: a
import com.badlogic.gdx.utils.FloatArray; //导入依赖的package包/类
private float a(FloatArray paramFloatArray, float paramFloat1, float paramFloat2, float paramFloat3)
{
int i1 = 0;
if (i1 < paramFloatArray.size)
{
float f = paramFloatArray.items[i1];
if (Math.abs(f - paramFloat1) < this.e.getHeight())
if (f >= (paramFloat2 + paramFloat3) / 2.0F)
break label67;
label67: for (paramFloat1 += this.e.getHeight(); ; paramFloat1 -= this.e.getHeight())
{
i1++;
break;
}
}
return paramFloat1;
}