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


Java Vector2d类代码示例

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


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

示例1: getExportArea

import org.joml.Vector2d; //导入依赖的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

示例2: selectGameItem

import org.joml.Vector2d; //导入依赖的package包/类
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
    // Transform mouse coordinates into normalized spaze [-1, 1]
    int wdwWitdh = window.getWidth();
    int wdwHeight = window.getHeight();

    float x = (float) (2 * mousePos.x) / (float) wdwWitdh - 1.0f;
    float y = 1.0f - (float) (2 * mousePos.y) / (float) wdwHeight;
    float z = -1.0f;

    invProjectionMatrix.set(window.getProjectionMatrix());
    invProjectionMatrix.invert();

    tmpVec.set(x, y, z, 1.0f);
    tmpVec.mul(invProjectionMatrix);
    tmpVec.z = -1.0f;
    tmpVec.w = 0.0f;

    Matrix4f viewMatrix = camera.getViewMatrix();
    invViewMatrix.set(viewMatrix);
    invViewMatrix.invert();
    tmpVec.mul(invViewMatrix);

    mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);

    return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:27,代码来源:MouseBoxSelectionDetector.java

示例3: createReflectedLaser

import org.joml.Vector2d; //导入依赖的package包/类
/**
 * Creates a LaserModel object and passes it to the lasers list of the objectManager
 * This is used for all reflected lasers to avoid calculating redundant reflections on lasers
 * @param begX
 * @param begY
 * @param vect
 * @return
 */
public static LaserModel createReflectedLaser(float begX, float begY, Vector2d vect) {
	float[] texture = new float[] {
			0, 0,
			1, 0,
			1, 1,
			0, 1,
	};
	
	int[] indices = new int[] {
			0, 1, 2,
			2, 3, 0
	};
	
	return new LaserModel(texture, indices, begX, begY, vect); // Return the new Laser
}
 
开发者ID:mattgd,项目名称:Laser-Amazer,代码行数:24,代码来源:CreateModel.java

示例4: selectGameItem

import org.joml.Vector2d; //导入依赖的package包/类
public boolean selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
    // Transform mouse coordinates into normalized spaze [-1, 1]
    int wdwWitdh = window.getWidth();
    int wdwHeight = window.getHeight();
    
    float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
    float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
    float z = -1.0f;

    invProjectionMatrix.set(window.getProjectionMatrix());
    invProjectionMatrix.invert();
    
    tmpVec.set(x, y, z, 1.0f);
    tmpVec.mul(invProjectionMatrix);
    tmpVec.z = -1.0f;
    tmpVec.w = 0.0f;
    
    Matrix4f viewMatrix = camera.getViewMatrix();
    invViewMatrix.set(viewMatrix);
    invViewMatrix.invert();
    tmpVec.mul(invViewMatrix);
    
    mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);

    return selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:27,代码来源:MouseBoxSelectionDetector.java

示例5: selectGameItem

import org.joml.Vector2d; //导入依赖的package包/类
public void selectGameItem(GameItem[] gameItems, Window window, Vector2d mousePos, Camera camera) {
    // Transform mouse coordinates into normalized spaze [-1, 1]
    int wdwWitdh = window.getWidth();
    int wdwHeight = window.getHeight();
    
    float x = (float)(2 * mousePos.x) / (float)wdwWitdh - 1.0f;
    float y = 1.0f - (float)(2 * mousePos.y) / (float)wdwHeight;
    float z = -1.0f;

    invProjectionMatrix.set(window.getProjectionMatrix());
    invProjectionMatrix.invert();
    
    tmpVec.set(x, y, z, 1.0f);
    tmpVec.mul(invProjectionMatrix);
    tmpVec.z = -1.0f;
    tmpVec.w = 0.0f;
    
    Matrix4f viewMatrix = camera.getViewMatrix();
    invViewMatrix.set(viewMatrix);
    invViewMatrix.invert();
    tmpVec.mul(invViewMatrix);
    
    mouseDir.set(tmpVec.x, tmpVec.y, tmpVec.z);

    selectGameItem(gameItems, camera.getPosition(), mouseDir);
}
 
