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


Java Vector2f类代码示例

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


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

示例1: update

import org.joml.Vector2f; //导入依赖的package包/类
@Override
public void update(float delta, Window window, Camera camera, World world) {
    Vector2f movement = new Vector2f();
    if (window.getInput().isKeyDown(GLFW_KEY_LEFT)) {
        movement.add(-10 * delta, 0);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_RIGHT)) {
        movement.add(10 * delta, 0);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_UP)) {
        movement.add(0, 10 * delta);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_DOWN)) {
        movement.add(0, -10 * delta);
    }
    move(movement);

    if(movement.x != 0|| movement.y != 0) {
        useAnimation(ANIM_WALKING);
    } else {
        useAnimation(ANIM_IDLE);
    }

    camera.getPosition().lerp(transform.pos.mul(-world.getScale(), new Vector3f()), 0.05f);
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:26,代码来源:Player.java

示例2: render

import org.joml.Vector2f; //导入依赖的package包/类
public void render(Camera camera, TileSheet sheet, Shader shader) {
	Vector2f position = boundingBox.getCenter(), scale = boundingBox.getHalfExtent();
	
	transform.identity().translate(position.x, position.y, 0).scale(scale.x, scale.y, 1); // Middle/Fill
	
	shader.setUniform("projection", camera.getProjection().mul(transform));
	switch (selectedState) {
		case STATE_SELECTED :
			sheet.bindTile(shader, 4, 1);
			break;
		case STATE_CLICKED :
			sheet.bindTile(shader, 7, 1);
			break;
		default :
			sheet.bindTile(shader, 1, 1);
			break;
	}
	Assets.getModel().render();
	
	renderSides(position, scale, camera, sheet, shader);
	renderCorners(position, scale, camera, sheet, shader);
}
 
开发者ID:MarcPopescu-Pfeiffer,项目名称:2DGame,代码行数:23,代码来源:Button.java

示例3: processFaceVertex

import org.joml.Vector2f; //导入依赖的package包/类
/**
 * Processes all the Face vertices by transforming them into the
 * correct data types.
 *
 * @param indices - Indices to process.
 * @param textCoordList - List of read texture coordinates.
 * @param normalsList - List of read normals.
 * @param indicesList - Destination indices list.
 * @param textCoordArr - Destination texture coordinates array.
 * @param normalsArr - Destination normals array.
 */
