void GraphicsObjectManager::privDrawObjectsDepthFirst( GraphicsObject *node ) const { GraphicsObject *child = 0; // --------- Do draw stuff here ----------------------- // node->print(); node->transform(); node->setRenderState(); node->draw(); // --------- Do draw stuff here ----------------------- // iterate through all of the active children if (node->getChild() != 0) { child = (GraphicsObject *)node->getChild(); // make sure that allocation is not a child node while (child != 0) { privDrawObjectsDepthFirst( child ); // goto next sibling child = (GraphicsObject *)child->getSibling(); } } else { // bye bye exit condition } }
void Skeleton::updateSkeleton(GraphicsObject *node, FrameBucket* pResult) { // --------- Do pose stuff here ----------------------- this->setBonePose(node, pResult); // iterate through all of the active children - copied from GOM, will it work here??? GraphicsObject *child = 0; if (node->getChild() != 0) { child = (GraphicsObject *)node->getChild(); // make sure that allocation is not a child node while (child != 0) { updateSkeleton( child, pResult ); // goto next sibling - node's child, but now we are iterating SIBLINGS child = (GraphicsObject *)child->getSibling(); } } else { // bye bye exit condition } }
GraphicsObject::GraphicsObject(const GraphicsObject &other) : QGraphicsPixmapItem() { m_type = other.m_type; setFlags(other.flags()); setPos(other.pos()); setRotation(other.rotation()); setToolTip(""); }
void ColourFilterObjectData::render(const GraphicsObject& go, const GraphicsObject* parent, std::ostream* tree) { if (go.width() != 100 || go.height() != 100) { static bool printed = false; if (!printed) { printed = true; cerr << "We can't yet scaling colour filters." << endl; } } // Lazily create colour object. if (!colour_filer_) { colour_filer_.reset(graphics_system_.BuildColourFiller(screen_rect_)); } RGBAColour colour = go.colour(); colour.setAlpha( static_cast<int>(colour.a_float() * go.computedAlpha())); colour_filer_->Fill(go, colour); if (tree) { *tree << " ColourFilterObjectData" << std::endl << " Screen rect: " << screen_rect_ << std::endl << " Colour: " << colour << std::endl << " Properties: "; PrintGraphicsObjectToTree(go, tree); *tree << endl; } }
void GraphicsObjectManager::privDrawObjectsTreeDepthFirst( PCSNode *node ) const { PCSNode *child = 0; GraphicsObject *go = (GraphicsObject *)node; // Transform and draw graphics object go->transform(); go->setRenderState(); go->draw(); // iterate through all of the active children if (node->getChild() != 0) { child = node->getChild(); // make sure that allocation is not a child node while (child != 0) { privDrawObjectsTreeDepthFirst( child ); // goto next sibling child = child->getSibling(); } } else { // bye bye exit condition } }
//--------------------------------------------------------------------------------- // Name: updateGui() //--------------------------------------------------------------------------------- void GameplayState::updateGui() { unsigned data[4] = {0}; data[0] = BATTLE_CITY->getEnemiesLeft(); data[1] = BATTLE_CITY->getPlayerLivesNum( PLAYER_ONE_TANK ); data[2] = BATTLE_CITY->getPlayerLivesNum( PLAYER_TWO_TANK ); data[3] = BATTLE_CITY->getCurrMapNumber(); if ( (data[0] ^ m_tdata[0]) | (data[1] ^ m_tdata[1]) | (data[2] ^ m_tdata[2] ) ) { char buff[100] = {0}; sprintf( buff, "T : %.2d | 1P : %.2d | 2P : %.2d | M : %.2d", data[0], data[1], data[2], data[3] ); if ( BATTLE_CITY->getGameMode() == _1PLAYER_MODE ) memset( buff + 19, ' ', sizeof(char) << 3 ); int buff_w, buff_h; RENDER_MGR->getFontManager()->getStringSize(buff, &buff_w, &buff_h, m_font_id ); if ( !m_data_gui_go.expired() ) { GraphicsObject * obj = m_data_gui_go._Get(); obj->setTemporary(true); } m_data_gui_go = GUI_TEXT( buff, ( BASE_SCREEN_WIDTH - buff_w ) >> 1, buff_h, CYAN_COLOR ); memcpy( m_tdata, data, sizeof(unsigned) << 2 ); }
int GraphicsObjectData::getRenderingAlpha(const GraphicsObject& go, const GraphicsObject* parent) { if (!parent) { return go.computedAlpha(); } else { return int((parent->computedAlpha() / 255.0f) * (go.computedAlpha() / 255.0f) * 255); } }
void ensureIsParentObject(GraphicsObject& parent, int size) { if (parent.hasObjectData()) { if (parent.objectData().isParentLayer()) { return; } } parent.setObjectData(new ParentGraphicsObjectData(size)); }
Point GraphicsObjectData::dstOrigin(const GraphicsObject& go) { if (go.xOrigin() || go.yOrigin()) { return Point(go.xOrigin(), go.yOrigin()); } boost::shared_ptr<const Surface> surface = currentSurface(go); if (surface) { return Point(surface->getPattern(go.pattNo()).originX, surface->getPattern(go.pattNo()).originY); } return Point(); }
void GraphicsObjectManager::drawObjectsList() { // Walk the graphics object list std::list<GraphicsObject *>::iterator it; for ( it=goList.begin(); it != goList.end(); it++ ) { // local pointer GraphicsObject *go = *it; // Transform and draw graphics object go->transform(); go->setRenderState(); go->draw(); } }
void ColourFilterObjectData::render(const GraphicsObject& go, const GraphicsObject* parent, std::ostream* tree) { if (go.mono() == 0) { RGBAColour colour = go.colour(); colour.setAlpha( static_cast<int>(colour.a_float() * go.computedAlpha())); graphics_system_.fillScreenArea(screen_rect_, colour); if (tree) objectInfo(*tree); } else { static bool printed = false; if (!printed) { printed = true; cerr << "We don't yet deal with objMono() and colour filters." << endl; } } }
Rect GraphicsObjectData::dstRect(const GraphicsObject& go, const GraphicsObject* parent) { Point origin = dstOrigin(go); Rect src = srcRect(go); int center_x = go.x() + go.xAdjustmentSum() - origin.x() + (src.width() / 2.0f); int center_y = go.y() + go.yAdjustmentSum() - origin.y() + (src.height() / 2.0f); float second_factor_x = 1.0f; float second_factor_y = 1.0f; if (parent) { center_x += parent->x() + parent->xAdjustmentSum(); center_y += parent->y() + parent->yAdjustmentSum(); second_factor_x = parent->getWidthScaleFactor(); second_factor_y = parent->getHeightScaleFactor(); } int half_real_width = (src.width() * second_factor_x * go.getWidthScaleFactor()) / 2.0f; int half_real_height = (src.height() * second_factor_y * go.getHeightScaleFactor()) / 2.0f; int xPos1 = center_x - half_real_width; int yPos1 = center_y - half_real_height; int xPos2 = center_x + half_real_width; int yPos2 = center_y + half_real_height; return Rect::GRP(xPos1, yPos1, xPos2, yPos2); }
void GraphicsScene::ProcessRange( u32 begin, u32 end ) { static const u32 nonPausable = GraphicsObject::Type_Camera | GraphicsObject::Type_Window | GraphicsObject::Type_StatWindow | GraphicsObject::Type_Chart | GraphicsObject::Type_CPUChart | GraphicsObject::Type_WorkloadWindow; for ( size_t i = begin; i < end; ++i ) { GraphicsObject* pObject = m_Objects[i]; // Update objects based on paused state if ( !m_bPause || pObject->GetType() & nonPausable ) { // Process this object pObject->Update( m_fDeltaTime ); } } }
Rect GraphicsObjectData::dstRect(const GraphicsObject& go) { Point origin = dstOrigin(go); Rect src = srcRect(go); int xPos1 = go.x() + go.xAdjustmentSum() - origin.x(); int yPos1 = go.y() + go.yAdjustmentSum() - origin.y(); int xPos2 = int(xPos1 + src.width() * (go.width() / 100.0f)); int yPos2 = int(yPos1 + src.height() * (go.height() / 100.0f)); return Rect::GRP(xPos1, yPos1, xPos2, yPos2); }
void GraphicsObjectData::render(const GraphicsObject& go, std::ostream* tree) { boost::shared_ptr<const Surface> surface = currentSurface(go); if (surface) { Rect src = srcRect(go); Rect dst = dstRect(go); int alpha = getRenderingAlpha(go); // TODO: Anyone attempting moving the clip area calculations here should // verify that it doesn't break the final pan scene of Yumemi in // Planetarian. if (tree) { objectInfo(*tree); *tree << " Rendering " << src << " to " << dst; if (alpha != 255) *tree << " (alpha=" << alpha << ")"; if (go.hasClip()) *tree << " [Warning: Clip rectangle calculations not applied.]"; *tree << endl; } surface->renderToScreenAsObject(go, src, dst, alpha); } }
void GraphicsObjectData::render(const GraphicsObject& go, const GraphicsObject* parent, std::ostream* tree) { boost::shared_ptr<const Surface> surface = currentSurface(go); if (surface) { Rect src = srcRect(go); Rect dst = dstRect(go, parent); int alpha = getRenderingAlpha(go, parent); if (go.buttonUsingOverides()) { // Tacked on side channel that lets a ButtonObjectSelectLongOperation // tweak the x/y coordinates of dst. There isn't really a better place to // put this. It can't go in dstRect() because the LongOperation also // consults the data from dstRect(). dst = Rect(dst.origin() + Size(go.buttonXOffsetOverride(), go.buttonYOffsetOverride()), dst.size()); } if (tree) { objectInfo(*tree); *tree << " Rendering " << src << " to " << dst << endl; if (parent) { *tree << " Parent: "; PrintGraphicsObjectToTree(*parent, tree); *tree << endl; } *tree << " Properties: "; if (alpha != 255) *tree << "(alpha=" << alpha << ") "; PrintGraphicsObjectToTree(go, tree); *tree << endl; } if (parent && parent->hasOwnClip()) { // In Little Busters, a parent clip rect is used to clip text scrolling // in the battle system. rlvm has the concept of parent objects badly // hacked in, and that means we can't directly apply the own clip // rect. Instead we have to calculate this in terms of the screen // coordinates and then apply that as a global clip rect. Point parent_start(parent->x() + parent->xAdjustmentSum(), parent->y() + parent->yAdjustmentSum()); Rect full_parent_clip = Rect(parent_start + parent->ownClipRect().origin(), parent->ownClipRect().size()); Rect clipped_dest = dst.intersection(full_parent_clip); Rect inset = dst.getInsetRectangle(clipped_dest); dst = clipped_dest; src = src.applyInset(inset); if (tree) { *tree << " Parent Own Clipping Rect: " << parent->ownClipRect() << endl << " After clipping: " << src << " to " << dst << endl; } } if (go.hasOwnClip()) { dst = dst.applyInset(go.ownClipRect()); src = src.applyInset(go.ownClipRect()); if (tree) { *tree << " Internal Clipping Rect: " << go.ownClipRect() << endl << " After internal clipping: " << src << " to " << dst << endl; } } // Perform the object clipping. if (go.hasClip()) { Rect clipped_dest = dst.intersection(go.clipRect()); // Do nothing if object falls wholly outside clip area if (clipped_dest.isEmpty()) return; // Adjust the source rectangle Rect inset = dst.getInsetRectangle(clipped_dest); dst = clipped_dest; src = src.applyInset(inset); if (tree) { *tree << " Clipping Rect: " << go.clipRect() << endl << " After clipping: " << src << " to " << dst << endl; } } // TODO: Do we want to skip this if no alpha? surface->renderToScreenAsObject(go, src, dst, alpha); } }
// I am not entirely sure these methods even make sense given the // context... int AnmGraphicsObjectData::pixelWidth(const GraphicsObject& rp) { const Surface::GrpRect& rect = image_->getPattern(rp.pattNo()); int width = rect.rect.width(); return int(rp.getWidthScaleFactor() * width); }
Rect GraphicsObjectData::srcRect(const GraphicsObject& go) { return currentSurface(go)->getPattern(go.pattNo()).rect; }
int AnmGraphicsObjectData::pixelHeight(const GraphicsObject& rp) { const Surface::GrpRect& rect = image_->getPattern(rp.pattNo()); int height = rect.rect.height(); return int(rp.getHeightScaleFactor() * height); }
void GraphicsObjectData::PrintGraphicsObjectToTree(const GraphicsObject& go, std::ostream* tree) { if (go.mono()) *tree << "(mono) "; if (go.invert()) *tree << "(invert) "; if (go.light()) *tree << "(light=" << go.light() << ") "; if (go.tint() != RGBColour::Black()) *tree << "(tint=" << go.tint() << ") "; if (go.colour() != RGBAColour::Clear()) *tree << "(colour=" << go.colour() << ") "; if (go.compositeMode()) *tree << "(composite=" << go.compositeMode() << ") "; if (go.xOrigin()) *tree << "(xOrigin=" << go.xOrigin() << ") "; if (go.yOrigin()) *tree << "(yOrigin=" << go.yOrigin() << ") "; }
int GraphicsObjectData::getRenderingAlpha(const GraphicsObject& go) { return go.alpha(); }
bool GraphicsObject::hasCollision(const GraphicsObject &other) { return SDL_HasIntersection(m_dst.get(), other.getDst().get()); }
int GraphicsObjectOfFile::pixelWidth(const GraphicsObject& rp) { const Surface::GrpRect& rect = surface_->getPattern(rp.pattNo()); int width = rect.rect.width(); return int((rp.width() / 100.0f) * width); }
int GraphicsObjectOfFile::pixelHeight(const GraphicsObject& rp) { const Surface::GrpRect& rect = surface_->getPattern(rp.pattNo()); int height = rect.rect.height(); return int((rp.height() / 100.0f) * height); }