Ejemplo n.º 1
0
	void ProgressBarWidget::render() {

		double progress = 0.0;
		if (currentStep >= 0 && currentStep < totalSteps)
			progress = (double) currentStep / (double) totalSteps;
		else
			progress = 1.0;

		WidgetPoint corner = getBoundingRect().getCorner();
		WidgetPoint dimensions = getBoundingRect().getDimensions();
		double right = corner.getX() + progress * dimensions.getX();
		double done_right = corner.getX() + dimensions.getX();
		double bottom = corner.getY()+dimensions.getY();

		OpenGL::Color::glColor(OpenGL::Color::GREY);
		glBegin(GL_QUADS);
		WidgetRenderer::glVertex(corner);
		WidgetRenderer::glVertex(WidgetPoint(done_right, corner.getY()));
		WidgetRenderer::glVertex(WidgetPoint(done_right, bottom));
		WidgetRenderer::glVertex(WidgetPoint(corner.getX(), bottom));
		glEnd();

		OpenGL::Color::glColor(OpenGL::Color::WHITE);
		glBegin(GL_QUADS);
		WidgetRenderer::glVertex(corner);
		WidgetRenderer::glVertex(WidgetPoint(right, corner.getY()));
		WidgetRenderer::glVertex(WidgetPoint(right, bottom));
		WidgetRenderer::glVertex(WidgetPoint(corner.getX(), bottom));
		glEnd();
	}