private static void processFaceVertex(IndexGroup indices, List<Vector2f> textCoordList,
                                      List<Vector3f> normalsList, List<Integer> indicesList,
                                      float[] textCoordArr, float[] normalsArr) {
    // Set index for vertex coordinates.
    int positionIndex = indices.indexPos;
    indicesList.add(positionIndex);

    // Reorder texture coordinates.
    if (indices.indexTextCoordinate >= 0) {
        Vector2f textCoord = textCoordList.get(indices.indexTextCoordinate);
        textCoordArr[positionIndex * 2] = textCoord.x;
        textCoordArr[positionIndex * 2 + 1] = 1 - textCoord.y;
    }
    if (indices.indexVecNormal >= 0) {
        Vector3f vecNormal = normalsList.get(indices.indexVecNormal);
        normalsArr[positionIndex * 3] = vecNormal.x;
        normalsArr[positionIndex * 3 + 1] = vecNormal.y;
        normalsArr[positionIndex * 3 + 2] = vecNormal.z;
    }
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:32,代码来源:OBJLoader.java

示例4: getExportArea

import org.joml.Vector2f; //导入依赖的package包/类
public Rectangle2D getExportArea(ViewPort view)
{
	Vector2fc pos = ViewPort.getWorldPos(view,
			0, 0, new Vector2f());
	Vector2dc offset = ViewPort.getScreenPos(view,
			(int) Math.ceil(pos.x()),
			(int) Math.ceil(pos.y()),
			new Vector2d());

	Vector2fc endPos = ViewPort.getWorldPos(view,
			view.getWidth(),
			view.getHeight(), new Vector2f());
	Vector2dc endScreen = ViewPort.getScreenPos(view,
			(int) Math.floor(endPos.x()),
			(int) Math.floor(endPos.y()),
			new Vector2d());

	return new Rectangle2D(offset.x(), offset.y(),
			endScreen.x() - offset.x(), endScreen.y() - offset.y());
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:21,代码来源:DungeonHandler.java

示例5: decode

import org.joml.Vector2f; //导入依赖的package包/类
@Override
public MovePlayerPacket decode(ByteBuf buf) {
    MovePlayerPacket packet = new MovePlayerPacket();
    packet.setEntityId(ByteBufUtils.readUnsignedVarLong(buf));

    Vector3f position = new Vector3f();
    position.x = ByteBufUtils.readFloatLE(buf);
    position.y = ByteBufUtils.readFloatLE(buf);
    position.z = ByteBufUtils.readFloatLE(buf);
    packet.setPosition(position);

    Vector2f rotation = new Vector2f();
    rotation.x = ByteBufUtils.readFloatLE(buf);
    rotation.y = ByteBufUtils.readFloatLE(buf);
    packet.setRotation(rotation);

    packet.setHeadYaw(ByteBufUtils.readFloatLE(buf));

    packet.setMotionType(MotionType.fromOrdinal(buf.readByte()));
    packet.setOnGround(buf.readBoolean());
    packet.setRidingEntityId(ByteBufUtils.readUnsignedVarLong(buf));

    return packet;
}
 
开发者ID:JungleTree,项目名称:JungleTree,代码行数:25,代码来源:MovePlayerCodec.java

示例6: TextureSheet

import org.joml.Vector2f; //导入依赖的package包/类
public TextureSheet(Texture tex, int subWidth, int subHeight, String name){
	this.texture = tex;
	
	this.subWidth = subWidth;
	this.subHeight = subHeight;
	
	subSize = new Vector2f(this.subWidth, this.subHeight);
	
	this.name = name;
	
	perWidth = texture.width / subWidth;
	perHeight = texture.height / subHeight;
	
	offsets = new Vector2f[perWidth * perHeight];
	
	for(int i=0;i<offsets.length;i++){
		int x = getX(i);
		int y = getY(i);
		offsets[i] = new Vector2f(x, y);
		offsets[i].mul(subSize);
	}
	names = new String[perWidth * perHeight];
	
	sheets.add(this);
}
 
开发者ID:tek256,项目名称:LD38,代码行数:26,代码来源:TextureSheet.java

示例7: processFaceVertex

import org.joml.Vector2f; //导入依赖的package包/类
private static void processFaceVertex(IdxGroup indices, List<Vector2f> textCoordList, List<Vector3f> normList,
                                      List<Integer> indicesList, float[] texCoordArr, float[] normArr) {

    // Set index for vertex coordinates
    int posIndex = indices.idxPos;
    indicesList.add(posIndex);

    // Reorder texture coordinates
    if (indices.idxTextCoord >= 0) {
        Vector2f textCoord = textCoordList.get(indices.idxTextCoord);
        texCoordArr[posIndex * 2] = textCoord.x;
        texCoordArr[posIndex * 2 + 1] = 1 - textCoord.y;
    }
    if (indices.idxVecNormal >= 0) {
        // Reorder vectornormals
        Vector3f vecNorm = normList.get(indices.idxVecNormal);
        normArr[posIndex * 3] = vecNorm.x;
        normArr[posIndex * 3 + 1] = vecNorm.y;
        normArr[posIndex * 3 + 2] = vecNorm.z;
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:22,代码来源:OBJLoader.java

示例8: explode

import org.joml.Vector2f; //导入依赖的package包/类
public static void explode(GobletWorld world, float x, float y, int power, boolean restrict, List<ExplosionUnit> dst)
{
	int ix = (int) Math.floor(x);
	int iy = (int) Math.floor(y);

	ExplosionUnit root = new ExplosionUnit(ix, iy, power);
	dst.add(root);

	spreadAll(world, dst, restrict);

	float maxDist = power * power;
	Vector2f center = new Vector2f(root.x, root.y);
	for(ExplosionUnit explosion : dst)
	{
		float dist = center.distanceSquared(explosion.x, explosion.y);
		attemptFire(world, explosion.x + 0.5F, explosion.y + 0.5F, 1 - dist / maxDist);
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:19,代码来源:Explosion.java

示例9: getNormalizedAnchorOffset

import org.joml.Vector2f; //导入依赖的package包/类
public static Vector2f getNormalizedAnchorOffset(Direction anchor, Vector2f dst)
{
	switch (anchor)
	{
		case EAST:
			return dst.set(1, 0.5F);
		case NORTHEAST:
			return dst.set(1, 0);
		case NORTH:
			return dst.set(0.5F, 0);
		case NORTHWEST:
			return dst.set(0, 0);
		case WEST:
			return dst.set(0, 0.5F);
		case SOUTHWEST:
			return dst.set(0, 1);
		case SOUTH:
			return dst.set(0.5F, 1);
		case SOUTHEAST:
			return dst.set(1, 1);
		case CENTER:
			return dst.set(0.5F, 0.5F);
	}

	return dst.set(0, 0);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:27,代码来源:Gui.java

示例10: setTile

import org.joml.Vector2f; //导入依赖的package包/类
public void setTile(Tile tile, int x, int y) {
    tiles[x + y * width] = tile.getId();
    if(tile.isSolid()) {
        bounding_boxes[x + y * width] = new AABB(new Vector2f(x*2, -y*2), new Vector2f(1,1));
    }else{
        bounding_boxes[x + y * width] = null;
    }
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:9,代码来源:World.java

示例11: circleLineIntersect

import org.joml.Vector2f; //导入依赖的package包/类
public static Vector2f[] circleLineIntersect(Vector2f lineP1, Vector2f lineP2, Vector2f circleCenter, float circleRadius)
{
    // Circle-line intersection
    float x_0 = lineP1.x, y_0 = lineP1.y;
    float x_1 = lineP2.x, y_1 = lineP2.y;
    float x_c = circleCenter.x, y_c = circleCenter.y;

    float f = x_1 - x_0;
    float g = y_1 - y_0;

    float xc0 = x_c - x_0;
    float yc0 = y_c - y_0;

    float t = f * xc0 + g * yc0;

    float fg2 = f * f + g * g;

    float inRoot = (circleRadius * circleRadius + fg2 - pow2f(f * yc0 - g * xc0));
    if(inRoot < 0) { return new Vector2f[0]; }
    if(inRoot == 0)
    {
        float intersectT = t / fg2;
        Vector2f intersection = new Vector2f(intersectT * f, intersectT * g);
        if(between(lineP1, intersection, lineP2)) { return new Vector2f[] { intersection }; }
        else { return new Vector2f[0]; }
    }
    float pm = (float) Math.sqrt(inRoot);
    float intersectT1 = (t + pm) / fg2;
    float intersectT2 = (t - pm) / fg2;
    Vector2f intersect1 = new Vector2f(intersectT1 * f + x_0, intersectT1 * g + y_0);
    Vector2f intersect2 = new Vector2f(intersectT2 * f + x_0, intersectT2 * g + y_0);
    if(between(lineP1, intersect1, lineP2))
    {
        if(between(lineP1, intersect2, lineP2)) { return new Vector2f[] { intersect1, intersect2 }; }
        else { return new Vector2f[] { intersect1 }; }
    }
    else if(between(lineP1, intersect2, lineP2)) { return new Vector2f[] { intersect2 }; }
    return new Vector2f[0];
}
 
开发者ID:Team-2502,项目名称:RobotCode2018,代码行数:40,代码来源:MathUtils.java

示例12: setPlanetAndPlayer

import org.joml.Vector2f; //导入依赖的package包/类
public void setPlanetAndPlayer(Planet planet, Player player) {
	System.out.println(planet.toString());
	player.getComponent(PhysicsComponent2D.class).getBody().getTransform()
			.setTranslation(ConverterUtil.convertToPhysics2D(
					new Vector2f(0, planet.getPlanetData().getFadeRadius() * TileDefinition.TILE_SIZE)));
	planet.setAsScene(player);
}
 
开发者ID:pcfreak9000,项目名称:SpaceExplorer2D,代码行数:8,代码来源:Universe.java

示例13: getCollision

import org.joml.Vector2f; //导入依赖的package包/类
public Collision getCollision(Vector2f point) {
	Vector2f distance = point.sub(center);
	distance.x = Math.abs(distance.x);
	distance.y = Math.abs(distance.y);
	
	distance.sub(half_extent);
	
	return new Collision(distance, distance.x < 0 && distance.y < 0);
}
 
开发者ID:MarcPopescu-Pfeiffer,项目名称:2DGame,代码行数:10,代码来源:AABB.java

示例14: getColumn

import org.joml.Vector2f; //导入依赖的package包/类
@Override
public Vector2f getColumn(int column, Vector2f dest) throws IndexOutOfBoundsException
{
	switch (column)
	{
		case 0:
			return dest.set(m00, m10);
		case 1:
			return dest.set(m01, m11);
		default:
			throw new IndexOutOfBoundsException();
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:14,代码来源:Matrix2f.java

示例15: getRow

import org.joml.Vector2f; //导入依赖的package包/类
@Override
public Vector2f getRow(int row, Vector2f dest) throws IndexOutOfBoundsException
{
	switch(row)
	{
		case 0:
			return dest.set(m00, m01);
		case 1:
			return dest.set(m10, m11);
		default:
			throw new IndexOutOfBoundsException();
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:14,代码来源:Matrix2f.java


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