Merge branch 'main' of https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
@@ -43,8 +43,7 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
private final Paint backgroundColor = new Paint();
|
private final Paint backgroundColor = new Paint();
|
||||||
|
|
||||||
private Matrix4f modelMatrix = new Matrix4f(); // The model view matrix for the 3D to 2D transformation.
|
private Matrix4f modelMatrix = new Matrix4f(); // The model view matrix for the 3D to 2D transformation.
|
||||||
private Matrix4f viewMatrix = new Matrix4f()
|
private Matrix4f viewMatrix = new Matrix4f(); // The view matrix for the 3D to 2D transformation.
|
||||||
.lookAt(new Vector3f(4, 4, 4), new Vector3f(0, 0, 0), new Vector3f(0, 1, 0)); // The view matrix for the 3D to 2D transformation.
|
|
||||||
private Matrix4f projectionMatrix = new Matrix4f(); // The projection matrix for the 3D to 2D transformation.
|
private Matrix4f projectionMatrix = new Matrix4f(); // The projection matrix for the 3D to 2D transformation.
|
||||||
private final Vector4f objectPosition = new Vector4f(0, 0, 0, 1); // The location of the object in 3D space.
|
private final Vector4f objectPosition = new Vector4f(0, 0, 0, 1); // The location of the object in 3D space.
|
||||||
private ConcurrentLinkedQueue<Vector2f> vectors = new ConcurrentLinkedQueue<>();
|
private ConcurrentLinkedQueue<Vector2f> vectors = new ConcurrentLinkedQueue<>();
|
||||||
@@ -172,9 +171,9 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
|
|
||||||
|
|
||||||
private Vector2f projectVertex(Vector3f point, int virtualWidth, int virtualHeight) {
|
private Vector2f projectVertex(Vector3f point, int virtualWidth, int virtualHeight) {
|
||||||
modelMatrix
|
viewMatrix
|
||||||
.identity()
|
.identity()
|
||||||
.translate(-objectPosition.x, -objectPosition.y, -objectPosition.z);
|
.lookAt(new Vector3f(0, 0, -5), new Vector3f(0, 0, 0), new Vector3f(0, 1, 0));
|
||||||
|
|
||||||
// Transform the projection matrix to a perspective projection matrix
|
// Transform the projection matrix to a perspective projection matrix
|
||||||
// Perspective transformation conserves the depth of the object
|
// Perspective transformation conserves the depth of the object
|
||||||
@@ -203,9 +202,13 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
if (this.exercise == null)
|
if (this.exercise == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0; i < axisVectors.length/2; i++)
|
for (int i = 0, startX, endX, startY, endY; i < axisVectors.length/2; i++)
|
||||||
{
|
{
|
||||||
canvas.drawLine(axisVectors[i*2].x, axisVectors[i*2].y, axisVectors[i*2+1].x, axisVectors[i*2+1].y, this.targetPaint);
|
startX = (int)Math.max(0, Math.min(this.screenDimensions.x, (int)axisVectors[i*2].x));
|
||||||
|
endX = (int)Math.max(0, Math.min(this.screenDimensions.x, (int)axisVectors[i*2+1].x));
|
||||||
|
startY = (int)Math.max(0, Math.min(this.screenDimensions.y, (int)axisVectors[i*2].y));
|
||||||
|
endY = (int)Math.max(0, Math.min(this.screenDimensions.y, (int)axisVectors[i*2+1].y));
|
||||||
|
canvas.drawLine(startX, startY, endX, endY, this.targetPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( Vector2f point : this.vectors)
|
for ( Vector2f point : this.vectors)
|
||||||
|
Reference in New Issue
Block a user