Ejemplo n.º 2
0
void TextWidget::render() {
    double ratioNow = SDL::Projector::getInstance()->getAspectRatio();
    if(lastRenderedRatio != ratioNow) {
        lastRenderedRatio = ratioNow;
        dirty = true;
    }
    
    if(dirty) {
        preRender();
    }
    
	if(data.empty() || !stringTexture.hasTexture()) {
        return;  // empty text, or error in pre-rendering
    }
    
    WidgetPoint corner = getBoundingRect().getCorner();
    WidgetPoint dimensions = getBoundingRect().getDimensions();
    
    glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, stringTexture.getTextureID());
    glColor3f(1.0f, 1.0f, 1.0f);
    
    // comment this out to disable font transparency
    glEnable(GL_BLEND);
    
    glBlendFunc(GL_ONE, GL_ONE);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    
    glBegin(GL_QUADS);
    
    double width = dimensions.getX() * widthFactor;
    double height = dimensions.getY() * heightFactor;
    
    // scale dimensions to take the larger power-of-2 texture into account
    // this way it looks the same no matter how big the texture actually is
    WidgetPoint topLeft = corner;
    WidgetPoint lowerLeft = corner;
    WidgetPoint topRight = corner;
    WidgetPoint lowerRight = corner;
    lowerLeft.addY(height);
    lowerRight.addY(height);
    topRight.addX(width);
    lowerRight.addX(width);
    
    glTexCoord2i(0, 0); WidgetRenderer::glVertex(topLeft);
    glTexCoord2i(1, 0); WidgetRenderer::glVertex(topRight);
    glTexCoord2i(1, 1); WidgetRenderer::glVertex(lowerRight);
    glTexCoord2i(0, 1); WidgetRenderer::glVertex(lowerLeft);
    
    glEnd();
    
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_BLEND);
}
Ejemplo n.º 3
0
void PSV_ChartItem::createUpAxisi(const PSV_AxisItemParam &axisParam)
{
    QMap<int, QVariant> param;
    QRectF m_rect = getBoundingRect();
    QRectF boundingRect = QRectF(m_chartRect.x(),m_rect.top()
                                 ,m_chartRect.width(),m_margin_total_up);
    param.insert(PSV::boundingRect,boundingRect);
    QFont markFont;
    markFont.setPointSizeF(PSV_Public::getMinLenght(m_rect) * axisParam.m_fontRatio * 0.03);
    param.insert(PSV::markFont,markFont);

    param.insert(PSV::hasArrow,axisParam.m_hasArrow);
    param.insert(PSV::maxValue,m_max_x);
    param.insert(PSV::minValue,m_min_x);
    if(axisParam.m_list.count() > 0)
    {
        m_upAxisItem = new PSV_AxisUpItem(param,axisParam.m_list,this);
        param.insert(PSV::isCenter,axisParam.m_isCenter);
    }
    else
    {
        m_upAxisItem = new PSV_AxisUpItem(param,this);
    }
    m_upAxisItem->getRange(m_max_x,m_min_x,m_rangeX);
}
Ejemplo n.º 4
0
Polygon PolygonInterface::boundingRect(void) const
{
    double minX, minY, maxX, maxY;
    getBoundingRect(&minX, &minY, &maxX, &maxY);
    
    return Rectangle(Point(minX, minY), Point(maxX, maxY));
}
Ejemplo n.º 5
0
void toprsGadlReader::getMaxSize( int resLevel,int& maxX, int& maxY ) const
{
	int aGdalBandIndex = 0;
	maxX = 0;
	maxY = 0;

	//if(theOverview.valid() && theOverview->isValidRLevel(resLevel))// xizhi
	{
		//toprsIRect rect = theOverview->getBoundingRect(resLevel);//xizhi
		toprsIRect rect = getBoundingRect(resLevel);
		if(!rect.hasNAN())
		{
			maxX = rect.width();
			maxY = rect.height();
		}
		return;
	}

	for(aGdalBandIndex=1;
		(int)aGdalBandIndex <= (int)GDALGetRasterCount(theDataset);
		++aGdalBandIndex)
	{
		GDALRasterBandH aBand = resolveRasterBand(resLevel, aGdalBandIndex);
		if(aBand)
		{
			maxY = toprs::max<int>((int)GDALGetRasterBandYSize(aBand), maxY);
			maxX = toprs::max<int>((int)GDALGetRasterBandXSize(aBand), maxX);
		}
		else
		{
			break;
		}
	}
}
Ejemplo n.º 6
0
void GameOverPanel::render(Scene& parent)
{
	SDL_Window * win = parent.app().getWindow();
	int width, height;
	SDL_GetWindowSize(win, &width, &height);

	Rect rect = getBoundingRect(win);
	
	glPushAttrib(GL_ENABLE_BIT);
	{
		glMatrixMode(GL_PROJECTION);
		glDisable(GL_LIGHTING);
		glPushMatrix();
		{
			glLoadIdentity();
			glOrtho(0, width, 0, height, -1, 1);
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			{
				glLoadIdentity();
				glBindTexture(texture);
				
				float alpha = 0;
				float translateY = 0;
				if(animTime > coolDownTime)
				{
					float diff = (animTime - coolDownTime) / (animTotalTime - coolDownTime);
					if(diff > 1)
						diff = 1;
					alpha = diff;
					translateY = translationYLength * (1 - diff) * (1 - diff);
				}
				glTranslate(Vector3::down * translateY);
				glColor(Vector3::one, alpha); 
				glBegin(GL_QUADS);
				{
					glTexCoord2f(0, 0);
					glVertex2f(rect.left(), height - rect.top());
					glTexCoord2f(0, 1);
					glVertex2f(rect.left(), height - rect.bottom());
					glTexCoord2f(1, 1);
					glVertex2f(rect.right(), height - rect.bottom());
					glTexCoord2f(1, 0);
					glVertex2f(rect.right(), height - rect.top());
				}
				glEnd();
			}
			glPopMatrix();
		}
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
	}
	glPopAttrib();

	if(animTime < animTotalTime)
	{
		animTime += parent.app().getFrameTime();
	}
}
Ejemplo n.º 7
0
void PageItem_NoteFrame::layout()
{
	if (!invalid || l_notes.isEmpty())
		return;
	if (!m_Doc->flag_layoutNotesFrames)
		return;
	if (itemText.length() == 0)
		return;
	if ((masterFrame() != NULL) && masterFrame()->invalid)
		return;

	//while layouting notes frames undo should be disabled
	UndoManager::instance()->setUndoEnabled(false);

	if (m_nstyle->isAutoNotesWidth() && (m_width != m_masterFrame->width()))
	{
		oldWidth = m_width = m_masterFrame->width();
		updateClip();
	}

	if ((m_Doc->appMode == modeEdit) && isSelected())
		updateNotesText();

	PageItem_TextFrame::layout();
	int oldH = m_height;
	if (notesStyle()->isAutoNotesHeight())
	{
		if (frameOverflows())
		{
			//increase height while text don`t fit in frame
			double maxH = m_Doc->currentPage()->height() - m_xPos;
			while (frameOverflows())
			{
				oldHeight = m_height += 8;
				updateClip(false);
				invalid = true;
				PageItem_TextFrame::layout();
				if (m_height >= maxH)
					break;
			}
		}
		double hackValue = 0.5;
		oldHeight = m_height = ceil(maxY) + m_textDistanceMargins.bottom() + hackValue;
		updateConstants();
		updateClip();
		invalid = true;
		PageItem_TextFrame::layout();
	}
	if (oldH != height())
	{
		if (masterFrame() != NULL)
		{
			foreach(PageItem_NoteFrame* nF, masterFrame()->notesFramesList())
				nF->invalid = true;
		}
	}
	invalid = false;
	m_Doc->regionsChanged()->update(getBoundingRect());
	UndoManager::instance()->setUndoEnabled(true);
}
Ejemplo n.º 8
0
//*****************************************************************************
//  METHOD: ossimImageSource::getValidImageVertices()
//*****************************************************************************
void ossimImageSource::getValidImageVertices(std::vector<ossimIpt>& validVertices,
                                             ossimVertexOrdering ordering,
                                             ossim_uint32 resLevel)const
{
  ossimImageSource* inter = PTR_CAST(ossimImageSource,
					      getInput(0));
  if(inter)
    {
      return inter->getValidImageVertices(validVertices,
					  ordering,
                                          resLevel);
    }
   ossimIrect boundingRect = getBoundingRect(resLevel);
   validVertices.clear();
   
   if(ordering == OSSIM_CLOCKWISE_ORDER)
   {
      validVertices.push_back(boundingRect.ul());
      validVertices.push_back(boundingRect.ur());
      validVertices.push_back(boundingRect.lr());
      validVertices.push_back(boundingRect.ll());
   }
   else
   {
      validVertices.push_back(boundingRect.ul());
      validVertices.push_back(boundingRect.ll());
      validVertices.push_back(boundingRect.lr());
      validVertices.push_back(boundingRect.ur());
   }
}
Ejemplo n.º 9
0
void rspfPixelFlipper::initialize()
{
	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
   rspfImageSourceFilter::initialize();
   theValidVertices.clear();
   theBoundingRects.clear();

   rspf_uint32 rlevels = getNumberOfDecimationLevels();
   rspf_uint32 idx = 0;

   if(rlevels)
   {
      if(theValidVertices.size() != rlevels)
      {
         theValidVertices.resize(rlevels);
      }
      if(theBoundingRects.size() != rlevels)
      {
         theBoundingRects.resize(rlevels);
      }
      for(idx = 0; idx < rlevels; ++idx)
      {
         std::vector<rspfIpt> validVertices;
         getValidImageVertices(validVertices,
                               RSPF_CLOCKWISE_ORDER,
                               idx);
         theValidVertices[idx] = rspfPolygon(validVertices);
         theBoundingRects[idx] = getBoundingRect(idx);
      }
   }
}
Ejemplo n.º 10
0
//*****************************************************************************
//  METHOD: rspfImageSource::getValidImageVertices()
//*****************************************************************************
void rspfImageSource::getValidImageVertices(std::vector<rspfIpt>& validVertices,
        rspfVertexOrdering ordering,
        rspf_uint32 resLevel)const
{
    rspfImageSource* inter = PTR_CAST(rspfImageSource,
                                      getInput(0));
    if(inter)
    {
        return inter->getValidImageVertices(validVertices,
                                            ordering,
                                            resLevel);
    }
    rspfIrect boundingRect = getBoundingRect(resLevel);
    validVertices.clear();

    if(ordering == RSPF_CLOCKWISE_ORDER)
    {
        validVertices.push_back(boundingRect.ul());
        validVertices.push_back(boundingRect.ur());
        validVertices.push_back(boundingRect.lr());
        validVertices.push_back(boundingRect.ll());
    }
    else
    {
        validVertices.push_back(boundingRect.ul());
        validVertices.push_back(boundingRect.ll());
        validVertices.push_back(boundingRect.lr());
        validVertices.push_back(boundingRect.ur());
    }
}
Ejemplo n.º 11
0
void PSV_ChartItem::createRightAxisi(const PSV_AxisItemParam &axisParam)
{
    QMap<int, QVariant> param;
    QRectF m_rect = getBoundingRect();
    QRectF boundingRect = QRectF(m_chartRect.right(), m_chartRect.top()
                                 ,m_margin_total_right, m_chartRect.height());
    param.insert(PSV::boundingRect,boundingRect);
    QFont markFont;
    markFont.setPointSizeF(PSV_Public::getMinLenght(m_rect) * axisParam.m_fontRatio * 0.03);
    param.insert(PSV::markFont,markFont);


    param.insert(PSV::hasArrow,axisParam.m_hasArrow);
    param.insert(PSV::maxValue,m_max_y_right);
    param.insert(PSV::minValue,m_min_y_right);
    if(axisParam.m_list.count() > 0)
    {
        m_rightAxisItem = new PSV_AxisRightItem(param,axisParam.m_list,this);
        param.insert(PSV::isCenter,axisParam.m_isCenter);
    }
    else
    {
        m_rightAxisItem = new PSV_AxisRightItem(param,this);
    }

    QVariant max;
    QVariant min;
    m_rightAxisItem->getRange(max,min);
    m_max_y_right = max.toDouble();
    m_min_y_right = min.toDouble();
}
Ejemplo n.º 12
0
void PSV_ChartItem::updateChartRect()
{
    QRectF m_rect = getBoundingRect();
    m_chartRect = QRectF(m_rect.x() + m_margin_total_left
                         ,m_rect.y()+m_margin_total_up
                         ,m_rect.width() - m_margin_total_left - m_margin_total_right
                         ,m_rect.height() - m_margin_total_up - m_margin_total_down);
}
Ejemplo n.º 13
0
void HoverPoints::_movePoint( const int index, const QPointF& point,
                              const bool emitUpdate )
{
    // Get the point bounding object to move it.
    _tfPoints[index] = getBoundPoint( point, getBoundingRect(), _locks.at( index ));

    if( emitUpdate )
        firePointChange();
}
Ejemplo n.º 14
0
void EllipseAnnotation::drawEllipseAnnotaion(QPainter *painter)
{
  QPainterPath path;
  // first we invert the painter since we have our coordinate system inverted.
  // inversion is required to draw the elliptic curves at correct angles.
  painter->scale(1.0, -1.0);
  painter->translate(0, ((-boundingRect().top()) - boundingRect().bottom()));
  applyLinePattern(painter);
  applyFillPattern(painter);
  qreal startAngle = StringHandler::getNormalizedAngle(mStartAngle);
  qreal endAngle = StringHandler::getNormalizedAngle(mEndAngle);
  if ((startAngle - endAngle) == 0) {
    path.addEllipse(getBoundingRect());
    painter->drawPath(path);
  } else {
    painter->drawPie(getBoundingRect(), mStartAngle*16, mEndAngle*16 - mStartAngle*16);
  }
}
Ejemplo n.º 15
0
QPainterPath RectangleAnnotation::shape() const
{
  QPainterPath path;
  path.addRoundedRect(getBoundingRect(), mRadius, mRadius);
  if (mFillPattern == StringHandler::FillNone)
    return addPathStroker(path);
  else
    return path;
}
Ejemplo n.º 16
0
void BitmapAnnotation::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
  Q_UNUSED(option);
  Q_UNUSED(widget);

  if(!mImageSource.isEmpty())
  {
    //open file from image source
    QByteArray data = QByteArray::fromBase64(mImageSource.toLatin1());
    QImage image;
    if(image.loadFromData(data))
      painter->drawImage(getBoundingRect(), image.mirrored());
  }
  else
  {
    QImage image(mFileName);
    painter->drawImage(getBoundingRect(), image.mirrored());
  }
}
Ejemplo n.º 17
0
QPainterPath EllipseAnnotation::shape() const
{
  QPainterPath path;
  qreal startAngle = StringHandler::getNormalizedAngle(mStartAngle);
  qreal endAngle = StringHandler::getNormalizedAngle(mEndAngle);
  if ((startAngle - endAngle) == 0)
  {
    path.addEllipse(getBoundingRect());
    if (mFillPattern == StringHandler::FillNone)
    {
      return addPathStroker(path);
    }
    else
    {
      return path;
    }
  }
  path.addEllipse(getBoundingRect());
  return path;
}
Ejemplo n.º 18
0
void Hint::render(Scene& parent)
{
	SDL_Window * win = parent.app().getWindow();
	int width, height;
	SDL_GetWindowSize(win, &width, &height);

	Rect rect = getBoundingRect(win);
	
	glPushAttrib(GL_ENABLE_BIT);
	{
		glMatrixMode(GL_PROJECTION);
		glDisable(GL_LIGHTING);
		glPushMatrix();
		{
			glLoadIdentity();
			glOrtho(0, width, 0, height, -1, 1);
			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();
			{
				glLoadIdentity();
				glBindTexture(texture);
				glColor(Vector3::one, 1-animTime); 
				glBegin(GL_QUADS);
				{
					glTexCoord2f(0, 0);
					glVertex2f(rect.left(), height - rect.top());
					glTexCoord2f(0, 1);
					glVertex2f(rect.left(), height - rect.bottom());
					glTexCoord2f(1, 1);
					glVertex2f(rect.right(), height - rect.bottom());
					glTexCoord2f(1, 0);
					glVertex2f(rect.right(), height - rect.top());
				}
				glEnd();
			}
			glPopMatrix();
		}
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
	}
	glPopAttrib();

	if(fadingOut)
	{
		animTime += parent.app().getFrameTime();
		if(animTime > 1){
			animTime = 0;
			fadingOut = false;
			disable();
		}
	}
}
Ejemplo n.º 19
0
Projectile::Projectile(Type type, const TextureHolder& textures)
: Entity(1)
, mType(type)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
, mTargetDirection()
{
	centerOrigin(mSprite);
    
    // Add particle system for missiles
    if (isGuided())
    {
        std::unique_ptr<EmitterNode> smoke(new EmitterNode(Particle::Smoke));
        smoke->setPosition(0.f, getBoundingRect().height / 2.f);
        attachChild(std::move(smoke));
        
        std::unique_ptr<EmitterNode> propellant(new EmitterNode(Particle::Propellant));
        propellant->setPosition(0.f, getBoundingRect().height / 2.f);
        attachChild(std::move(propellant));
        
    }
}
Ejemplo n.º 20
0
void SceneNode::drawBoundingRect(sf::RenderTarget& target, sf::RenderStates) const
{
	sf::FloatRect rect = getBoundingRect();

	sf::RectangleShape shape;
	shape.setPosition(sf::Vector2f(rect.left, rect.top));
	shape.setSize(sf::Vector2f(rect.width, rect.height));
	shape.setFillColor(sf::Color::Transparent);
	shape.setOutlineColor(sf::Color::Green);
	shape.setOutlineThickness(1.f);

	target.draw(shape);
}
DiasporaClusterGraphicsItem::DiasporaClusterGraphicsItem(float fx, float fy, ClusterItem &item) :
        _corner(QPointF(fx,fy)),
        _x(fx), _y(fy),
        _clusterItem(item),
        _referenceSize(DiasporaDefaultFonts::TitleFont().pointSizeF())
{
    _size = QSizeF(200,200);
    _itemName = _clusterItem.name();
    _rect = getBoundingRect();
    _currentScene = 0;
    this->setFlag(QGraphicsItem::ItemIsSelectable,true);
    //this->setFlag(QGraphicsItem::ItemIsMovable,true);
}
Ejemplo n.º 22
0
bool SkillsNode::mouseIntersects(sf::RenderWindow& window)
{
    sf::FloatRect aux;
    aux = getBoundingRect();

    if(sf::Mouse::getPosition(window).x >= aux.left
            && sf::Mouse::getPosition(window).x <= aux.left + aux.width
            && sf::Mouse::getPosition(window).y >= aux.top
            && sf::Mouse::getPosition(window).y <= aux.top + aux.height)
    {
        return true;
    }
    else
    {
        return false;
    }
}
Ejemplo n.º 23
0
void PSV_ChartItem::adjustTitlePos()
{
    if(m_titleItem == NULL)
    {
        return;
    }
//    qreal margin = getData(PSV::margin).toDouble();
//    PSV_Public::printMes(margin,"margin");

    qreal x = m_chartRect.left() + 0.5 * (m_chartRect.width() - m_titleItem->boundingRect().width());
    qreal dy = 0;
    if(m_upAxisItem != NULL)
    {
        dy += m_upAxisItem->validRect().height();
    }
    qreal y = getBoundingRect().top() + (m_margin_total_up - m_margin_up - getData(PSV::margin,3).toInt() - m_titleItem->boundingRect().height()) * 0.5;
    m_titleItem->setPos(x,y);
}
Ejemplo n.º 24
0
void PSV_ChartItem::createHVLine()
{
    QLineF hLine(m_chartRect.left(),m_chartRect.center().y(),m_chartRect.right(),m_chartRect.center().y());
    QLineF vLine(m_chartRect.center().x(),m_chartRect.top(),m_chartRect.center().x(),m_chartRect.bottom());

    m_hLineItem = new QGraphicsLineItem(hLine,this);
    m_vLineItem = new QGraphicsLineItem(vLine,this);
    m_boundingItem = new QGraphicsRectItem(getBoundingRect(),this);
    m_hLineItem->hide();
    m_vLineItem->hide();
    m_boundingItem->hide();
    m_hLineItem->setZValue(10001);
    m_vLineItem->setZValue(10001);
    m_boundingItem->setZValue(10001);

    m_currentMesItem = new QGraphicsTextItem(this);
    //    m_currentMesItem->setFont(m_valueFont);

}
Ejemplo n.º 25
0
double PSV_ChartItem::getAxisY(float dataY, int adjust) const
{
    double y = m_margin_total_up + getBoundingRect().top();
    QRectF rect = m_chartRect;
    if(!rect.isValid())
    {
        return y;
    }

    if(*m_max_y_curP > *m_min_y_curP)
    {
        y = rect.bottom() - 1.0 * (dataY - *m_min_y_curP) / (*m_max_y_curP - *m_min_y_curP) * rect.height() - adjust;
    }
    else
    {
        PSV_Public::printMes(QString("*m_max_y_curP(%1) <= *m_min_y_curP(%2)")
                             .arg(*m_max_y_curP).arg(*m_min_y_curP));
    }
    return y;
}
Ejemplo n.º 26
0
void HoverPoints::setPoints( const QPolygonF& listPoints )
{
    // If the given list of points is not equal to the current list,
    // clear all the points.
    if( listPoints.size() != _tfPoints.size())
        _fingerPointMapping.clear();
    _tfPoints.clear();

    // Update the current _tfPoints_ list to the given list of points.
    for( int32_t i = 0; i < listPoints.size(); ++i )
        _tfPoints << getBoundPoint( listPoints.at(i), getBoundingRect(), 0 );

    // Update the new list of points before drawinf them.
    _locks.clear();
    if( _tfPoints.size() > 0 )
    {
        _locks.resize( _tfPoints.size());
        _locks.fill(0);
    }
}
Ejemplo n.º 27
0
rspfAppFixedTileCache::rspfAppFixedCacheId rspfCacheTileSource::getCacheId(rspf_uint32 resLevel)
{
   rspfAppFixedTileCache::rspfAppFixedCacheId result = -1;
   if(theRLevelCacheList.empty())
   {
      initializeRlevelCache();
   }
   if(resLevel < theRLevelCacheList.size())
   {
      if(theRLevelCacheList[resLevel] <0)
      {
         rspfIpt cacheTileSize(theFixedTileSize);
         if(theUseInputTileSizeFlag)
         {
            cacheTileSize = rspfIpt(rspf::min(static_cast<rspf_int32>(theInputConnection->getTileWidth()),
                                                static_cast<rspf_int32>(1024)), 
                                     rspf::min(static_cast<rspf_int32>(theInputConnection->getTileHeight()),
                                                static_cast<rspf_int32>(1024)));
            
         }

         //std::cout << cacheTileSize << std::endl;
         rspfIrect rect = getBoundingRect(resLevel);
         
         if((cacheTileSize.x > static_cast<rspf_int64>(rect.width()))&&
            (cacheTileSize.y > static_cast<rspf_int64>(rect.height())))
         {
            cacheTileSize.x = rspf::max(static_cast<rspf_int64>(rect.width()), 
                                         static_cast<rspf_int64>(64));
            cacheTileSize.y = rspf::max(static_cast<rspf_int64>(rect.height()), 
                                         static_cast<rspf_int64>(64));
         }

         rect.stretchToTileBoundary(theFixedTileSize);
         theRLevelCacheList[resLevel] = rspfAppFixedTileCache::instance()->newTileCache(rect, cacheTileSize); 
      }
      result = theRLevelCacheList[resLevel];
   }
   
   return result;
}
Ejemplo n.º 28
0
//---------------------------------------------------------------------
// ● 地形との当たり判定を行う
//---------------------------------------------------------------------
u32 GameObject::judgeCollisionToMap( float* dx_, float* dy_ )
{
    *dx_ = *dy_ = 0.0f;

    // 当たり判定全般は、判定用の矩形がある場合にのみ行う
    const LRect* rc = getBoundingRect();
    if ( rc )
    {
        LRect col_rect = *rc;

        // 移動した後の座標
	    LVector3 d_pos = mPosition + mVelocity;

        // 移動前の判定用矩形の座標
        float px = col_rect.x;
        float py = col_rect.y;

        // 矩形を移動させて、移動後の判定領域にする
        col_rect.x += static_cast< int >( mVelocity.x );
        col_rect.y += static_cast< int >( mVelocity.y );
        
	    // 移動量 (いまはつかわないかも)
	    LVector3 dest = mPosition - d_pos;

	    // マップとの当たり判定結果の、修正後の座標を格納する変数
	    LVector3 result_pos;
		
        
	    u32 result = MapManager::getInstance()->collision( col_rect, dest, &result_pos );

        // 移動前と比べて、移動量を求める
        *dx_ = result_pos.x - px;
        *dy_ = result_pos.y - py;

		return result;
    }
    return 0;
}
Ejemplo n.º 29
0
void Creature::updateCurrent(sf::Time dt, CommandQueue &commands)
{
    updateAnimation(dt);

    if(isDestroyed() && !hasBeenSacrificed())
    {
        if(mEmitter)
        {
            mEmitter->update(dt, commands);
            mDestroyedSince += dt;
        }
        else
        {
            // blood
            std::unique_ptr<EmitterNode> e(new EmitterNode(Particle::Default));
            e->setPosition(sf::Vector2f(0.f, -32.f));
            mEmitter = e.get();
            attachChild(std::move(e));

            // text
            if(randomInt(4) == 0)
            {
                Command command;
                command.category = Category::UILayer;
                command.action = derivedAction<SceneNode>([this] (SceneNode& node, sf::Time) {
                    std::string str = StringTable[randomInt(StringTable.size())];
                    std::unique_ptr<CombatTextNode> tn(new CombatTextNode(str, mFonts));
                    tn->setPosition(sf::Vector2f(getPosition().x, getPosition().y-getBoundingRect().height/2));
                    node.attachChild(std::move(tn));
                });
                commands.push(command);
            }
        }
    }

    mAIController.update(commands, *this);
    Entity::updateCurrent(dt, commands);
}
Ejemplo n.º 30
0
QPainterPath BitmapAnnotation::shape() const
{
  QPainterPath path;
  path.addRoundedRect(getBoundingRect(), mCornerRadius, mCornerRadius);
  return path;
}