glRotatef
기능을 사용하지 않고 JOGL에서 Z 축에 대해 이미지를 회전하는 방법은 무엇입니까? 내가 얻는 방법을 모르겠다 z가이기 때문에 e.getZ()
기능이 없습니다. 어떻게 한 사람이 z_prime
을 계산할 수 있습니까? 지금 내가 z 축을 중심으로 회전하려 할 때, 그것은 좋아하는 것에서 z 축을 중심으로 회전 한 다음 y 축을 중심으로 회전하고 다시 z로 돌아 간다. (내가 z_rot += y_prime
을 가지고 있기 때문에 의미가있다. 다만 Z 그것에 대해 회전이 모든 회전이 일치 중간 상태를 사용되는 Z '?glRotateF 내장 함수를 사용하지 않고 JOGL에서 Z 축에 대한 이미지를 회전하는 방법
public void transform(float[] vertices_in, float[] vertices_out){
// perform your transformation
int length = vertices_in.length;
float[] transformMatrix =
{
r11, r12, r13, tx,
r21, r22, r23, ty,
r31, r32, r33, tz,
0, 0, 0, 1
};
// Fill in the empty verticesout vector
for(int i = 0; i < vertices_in.length; i++)
{
vertices_out[i] = vertices_in[i];
}
// loop through and set the new matrix (after translation)
// because
// 1 0 0 0
// 0 1 0 0
// 0 0 1 0
// X Rotation
for(int i = 0; i < vertices_out.length; i += 3)
{
vertices_out[i+1] = vertices_out[i+1] * (float)Math.cos(xRot) - vertices_out[i+2] * (float)Math.sin(xRot); //New Y
vertices_out[i+2] = vertices_out[i+1] * (float)Math.sin(xRot) + vertices_out[i+2] * (float)Math.cos(xRot); //New Z
}
// Y Rotation
for(int i = 0; i < vertices_out.length; i += 3)
{
vertices_out[i] = vertices_out[i] * (float)Math.cos(yRot) + vertices_out[i+2] * (float)Math.sin(yRot);
vertices_out[i+2] = vertices_out[i]*-(float)Math.sin(yRot) + vertices_out[i+2]*(float)Math.cos(yRot);
}
// Z Rotation
for(int i = 0; i < vertices_out.length; i += 3)
{
vertices_out[i] = vertices_out[i] * (float)Math.cos(zRot) - vertices_out[i+1] * (float)Math.sin(zRot);
vertices_out[i+1] = vertices_out[i] * (float)Math.sin(zRot) + vertices_out[i+1] * (float)Math.cos(zRot);
}
// Translation & Scaling
for(int i = 0; i < vertices_in.length; i+=3)
{
vertices_out[i] = vertices_out[i] * transformMatrix[0] + transformMatrix[3]; //x'
vertices_out[i+1] = vertices_out[i+1] * transformMatrix[5] + transformMatrix[7]; //y'
vertices_out[i+2] = vertices_out[i+2] * transformMatrix[10] + transformMatrix[11]; //z'
}
}
@Override
public void mouseDragged(MouseEvent e)
{
if(rotating)
{
float XX = (e.getX()-windowWidth*0.5f)*orthoX/windowWidth;
float YY = -(e.getY()-windowHeight*0.5f)*orthoX/windowWidth;
float x_prime = (StartXX - XX);
float y_prime = (StartYY - YY);
if(rightMouseClick)
{
zRot += y_prime/50;
}
else
{
xRot += y_prime/50;
yRot += x_prime/50;
StartYY = YY;
StartXX = XX;
}
}
}
무엇? 트랙볼을 구현하려고합니까? –
아니요, 이미지를 z 축 주위로 회전하려고합니다. 그것은 내가 잘못하고있는 것처럼 보입니다. 처음에는 z에 대해 이미지가 증가하는 것처럼 보입니다. 그러면 y가 증가하고 z가 다시 증가하는 것처럼 보입니다. z 축에 대해 회전시키고 싶습니다. 말 되네? 아니면 @ NicoSchertler가 가능하지 않습니까? – Yusha