当前位置: 首页>>代码示例>>Java>>正文


Java Vector2i类代码示例

本文整理汇总了Java中org.joml.Vector2i的典型用法代码示例。如果您正苦于以下问题:Java Vector2i类的具体用法?Java Vector2i怎么用?Java Vector2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Vector2i类属于org.joml包,在下文中一共展示了Vector2i类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: contains

import org.joml.Vector2i; //导入依赖的package包/类
public static boolean contains(GridMap map, int x, int y, int w, int h, Object value)
{
	Poma.ASSERT(w >= 0);
	Poma.ASSERT(h >= 0);
	Poma.ASSERT(x >= 0 && x < map.width() && y >= 0 && y < map.height());
	Poma.ASSERT(map.width() - x >= w && map.height() - y >= h);

	for (int i = 0; i < w; ++i)
	{
		for (int j = 0; j < h; ++j)
		{
			if (value.equals(map.get(new Vector2i(x + i, y + j))))
			{
				return true;
			}
		}
	}

	return false;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:21,代码来源:MapUtil.java

示例2: overlay

import org.joml.Vector2i; //导入依赖的package包/类
public static <T> void overlay(GridMap<T> map, int x, int y, GridMap<T> values)
{
	Poma.ASSERT(x >= 0 && x < map.width() && y >= 0 && y < map.height());

	for (int i = 0; i < values.width(); ++i)
	{
		for (int j = 0; j < values.height(); ++j)
		{
			T v = values.get(new Vector2i(i, j));
			if (!v.equals(0))
			{
				map.set(new Vector2i(x + i, y + j), v);
			}
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:17,代码来源:MapUtil.java

示例3: replace

import org.joml.Vector2i; //导入依赖的package包/类
public static <T> void replace(GridMap<T> map, int x, int y, int w, int h, T value, Predicate<T> canReplace)
{
	Poma.ASSERT(w >= 0);
	Poma.ASSERT(h >= 0);
	Poma.ASSERT(x >= 0 && x < map.width() && y >= 0 && y < map.height());
	Poma.ASSERT(map.width() - x >= w && map.height() - y >= h);

	for (int i = 0; i < w; ++i)
	{
		for (int j = 0; j < h; ++j)
		{
			T v = map.get(new Vector2i(x + i, y + j));
			if (canReplace.test(v))
			{
				map.set(new Vector2i(x + i, y + j), value);
			}
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:20,代码来源:MapUtil.java

示例4: copy

import org.joml.Vector2i; //导入依赖的package包/类
public static <T> GridMap<T> copy(GridMap<T> map, int x, int y, int w, int h, GridMap<T> dst)
{
	Poma.ASSERT(w >= 0);
	Poma.ASSERT(h >= 0);
	Poma.ASSERT(x >= 0 && x < map.width() && y >= 0 && y < map.height());
	Poma.ASSERT(map.width() - x >= w && map.height() - y >= h);

	for (int i = 0; i < dst.width(); ++i)
	{
		for (int j = 0; j < dst.height(); ++j)
		{
			dst.set(new Vector2i(i, j), map.get(new Vector2i(x + i, y + j)));
		}
	}
	return dst;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:17,代码来源:MapUtil.java

示例5: polari

import org.joml.Vector2i; //导入依赖的package包/类
/**Gets the polar {@link Vector2i} representation of direction in only integers*/
public Vector2i polari(Vector2i dst)
{
	switch(this)
	{
		case EAST: return dst.set(1, 0);
		case NORTHEAST: return dst.set(1, 1);
		case NORTH: return dst.set(0, 1);
		case NORTHWEST: return dst.set(-1, 1);
		case WEST: return dst.set(-1, 0);
		case SOUTHWEST: return dst.set(-1, -1);
		case SOUTH: return dst.set(0, -1);
		case SOUTHEAST: return dst.set(1, -1);
		default: return dst.set(0, 0);
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:17,代码来源:Direction.java

示例6: find

import org.joml.Vector2i; //导入依赖的package包/类
public Vector2ic find(int x, int y, int w, int h, BiFunction<Vector2ic, T, Boolean> test)
{
	Vector2i key = new Vector2i();
	for(int i = 0; i < w; ++i)
	{
		for(int j = 0; j < h; ++j)
		{
			key.set(x + i, y + j);
			Boolean flag = test.apply(key, this.get(key));
			if (flag != null && flag)
			{
				return key;
			}
		}
	}
	return null;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:18,代码来源:GridMap.java

示例7: generateChunk

import org.joml.Vector2i; //导入依赖的package包/类
public static Chunk generateChunk(Vector2i position, World world) {
    Block[][][] blocks = new Block[Chunk.SIZE_X][Chunk.SIZE_Y][Chunk.SIZE_Z];
    for(int x = 0; x < Chunk.SIZE_X; x++) {
        for(int z = 0; z < Chunk.SIZE_Z; z++) {
            for(int y = Chunk.SIZE_Y - 1; y >= 0; y--) {
                Vector3i pos = new Vector3i(x, y, z).add(new Vector3i(position.x * Chunk.SIZE_X, 0, position.y * Chunk.SIZE_Z));
                //Heightmap
                double v1 = perturb.get(pos.x, pos.z);
                int height = (int) (mainOctave.get(pos.x + v1, pos.z + v1) + WATER_LEVEL);
                //Caves
                double c1 = perturb.get(pos.x, pos.y, pos.z) * 5;
                double density = caves.get(pos.x + c1, pos.y + c1, pos.z + c1) + CAVE_VALUE + (pos.y / 20);
                if(density > 0 && pos.y <= height)
                    blocks[x][y][z] = pos.y == height ? Blocks.GRASS : Blocks.STONE;
                else
                    blocks[x][y][z] = Blocks.AIR;
            }
        }
    }
    return new Chunk(blocks, position, world);
}
 
开发者ID:mcmacker4,项目名称:OpenVoxel,代码行数:22,代码来源:ChunkGenerator.java

示例8: fill

import org.joml.Vector2i; //导入依赖的package包/类
public static <T> void fill(GridMap<T> map, int x, int y, int w, int h, T value)
{
	Poma.ASSERT(w >= 0);
	Poma.ASSERT(h >= 0);
	Poma.ASSERT(x >= 0 && x < map.width() && y >= 0 && y < map.height());
	Poma.ASSERT(map.width() - x >= w && map.height() - y >= h);

	for (int i = 0; i < w; ++i)
	{
		for (int j = 0; j < h; ++j)
		{
			map.set(new Vector2i(x + i, y + j), value);
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:16,代码来源:MapUtil.java

示例9: set

import org.joml.Vector2i; //导入依赖的package包/类
public static <T> void set(GridMap<T> map, int x, int y, GridMap<T> values)
{
	Poma.ASSERT(x >= 0 && x < map.width() && y >= 0 && y < map.height());

	for (int i = 0; i < values.width(); ++i)
	{
		for (int j = 0; j < values.height(); ++j)
		{
			map.set(new Vector2i(x + i, y + j), values.get(new Vector2i(i, j)));
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:13,代码来源:MapUtil.java

示例10: bake

import org.joml.Vector2i; //导入依赖的package包/类
@Override
public void bake(DungeonData data)
{
	boolean running = true;

	while (running)
	{
		running = false;

		for (int x = 1; x < data.width - 1; ++x)
		{
			for (int y = 1; y < data.height - 1; ++y)
			{
				if (this.isCarveableTile.test(data.getTiles().get(x, y))) continue;

				int exits = 0;
				for (Direction dir : Direction.Cardinals.values())
				{
					Vector2i dv = dir.polari(new Vector2i());
					if (!this.isCarveableTile.test(data.getTiles().get(x + dv.x(), y + dv.y())))
						exits++;
				}

				if (exits != 1) continue;

				data.getTiles().set(x, y, 0);
				running = true;
			}
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:32,代码来源:MazeGenSparseMaze.java

示例11: forEach

import org.joml.Vector2i; //导入依赖的package包/类
public void forEach(int x, int y, int w, int h, BiConsumer<Vector2ic, T> action)
{
	Vector2i key = new Vector2i();
	for(int i = 0; i < w; ++i)
	{
		for(int j = 0; j < h; ++j)
		{
			key.set(x + i, y + j);
			action.accept(key, this.get(key));
		}
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:13,代码来源:GridMap.java

示例12: toString

import org.joml.Vector2i; //导入依赖的package包/类
@Override
public String toString()
{
	final StringBuilder sb = new StringBuilder();
	sb.append('[');

	final Vector2i key = new Vector2i();
	for(int y = 0; y < this.height; ++y)
	{
		if (y > 0) sb.append('\n');

		for(int x = 0; x < this.width; ++x)
		{
			key.set(x, y);
			sb.append(this.get(key));

			if (!(x == this.width - 1 && y == this.height - 1))
			{
				sb.append(',');
				sb.append(' ');
			}
		}
	}

	sb.append(']');
	return sb.toString();
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:28,代码来源:GridMap.java

示例13: getAvailableNodes

import org.joml.Vector2i; //导入依赖的package包/类
@Override
protected Iterable<Integer> getAvailableNodes(Integer node)
{
	List<Integer> neighbors = new ArrayList<>(4);
	int w = map.width();
	int x = node % w;
	int y = node / w;
	Vector2i key = new Vector2i(x, y);
	if (x < w - 1 && solid.test(map.get(key.set(x + 1, y)))) neighbors.add(node + 1);
	if (x > 0 && solid.test(map.get(key.set(x - 1, y)))) neighbors.add(node - 1);
	if (y < w - 1 && solid.test(map.get(key.set(x, y + 1)))) neighbors.add(node + w);
	if (y > 0 && solid.test(map.get(key.set(x, y - 1)))) neighbors.add(node - w);
	return neighbors;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:15,代码来源:AStarGridCardinal.java

示例14: getTileCoord

import org.joml.Vector2i; //导入依赖的package包/类
public static Vector2i getTileCoord(float posX, float posY, Vector2i dst)
{
	float x = posX % DungeonChunk.CHUNK_SIZE;
	float y = posY % DungeonChunk.CHUNK_SIZE;

	if (x < 0) x += DungeonChunk.CHUNK_SIZE;
	if (y < 0) y += DungeonChunk.CHUNK_SIZE;

	return dst.set((int) Math.floor(x), (int) Math.floor(y));
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:11,代码来源:Chunk.java

示例15: loadChunk

import org.joml.Vector2i; //导入依赖的package包/类
public T loadChunk(Vector2ic chunkCoord)
{
	T chunk = this.chunks.get(chunkCoord);
	if (chunk == null)
	{
		Vector2i key = new Vector2i(chunkCoord);
		chunk = this.loader.onChunkLoad(this, key, this.chunkSize);
		this.chunks.put(key, chunk);
	}
	else
	{
		this.markChunkForUpdate(chunk);
	}
	return chunk;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:16,代码来源:ChunkMap.java


注:本文中的org.joml.Vector2i类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。