小编Zut*_*tty的帖子

OpenGL 3(LWJGL)LookAt Matrix混乱

我正在使用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)

java opengl matrix lwjgl glulookat

6
推荐指数
1
解决办法
4901
查看次数

使用Result Transformer计算Hibernate 4.1 Count Projection Type Mismatch(Long/Integer)

我有一个实体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某种方式返回使结果转换器转换LongInteger

java hibernate criteria

5
推荐指数
1
解决办法
4240
查看次数

标签 统计

java ×2

criteria ×1

glulookat ×1

hibernate ×1

lwjgl ×1

matrix ×1

opengl ×1