Hi,
I want to rotate a sprite around its y-axis. To do this I have overwritten the transform method like shown below.
It is working, but the rotation added by me does not rotate exactly around the y-axis and the center of the sprite. I tried to do the rotation at different positions of the translate method, but with no luck.
Any help on this would be great,
zombie
if ( relativeAnchorPoint_ && (transformAnchor_.x != 0 || transformAnchor_.y != 0 ) )
glTranslatef( RENDER_IN_SUBPIXEL(-transformAnchor_.x), RENDER_IN_SUBPIXEL(-transformAnchor_.y), vertexZ_);
if (transformAnchor_.x != 0 || transformAnchor_.y != 0 )
glTranslatef( RENDER_IN_SUBPIXEL(position_.x + transformAnchor_.x), RENDER_IN_SUBPIXEL(position_.y + transformAnchor_.y), vertexZ_);
else if ( position_.x !=0 || position_.y !=0)
glTranslatef( RENDER_IN_SUBPIXEL(position_.x), RENDER_IN_SUBPIXEL(position_.y), vertexZ_ );
// ADDED
// ADDED
// ADDED
glRotatef( -50.0f, 0.0f, 1.0f, 0.0f );
// rotate
if (rotation_ != 0.0f )
glRotatef( -rotation_, 0.0f, 0.0f, 1.0f );
// scale
if (scaleX_ != 1.0f || scaleY_ != 1.0f)
glScalef( scaleX_, scaleY_, 1.0f );
// restore and re-position point
if (transformAnchor_.x != 0.0f || transformAnchor_.y != 0.0f)
glTranslatef(RENDER_IN_SUBPIXEL(-transformAnchor_.x), RENDER_IN_SUBPIXEL(-transformAnchor_.y), vertexZ_);