org.fxyz3d.utils.CameraAdapter Maven / Gradle / Ivy
The newest version!
/**
* CameraAdapter.java
*
* Copyright (c) 2013-2016, F(X)yz
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of F(X)yz, any associated website, nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL F(X)yz BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.fxyz3d.utils;
import javafx.geometry.Point3D;
import javafx.scene.Camera;
import javafx.scene.transform.Transform;
import javafx.util.Callback;
/**
*
* @author Jason Pollastrini aka jdub1581
*/
public interface CameraAdapter {
public Camera getCamera();
/*==========================================================================
Callbacks
| R | Up| F | | P|
U |mxx|mxy|mxz| |tx|
V |myx|myy|myz| |ty|
N |mzx|mzy|mzz| |tz|
*/
//Forward / look direction
Callback F = (a) -> {
return new Point3D(a.getMzx(), a.getMzy(), a.getMzz());
};
Callback N = (a) -> {
return new Point3D(a.getMxz(), a.getMyz(), a.getMzz());
};
// up direction
Callback UP = (a) -> {
return new Point3D(a.getMyx(), a.getMyy(), a.getMyz());
};
Callback V = (a) -> {
return new Point3D(a.getMxy(), a.getMyy(), a.getMzy());
};
// right direction
Callback R = (a) -> {
return new Point3D(a.getMxx(), a.getMxy(), a.getMxz());
};
Callback U = (a) -> {
return new Point3D(a.getMxx(), a.getMyx(), a.getMzx());
};
//position
Callback P = (a) -> {
return new Point3D(a.getTx(), a.getTy(), a.getTz());
};
default Point3D getCameraForwardVectorColumn() {
return F.call(getCamera().getLocalToSceneTransform());
}
default Point3D getCameraForwardVectorRow() {
return N.call(getCamera().getLocalToSceneTransform());
}
default Point3D getCameraRightVectorColumn() {
return R.call(getCamera().getLocalToSceneTransform());
}
default Point3D getCameraRightVectorRow() {
return U.call(getCamera().getLocalToSceneTransform());
}
default Point3D getCameraUpVectorColumn() {
return UP.call(getCamera().getLocalToSceneTransform());
}
default Point3D getCameraUpVectorRow() {
return V.call(getCamera().getLocalToSceneTransform());
}
default Point3D getCameraScenePosition() {
return P.call(getCamera().getLocalToSceneTransform());
}
}