California

10-02-2016, 10:32 AM

I want to Rotate my object around it's axis , i.e i want to create a fan like rotation

But i am not able to get the desired effect

The following it's the code:

Matrix4f matrix = new Matrix4f();

matrix.setIdentity();

Matrix4f.translate(translation, matrix, matrix);

Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1,0,0), matrix, matrix);

Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0,1,0), matrix, matrix);

Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0,0,1), matrix, matrix);

Matrix4f.scale(new Vector3f(scale,scale,scale), matrix, matrix);

My vertex code:

vec4 worldPosition = transformationMatrix * vec4(position,1.0);

vec4 positionRelativeToCam = viewMatrix*worldPosition;

gl_Position = projectionMatrix *positionRelativeToCam;

Main Game Loop:

Object.increaseRotation(0,0,1f);

Rotating Along Z axis also make by object cange it's y and x position thus making it revoving with rotation.

But, it's not rotating along it's own axis. What am I missing here?

Please Help

Full Code - dropbox.com/sh/1glu6x4ajd6y4mw/AABvIPdCcUw4HwI9aZkiM5z4a/src?dl=0

sample image - i.stack.imgur.com/knBlT.gif

But i am not able to get the desired effect

The following it's the code:

Matrix4f matrix = new Matrix4f();

matrix.setIdentity();

Matrix4f.translate(translation, matrix, matrix);

Matrix4f.rotate((float) Math.toRadians(rx), new Vector3f(1,0,0), matrix, matrix);

Matrix4f.rotate((float) Math.toRadians(ry), new Vector3f(0,1,0), matrix, matrix);

Matrix4f.rotate((float) Math.toRadians(rz), new Vector3f(0,0,1), matrix, matrix);

Matrix4f.scale(new Vector3f(scale,scale,scale), matrix, matrix);

My vertex code:

vec4 worldPosition = transformationMatrix * vec4(position,1.0);

vec4 positionRelativeToCam = viewMatrix*worldPosition;

gl_Position = projectionMatrix *positionRelativeToCam;

Main Game Loop:

Object.increaseRotation(0,0,1f);

Rotating Along Z axis also make by object cange it's y and x position thus making it revoving with rotation.

But, it's not rotating along it's own axis. What am I missing here?

Please Help

Full Code - dropbox.com/sh/1glu6x4ajd6y4mw/AABvIPdCcUw4HwI9aZkiM5z4a/src?dl=0

sample image - i.stack.imgur.com/knBlT.gif