void Iw2DSprite::Render(CIwSVec2 pPosition) { if(m_Angle > 0 || m_Angle < 0) { CIwMat2D RotationMatrix; RotationMatrix.SetRot(m_Angle, CIwVec2(pPosition.x + m_Center.x , pPosition.y + m_Center.y) ); Iw2DSetTransformMatrix(RotationMatrix); } if( m_Flip.x > 0 && m_Flip.y > 0) Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_ROT180); else if( m_Flip.x > 0 && m_Flip.y <= 0) Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_FLIP_X); else if( m_Flip.y > 0 && m_Flip.x <= 0) Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_FLIP_Y); Iw2DDrawImageRegion(m_SpriteSheet, pPosition, m_FrameSize, m_DrawRect, m_FrameSize); if(m_Angle > 0 || m_Angle < 0) Iw2DSetTransformMatrix(CIwMat2D::g_Identity); if( m_Flip.x > 0 || m_Flip.y > 0) Iw2DSetImageTransform(IW_2D_IMAGE_TRANSFORM_NONE); }
void myIwGxDrawStar(int x, int y, CIwSVec2 texpos, int iscale, iwangle rotval, int alphaf) { CIwMat2D transformMatrix; int i; // if (ssend_vertices + 4 > (MX_VERTICES)) { myIwGxDoneBonus(); ssend_vertices = 0; } transformMatrix = CIwMat2D::g_Identity; transformMatrix.SetRot(rotval, CIwVec2(x, y)); // // 0 = top-left // 1 = bottom-left // 2 = bottom-right // 3 = top-right // svertices[ssend_vertices + 0].x = x - iscale; svertices[ssend_vertices + 0].y = y - iscale; svertices[ssend_vertices + 1].x = x - iscale; svertices[ssend_vertices + 1].y = y + iscale; svertices[ssend_vertices + 2].x = x + iscale; svertices[ssend_vertices + 2].y = y + iscale; svertices[ssend_vertices + 3].x = x + iscale; svertices[ssend_vertices + 3].y = y - iscale; // suvdata[ssend_vertices + 0].x = (texpos.x) << 3; suvdata[ssend_vertices + 0].y = (texpos.y) << 3; suvdata[ssend_vertices + 1].x = (texpos.x) << 3; suvdata[ssend_vertices + 1].y = (texpos.y + 32) << 3; suvdata[ssend_vertices + 2].x = (texpos.x + 32) << 3; suvdata[ssend_vertices + 2].y = (texpos.y + 32) << 3; suvdata[ssend_vertices + 3].x = (texpos.x + 32) << 3; suvdata[ssend_vertices + 3].y = (texpos.y) << 3; // scolors[ssend_vertices + 0].Set(0xFF, 0xFF, 0xFF, (uint8)(alphaf)); scolors[ssend_vertices + 1].Set(0xFF, 0xFF, 0xFF, (uint8)(alphaf)); scolors[ssend_vertices + 2].Set(0xFF, 0xFF, 0xFF, (uint8)(alphaf)); scolors[ssend_vertices + 3].Set(0xFF, 0xFF, 0xFF, (uint8)(alphaf)); // for (i = 0; i < 4; i++) svertices[ssend_vertices + i] = transformMatrix.TransformVec(svertices[ssend_vertices + i]); ssend_vertices += 4; // }
void TileSet::Render(int index,CIwSVec2 topLeft,int rotation) { int ind=index-m_firstGid; if(ind<0) return; int index_X=ind%_tilesPerRow; int index_Y=ind/_tilesPerRow; CIwSVec2 pos = CIwSVec2(index_X * _tilewidth,index_Y * _tileheight); if(rotation!=0) { iwangle angle =90*rotation;//90 degrees CIwSVec2 centre=CIwSVec2(iwsfixed(topLeft.x+(float)_tilewidth/2.0f),iwsfixed(topLeft.y+(float)_tileheight/2.0f)); CIwMat2D rot; rot.SetRot(IW_ANGLE_FROM_DEGREES(angle), CIwVec2(centre)); Iw2DSetTransformMatrix(rot); } Iw2DDrawImageRegion(_image, topLeft, pos, _tileSize); Iw2DSetTransformMatrix(CIwMat2D::g_Identity); }
//----------------------------------------------------------------------------- void ExampleRender() { static const CIwSVec2 imageSize(g_Image->GetWidth() >> 3, g_Image->GetHeight() >> 3); static const CIwSVec2 halfImageSize = imageSize >> 1; const CIwSVec2 screenCentre = CIwSVec2((int16)Iw2DGetSurfaceWidth() >> 1, (int16)Iw2DGetSurfaceHeight() >> 1); const b2Transform t = g_body->GetTransform(); const CIwSVec2 pos = screenCentre + (CIwSVec2(int16(t.p.x*8), -int16(t.p.y*8))); const float angle = -t.q.GetAngle() * (180.0f/3.14159f); // reverse angle as our screen-Y coord is reversed CIwMat2D rot; rot.SetRot(iwangle(angle * 1024 / 90), CIwVec2(pos) << 3); Iw2DSetTransformMatrixSubPixel(rot); Iw2DDrawImage(g_Image, pos - halfImageSize, imageSize); // Iw2DSetTransformMatrix(CIwMat2D::g_Identity); Iw2DSurfaceShow(); }