I am facing a problem when using joglutils which uses opengl Y-axis-Up coordinate system and has the view direction from (0,0,0) to (0,0,-1)
Usually google sketchup and some other software uses Z-axis as up coordinate. So when loading the Z-axis-UP model, I have to change the view orientation.
The idea occurred to me firstly is to pre-rotate the camera -
Rotf rot90 = null;
if(getAsset()!=null && getAsset().getUpAxis().equals(UpAxisType.X_UP) || getAsset().getUpAxis().equals(UpAxisType.Z_UP)){
Vec3f axis = new Vec3f();
if(getAsset().getUpAxis().equals(UpAxisType.Z_UP)){
axis = new Vec3f(1, 0, 0);
}else{
axis = new Vec3f(0, 0, 1);
}
rot90 = new Rotf(axis, (float)Math.PI/2);
}
……
if(rot90!=null){
clcamera.setOrientation(rot90.times(clcamera.getOrientation()));
}
[/quote]
I think it is not correct because the later cacualtions will get wrong orientation.
I also try to pre-rotate the world coordinate by a gl.glRotatef before rendering the camera and the scene. But we found the model being rendered mysteriously twice (one is rotated, one is not) and we cannot find out why. And I think it may have other side-effects. For example Viewport width and height are changed.
Can anybody have sophisticated arithmetic to handle the different up-axis problem? Thanks.