JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
TestPMVMatrix02NOUI.java
Go to the documentation of this file.
1/**
2 * Copyright 2012 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.opengl.test.junit.math;
30
31import org.junit.Before;
32import org.junit.Test;
33import org.junit.FixMethodOrder;
34import org.junit.runners.MethodSorters;
35
36import com.jogamp.opengl.util.PMVMatrix;
37import com.jogamp.junit.util.JunitTracer;
38import com.jogamp.math.Matrix4f;
39import com.jogamp.math.Vec3f;
40import com.jogamp.opengl.fixedfunc.GLMatrixFunc;
41
42import static org.junit.Assert.assertEquals;
43
44/**
45 * @author Thomas De Bodt
46 */
47@FixMethodOrder(MethodSorters.NAME_ASCENDING)
48public class TestPMVMatrix02NOUI extends JunitTracer {
49
50 private PMVMatrix fMat;
51
52 @Before
53 public void setUp() throws Exception {
54 fMat = new PMVMatrix();
55 }
56
57 @Test
58 public void testLookAtNegZIsNoOp() throws Exception {
60 // Look towards -z
61 fMat.gluLookAt(
62 new Vec3f(0, 0, 0),
63 new Vec3f(0, 0, -1),
64 new Vec3f(0, 1, 0)
65 );
66 final Matrix4f mvMatrix = fMat.getMv();
67 assertEquals(
68 /**
69 * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward.
70 */
71 new Matrix4f( new float[] {
72 1, 0, 0, 0,
73 0, 1, 0, 0,
74 0, 0, 1, 0,
75 0, 0, 0, 1
76 }),
77 mvMatrix
78 );
79 }
80 @Test
81 public void testLookAtPosY() throws Exception {
83 // Look towards +y
84 fMat.gluLookAt(
85 new Vec3f(0, 0, 0),
86 new Vec3f(0, 1, 0),
87 new Vec3f(0, 0, 1)
88 );
89 final Matrix4f mvMatrix = fMat.getMv();
90 assertEquals(
91 /**
92 * The 3 rows of the matrix (= the 3 columns of the array/buffer) should be: side, up, -forward.
93 */
94 new Matrix4f(new float[] {
95 1, 0, 0, 0,
96 0, 0, -1, 0,
97 0, 1, 0, 0,
98 0, 0, 0, 1
99 }),
100 mvMatrix
101 );
102 }
103
104 public static void main(final String args[]) {
105 org.junit.runner.JUnitCore.main(TestPMVMatrix02NOUI.class.getName());
106 }
107}
Basic 4x4 float matrix implementation using fields for intensive use-cases (host operations).
Definition: Matrix4f.java:89
3D Vector based upon three float components.
Definition: Vec3f.java:37
final Matrix4f getMv()
Returns the modelview matrix (Mv).
PMVMatrix implements a subset of the fixed function pipeline GLMatrixFunc using PMVMatrix4f.
Definition: PMVMatrix.java:62
final void glMatrixMode(final int matrixName)
Sets the current matrix mode.
Definition: PMVMatrix.java:218
final void gluLookAt(final Vec3f eye, final Vec3f center, final Vec3f up)
Multiply the current matrix with the eye, object and orientation, i.e.
Definition: PMVMatrix.java:507
Subset of OpenGL fixed function pipeline's matrix operations.
static final int GL_MODELVIEW
Matrix mode modelview.