开发者ID:lwjglgamedev,项目名称:lwjglbook,代码行数:27,代码来源:MouseBoxSelectionDetector.java

示例6: contains

import org.joml.Vector2d; //导入依赖的package包/类
public boolean contains(Vector2d position){
	if(position.y >= position.y - (size.y / 2f) && position.y <= position.y + (size.y / 2f)){
		if(position.y >= position.y - (size.y / 2f) && position.y <= position.y + (size.y / 2f)){
			return true;
		}
	}
	return false;
}
 
开发者ID:tek256,项目名称:LD38,代码行数:9,代码来源:UIElement.java

示例7: drawCursor

import org.joml.Vector2d; //导入依赖的package包/类
public static void drawCursor(GraphicsContext g, ViewPort v, Vector2fc mouse)
{
	Vector2dc offset = ViewPort.getScreenPos(v,
			(int) Math.floor(mouse.x()),
			(int) Math.floor(mouse.y()),
			new Vector2d());

	g.save();
	g.translate(offset.x(), offset.y());
	g.scale(v.getUnitScale(), v.getUnitScale());
	g.setFill(COLOR_CURSOR);
	g.fillRect(0, 0, 1, 1);
	g.restore();
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:15,代码来源:Renderer.java

示例8: LaserModel

import org.joml.Vector2d; //导入依赖的package包/类
/**
 * New LaserModel given a vector
 * @param tCoords
 * @param indices
 * @param x0
 * @param y0
 * @param vect
 */
LaserModel(float[] tCoords, int[] indices, float x0, float y0, Vector2d vect) {
	super(getVertices(x0, y0, (float)originV.angle(vect), (float)vect.length(), LASER_WIDTH), tCoords, indices, 4, GameTexture.LASER.getPath());
	this.angle = (float)originV.angle(vect);
	this.vect = vect;
	coords[0] = x0;
	coords[1] = y0;
	
	determineDirection();
}
 
开发者ID:mattgd,项目名称:Laser-Amazer,代码行数:18,代码来源:LaserModel.java

示例9: MouseInput

import org.joml.Vector2d; //导入依赖的package包/类
/**
 * Sets the vectors to the default values.
 */

public MouseInput(){
    previousPos = new Vector2d(-1, -1);
    currentPos = new Vector2d(0, 0);
    displVec = new Vector2f();
}
 
开发者ID:gjkf,项目名称:seriousEngine,代码行数:10,代码来源:MouseInput.java

示例10: tranform

import org.joml.Vector2d; //导入依赖的package包/类
public Vector2d tranform(Vector2d vec)
{
	final Vector4d tmp = new Vector4d();
	tmp.set(vec.x, vec.y, 0, 1);
	tmp.mul(Combined);
	return vec.set(tmp.x, tmp.y);
}
 
开发者ID:Wicpar,项目名称:ClassicSinkingSim,代码行数:8,代码来源:Camera.java

示例11: update

import org.joml.Vector2d; //导入依赖的package包/类
public static void update(Mouse mouse, Keyboard keyboard, Map map, Camera cam) {
    if (mouse.pressed.left) {
        if (!containsData() || !checkUndergroundPermissions()) {
            return;
        }
        tile = cam.getHoveredTile();
        location = calculateLocation(cam);
        point = new Vector2d(tile.getX()+location.getHorizontalAlign()/4f, tile.getY()+location.getVerticalAlign()/4f);
        placeEntity(map, tile, location, Globals.floor);
        object = tile.getGridEntity(Globals.floor, location);
        map.newAction();
    }
    else if (object != null && mouse.hold.left) {
        Vector3d camPosition = cam.getPosition();
        double deltaX = camPosition.x - point.x;
        double deltaY = camPosition.y - point.y;
        double rotation = Math.atan2(deltaY, deltaX)+Math.PI/2f;
        if (!keyboard.isHold(KeyEvent.VK_SHIFT)) {
            rotation = getClampedRotation(rotation);
        }
        object.setRotation(rotation);
        map.getSymmetry().mirrorObjectRotation(tile, object, rotation, location, Globals.floor);
    }

    if (mouse.released.left) {
        tile = null;
        point = null;
        object = null;
        location = null;
    }

    if (mouse.hold.right && !mouse.hold.left) {
        location = calculateLocation(cam);
        cam.getHoveredTile().setGameObject(null, null, Globals.floor);
        map.getSymmetry().mirrorObject(cam.getHoveredTile(), null, location, Globals.floor);
        map.newAction();
    }
}
 
开发者ID:Warlander,项目名称:DeedPlanner-2,代码行数:39,代码来源:ObjectsUpdater.java

示例12: MouseHandler

import org.joml.Vector2d; //导入依赖的package包/类
/**
 * Default constructor for the mouse handler initializing all the
 * fields.
 */
public MouseHandler() {
	previousPos = new Vector2d(-1, -1);
	currentPos = new Vector2d(0, 0);
	dispelVec = new Vector2f();
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:10,代码来源:MouseHandler.java

示例13: drawDungeon

import org.joml.Vector2d; //导入依赖的package包/类
public static void drawDungeon(LayeredCanvas canvas, ViewPort v, Dungeon dungeon, boolean draft)
{
	GraphicsContext solids = canvas.getCanvas(LAYER_SOLID).getGraphicsContext2D();
	GraphicsContext shadows = canvas.getCanvas(LAYER_SHADOW).getGraphicsContext2D();
	GraphicsContext items = canvas.getCanvas(LAYER_ITEM).getGraphicsContext2D();
	GraphicsContext floors = canvas.getCanvas(LAYER_FLOOR).getGraphicsContext2D();

	DungeonTileRenderer renderer = new DungeonTileRenderer();
	Vector2f vec2f = new Vector2f();
	Vector2d vec2d = new Vector2d();
	for(DungeonChunk chunk : dungeon.getMap().getLoadedChunks())
	{
		Vector2fc chunkPos = chunk.getChunkPos(vec2f);

		for(int i = 0; i < chunk.getChunkSize(); ++i)
		{
			for(int j = 0; j < chunk.getChunkSize(); ++j)
			{
				Vector2dc offset = ViewPort.getScreenPos(v,
						(int) Math.floor(chunkPos.x() + i),
						(int) Math.floor(chunkPos.y() + j),
						vec2d);

				renderer.posX = chunkPos.x() + i;
				renderer.posY = chunkPos.y() + j;
				renderer.solid = chunk.solids.get(i, j);
				renderer.permeable = chunk.permeables.get(i, j);
				renderer.direction = chunk.directions.get(i, j);
				renderer.region = chunk.regions.get(i, j);
				renderer.item = chunk.items.get(i, j);

				//Background Pass
				drawTile(renderer.solid ? solids : floors,
						renderer, dungeon.getBlockTile(renderer.region),
						offset.x(), offset.y(),
						v.getUnitScale(), v.getUnitScale());

				//Foreground Pass
				if (renderer.item != 0)
				{
					GraphicsContext g;
					DungeonTile tile = DungeonTile.getTileByID(renderer.item);
					if (tile instanceof TileItem)
					{
						g = ((TileItem) tile).shouldRender3D() ? solids : items;
					}
					else
					{
						g = floors;
					}

					drawTile(g,
							renderer, tile,
							offset.x(), offset.y(),
							v.getUnitScale(), v.getUnitScale());
				}
			}
		}
	}

	if (!draft)
	{
		SnapshotParameters params = new SnapshotParameters();
		params.setFill(Color.TRANSPARENT);
		WritableImage image = canvas.getCanvas(LAYER_SOLID).snapshot(params, null);
		drawShadow(image, v.getUnitScale(), shadows);
	}
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:69,代码来源:Renderer.java

示例14: getScreenPos

import org.joml.Vector2d; //导入依赖的package包/类
public static Vector2d getScreenPos(ViewPort view, float posX, float posY, Vector2d dst)
{
	return dst.set(posX * view.unitScale + view.x, posY * view.unitScale + view.y);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:5,代码来源:ViewPort.java

示例15: MouseInput

import org.joml.Vector2d; //导入依赖的package包/类
public MouseInput() {
    previousPos = new Vector2d(-1, -1);
    currentPos = new Vector2d(0, 0);
    displVec = new Vector2f();
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:6,代码来源:MouseInput.java


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