void AnimationViewerPanel::renderCenterPointSprite(const GLSprite* pGlSprite, const QPoint& centerPoint, QPainter& painter) { if (pGlSprite->mSpriteDescriptor.isImage()) { // render center point GLSprite* centerPointSprite = AnimationModel::getCenterPointSprite(); QPointF offset = QPointF( (pGlSprite->mSpriteDescriptor.mPosition.mX + pGlSprite->mSpriteDescriptor.center().x()), (pGlSprite->mSpriteDescriptor.mPosition.mY + pGlSprite->mSpriteDescriptor.center().y()) ); QPoint centerPointCenterPoint = centerPoint + offset.toPoint(); painter.translate(centerPointCenterPoint.x(), centerPointCenterPoint.y()); centerPointSprite->render(QPoint(0, 0), painter, AnimationModel::getTargetSprite(), false, mEmittedAnimationList); painter.translate(-centerPointCenterPoint.x(), -centerPointCenterPoint.y()); } }
void AnimationViewerPanel::renderCelSprites(const QPoint& centerPoint, QPainter& painter) { KeyFrame::KeyFramePosition currentPosition = mpAnimationModel->getCurrentKeyFramePosition(); if (mIsAnimationPlaying) { mpAnimationModel->executeCommand(currentPosition.mFrameNo); } QList<const GLSprite*>::Iterator iter = mRenderSpriteList.begin(); while (iter != mRenderSpriteList.end()) { GLSprite* glSprite = (GLSprite*)*iter; if (glSprite->mLineNo == AnimationModel::LINE_target) { if (!mShowTarget) { iter++; continue; } GLSprite::Point2 position; position.mX = glSprite->mSpriteDescriptor.mPosition.mX + AnimationModel::TARGET_originX; position.mY = glSprite->mSpriteDescriptor.mPosition.mY + AnimationModel::TARGET_originY; glSprite->mSpriteDescriptor.mPosition = position; } if (!mShowCamera && glSprite->mLineNo == AnimationModel::LINE_camera) { iter++; continue; } // render sprite // Move rendering position depends on targeting position option int dx = 0; int dy = 0; // if (glSprite->mLineNo == AnimationModel::LINE_target) // { // dx = glSprite->mSpriteDescriptor.mTextureSrcRect.width() / 2; // dy = glSprite->mSpriteDescriptor.mTextureSrcRect.height() / 2; // } painter.translate(centerPoint.x() + dx, centerPoint.y() + dy); if (glSprite) { glSprite->render(QPoint(0, 0), painter,AnimationModel::getTargetSprite(), mIsAnimationPlaying, mEmittedAnimationList); } painter.translate(-centerPoint.x() - dx, -centerPoint.y() - dy); if (glSprite && !mIsAnimationPlaying && mShowAnimationUI) { renderCelBox(painter, glSprite, centerPoint - glSprite->mSpriteDescriptor.center()); } iter++; } if (mIsAnimationPlaying) { // update emitted animations for (int lineNo = 0; lineNo < AnimationModel::LINE_COUNT; lineNo++) { for (int i = mEmittedAnimationList[lineNo].count() - 1; i >= 0; i--) { mEmittedAnimationList[lineNo][i]->update(); if (mEmittedAnimationList[lineNo][i]->isDone()) { mEmittedAnimationList[lineNo].removeAt(i); } } } } }