Hab meinen Code doch wieder gefunden.
Sollte so funktionieren:
Code:
void draw2DImage(video::ITexture *image, core::position2d<s32> center, core::dimension2d<s32> dimension, float rotation = 0, bool alphachannel = true, bool addcolor = false, bool mirrorx = false, bool mirrory = false)
{
video::SMaterial tmpmat;
tmpmat.Lighting = false;
tmpmat.BackfaceCulling = false;
tmpmat.ZBuffer = false;
tmpmat.ZWriteEnable = false;
tmpmat.Texture1 = image;
if (alphachannel)
tmpmat.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
if (addcolor)
tmpmat.MaterialType = video::EMT_TRANSPARENT_ADD_COLOR;
driver->setMaterial(tmpmat);
float centerx = (-(ScreenWidth/2) + center.X) * 2;
float centery = -(-(ScreenHeight/2) + center.Y) * 2;
float halfdimx = float(dimension.Width);
float halfdimy = float(dimension.Height);
int left = (!mirrorx)?(0) : (1);
int top = (!mirrory)?(0) : (1);
video::S3DVertex vertices[4];
vertices[0] = video::S3DVertex((centerx - cos(rotation / 180 * M_PI) * halfdimx + sin(rotation / 180 * M_PI) * halfdimy) / (ScreenWidth),
(centery + sin(rotation / 180 * M_PI) * halfdimx + cos(rotation / 180 * M_PI) * halfdimy) / (ScreenHeight), 0, 0, 0, 0, video::SColor(255, 255, 255, 255), left, top);
vertices[1] = video::S3DVertex((centerx + cos(rotation / 180 * M_PI) * halfdimx + sin(rotation / 180 * M_PI) * halfdimy) / (ScreenWidth),
(centery - sin(rotation / 180 * M_PI) * halfdimx + cos(rotation / 180 * M_PI) * halfdimy) / (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) * halfdimx - sin(rotation / 180 * M_PI) * halfdimy) / (ScreenWidth),
(centery - sin(rotation / 180 * M_PI) * halfdimx - cos(rotation / 180 * M_PI) * halfdimy) / (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) * halfdimx - sin(rotation / 180 * M_PI) * halfdimy) / (ScreenWidth),
(centery + sin(rotation / 180 * M_PI) * halfdimx - cos(rotation / 180 * M_PI) * halfdimy) / (ScreenHeight), 0, 0, 0, 0, video::SColor(255, 255, 255, 255), left, (top+1)%2);
u16 indices[6] = {0, 1, 3, 1, 2, 3};
driver->drawIndexedTriangleList(vertices, 4, indices, 2);
}
EDIT:
Ja, ich weiß, schlimmer Stil und nicht kommentiert... aber auch schon älter... ^^
EDIT2: 2 Smilies im Code entfernt... phpBB nervt... ^^