Package engine.tools
Class MousePicker
java.lang.Object
engine.tools.MousePicker
Mousepicker class is used to know with which Tile in the world the mouse is intersecting.
This is done by reversing the process in which the mouse position is calculated by going backwards from 3D ray to position in 2D space.
-
Constructor Summary
ConstructorsConstructorDescriptionMousePicker
(Camera camera, org.joml.Matrix4f projectionMatrix, WorldGrid worldGrid) Instantiated and takes in the cameram, WorldGrid and projection matrix. -
Method Summary
Modifier and TypeMethodDescriptionorg.joml.Vector3f
org.joml.Vector3f
org.joml.Vector2i
Gets the current tile on which the mouse is hovering.org.joml.Vector2f
getNormalizedDeviceCoords
(float mouseX, float mouseY) Normalizes the position coordinates to the system used by OpenGL to render and the DisplayManager.void
update()
Updates variables in the mousepicker class with the new ones when called each frame.
-
Constructor Details
-
MousePicker
Instantiated and takes in the cameram, WorldGrid and projection matrix.- Parameters:
camera
-projectionMatrix
-worldGrid
-
-
-
Method Details
-
getCurrentRay
public org.joml.Vector3f getCurrentRay() -
getCurrentTerrainPoint
public org.joml.Vector3f getCurrentTerrainPoint() -
getCurrentTileCoords
public org.joml.Vector2i getCurrentTileCoords()Gets the current tile on which the mouse is hovering.- Returns:
-
update
public void update()Updates variables in the mousepicker class with the new ones when called each frame. -
getNormalizedDeviceCoords
public org.joml.Vector2f getNormalizedDeviceCoords(float mouseX, float mouseY) Normalizes the position coordinates to the system used by OpenGL to render and the DisplayManager.- Parameters:
mouseX
-mouseY
-- Returns:
-