Im Moment wird immer um "core::position2d<s32> center" gedreht, dieser Punkt ist gleichzeitig auch die Mitte der Bildes.
Du musst jetzt sowas hinzufügen:
Am Anfang wird zB eine Variable "core::position2d<s32> rotationoffset" übergeben, diese definiert später die Position auf dem Bild, um die gedreht wird.
Dieser Code gibt den Punkt an, um den gedreht wird:
Code:
float centerx = (-(ScreenWidth/2) + center.X) * 2;
float centery = -(-(ScreenHeight/2) + center.Y) * 2;
So musst du den um den Offset verschieben:
Code:
float centerx = (-(ScreenWidth/2) + center.X + rotationoffset.X) * 2;
float centery = -(-(ScreenHeight/2) + center.Y + rotationoffset.Y) * 2;
Dieser Code gibt aktuell an, wie breit das Bild rechts/links von Punkt center ist:
Code:
float halfdimx = float(dimension.Width);
float halfdimy = float(dimension.Height);
Den musst du dann so abändern:
Code:
float widthleft = float(dimension.Width) - rotationoffset.X * 2;
float widthright = float(dimension.Width) + rotationoffset.X * 2;
float heighttop = float(dimension.Height) - rotationoffset.Y * 2;
float heightbottom = float(dimension.Height) + rotationoffset.Y * 2;
Dadurch erreichst du, dass die Punkte des Vierecks unterschiedlich weit von der Mitte entfernt sind.
Diese Werte musst du jetzt in die Dreiecke einfügen:
Code:
vertices[0] = video::S3DVertex((centerx - cos(rotation / 180 * M_PI) * widthleft + sin(rotation / 180 * M_PI) * heighttop) / (ScreenWidth),
(centery + sin(rotation / 180 * M_PI) * widthleft + cos(rotation / 180 * M_PI) * heighttop) / (ScreenHeight), 0, 0, 0, 0, video::SColor(255, 255, 255, 255), left, top);
vertices[1] = video::S3DVertex((centerx + cos(rotation / 180 * M_PI) * widthright + sin(rotation / 180 * M_PI) * heighttop) / (ScreenWidth),
(centery - sin(rotation / 180 * M_PI) * widthright + cos(rotation / 180 * M_PI) * heighttop / (ScreenHeight), 0, 0, 0, 0, video::SColor(255, 255, 255, 255), (left+1)%2, top);
vertices[2] = video::S3DVertex((centerx + cos(rotation / 180 * M_PI) * widthright - sin(rotation / 180 * M_PI) * heightbottom) / (ScreenWidth),
(centery - sin(rotation / 180 * M_PI) * widthright - cos(rotation / 180 * M_PI) * heightbottom) / (ScreenHeight), 0, 0, 0, 0, video::SColor(255, 255, 255, 255), (left+1)%2, (top+1)%2);
vertices[3] = video::S3DVertex((centerx - cos(rotation / 180 * M_PI) * widthleft - sin(rotation / 180 * M_PI) * heightbottom) / (ScreenWidth),
(centery + sin(rotation / 180 * M_PI) * widthleft - cos(rotation / 180 * M_PI) * heightbottom) / (ScreenHeight), 0, 0, 0, 0, video::SColor(255, 255, 255, 255), left, (top+1)%2);
Habe den Code jetzt nicht irgendwie ausgetestet, das Konzept sollte aber so stimmen.
Bei Fragen Problemem bin ich auch unter ICQ (306214707) erreichbar...