我正在使用LWJGL学习OpenGL 3.我试图实现一个等效的gluLookAt()
,虽然它的工作原因我有点困惑为什么.
我承认只是从网络上的各种来源复制这些代码,但经过深入研究后,我认为理解它背后的数学,并且我理解LWJGL在做什么.
但是,"正确" gluLookAt
代码在我的应用程序中表现不正确,因为相机似乎转向了错误的方式.我只设法获得通过转置正交向量的工作我的代码forward
,side
以及up
(希望我使用的是正确的术语!),我敢肯定是错误的...
private static final Vector3f forward = new Vector3f();
private static final Vector3f side = new Vector3f();
private static final Vector3f up = new Vector3f();
private static final Vector3f eye = new Vector3f();
public static Matrix4f lookAt(float eyeX, float eyeY, float eyeZ,
float centerX, float centerY, float centerZ,
float upX, float upY, float upZ) {
forward.set(centerX - eyeX, centerY - eyeY, centerZ - eyeZ);
forward.normalise();
up.set(upX, upY, …
Run Code Online (Sandbox Code Playgroud) 我有一个实体bean FooEntity
和DAO方法来获取由该实体上的属性分组的行计数,封装在视图模型bean中FooCount
.
public List<FooCount> groupByFoo() {
return sessionFactory.getCurrentSession()
.createCriteria(FooEntity.class)
.setProjection(Projections.projectionList()
.add(Projections.groupProperty("foo"), "foo")
.add(Projections.count("foo"), "count")
).setResultTransformer(Transformers.aliasToBean(FooCount.class))
.list();
}
public class FooCount {
private String foo;
private Integer count; // <-- this is the problem
// getters/setters...
}
Run Code Online (Sandbox Code Playgroud)
运行它会产生异常,因为Projections.count()
产生一个Long
而不是一个Integer
.
org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of FooCount.count
at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:119)
--snip--
Caused by: java.lang.IllegalArgumentException: argument type mismatch
Run Code Online (Sandbox Code Playgroud)
它可以工作,如果我count
改为a Long
但我宁愿不更改视图模型类,因为它使用的是其他各种地方.
我可以Projections.count()
以Integer
某种方式返回或使结果转换器转换Long
为Integer
?