void BarView::draw(Painter &painter) { painter.setFillColor(Color(0,0xAA,0,255)); if((int)(width*value)>0 && dir) { painter.fillRectangle(Rect2D(0,0,width*value,height)); } else if((int)(width*value)<0 && !dir) { painter.setFillColor(Color(0xFF,0,0,255)); painter.fillRectangle(Rect2D(width-1+width*value,0,width-1,height)); } }
Rect2D SpriteRenderNode::getWorldRect() { if(hasBounds) { return Rect2D(Vector2(-bounds.X()/2, -bounds.Y()/2),Vector2(bounds.X()/2,bounds.Y()/2)); } else { Texture* tex = CalicoAPI::getResourceManager()->getTexture(texture); assert(tex != NULL); float zoomFactor = layer->getCamera()->getZoomFactor(); return Rect2D( Vector2(zoomFactor * -tex->getWorldDimensions().X()/2, zoomFactor * -tex->getWorldDimensions().Y()/2), Vector2(zoomFactor * tex->getWorldDimensions().X()/2, zoomFactor * tex->getWorldDimensions().Y()/2) ); } }
std::list<Rect2D> Rect2D::split() const { std::list<Rect2D> l; int w2=w/2; int h2=h/2; int w2a=w-w2; int h2a=h-h2; l.push_back(Rect2D(x ,y ,w2,h2)); l.push_back(Rect2D(x+w2,y ,w2a,h2)); l.push_back(Rect2D(x ,y+h2,w2,h2a)); l.push_back(Rect2D(x+w2,y+h2,w2a,h2a)); return l; }
Rect2D CameraRenderNode::getCameraBounds() { if(guiCamera) { Vector2 bounds = scene->getSettingsManager()->getPointViewportBounds(); return Rect2D(Vector2(0,0), bounds); } else { Vector2 bounds = scene->getSettingsManager()->getPointViewportBounds(); float width = bounds.X(); float height = bounds.Y(); GLfloat cameraWidth = width * zoomFactor; GLfloat cameraHeight = height * zoomFactor; Vector2 cameraBoundsMin = Vector2(-cameraWidth/2, -cameraHeight/2); Vector2 cameraBoundsMax = Vector2(cameraWidth/2, cameraHeight/2); return Rect2D(cameraBoundsMin, cameraBoundsMax); } }
void ScrollView::resize(float newwidth, float newheight) { float scrollBarWidth = scrollBar().getComponent()->getWidth(); scrollBar().getComponent()->resize(scrollBarWidth, newheight); scrollBar().setPos(Vector2(newwidth - scrollBarWidth, 0)); float scrollarea = 0; if(contents().getComponent() != 0) { Component* component = contents().getComponent(); if(component->getFlags() & FLAG_RESIZABLE) component->resize(newwidth - scrollBarWidth, newheight); contents().setClipRect( Rect2D(0, 0, newwidth - scrollBarWidth, newheight)); scrollarea = component->getHeight() - newheight; if(scrollarea < 0) scrollarea = 0; } ScrollBar* scrollBarComponent = (ScrollBar*) scrollBar().getComponent(); scrollBarComponent->setRange(0, scrollarea); scrollBarComponent->setValue(0); width = newwidth; height = newheight; setDirty(); }
void ParticleEditor::DrawParticleSystem() { m_manager->SetZPosition(0.0f); const VideoPtr& video = m_provider->GetVideo(); const InputPtr& input = m_provider->GetInput(); const Vector2 v2Screen = video->GetScreenSizeF(); const bool overMenu = (input->GetCursorPosition(video).x<(int)m_menuWidth*2); if (input->GetLeftClickState() == GSKS_DOWN && !overMenu) m_v2Pos = input->GetCursorPositionF(video); else m_v2Pos = video->GetScreenSizeF()/2; if (input->GetKeyState(GSK_LEFT) == GSKS_DOWN) m_systemAngle+=2; if (input->GetKeyState(GSK_RIGHT) == GSKS_DOWN) m_systemAngle-=2; if (input->GetKeyState(GSK_UP) == GSKS_DOWN) m_systemAngle = 0.0f; if (input->GetKeyState(GSK_DOWN) == GSKS_DOWN) m_systemAngle = 180.0f; m_timer.CalcLastFrame(); m_manager->UpdateParticleSystem(m_v2Pos, Vector3(m_v2Pos, 0), m_systemAngle, static_cast<float>(m_timer.GetElapsedTime() * 1000.0)); video->SetScissor(Rect2D((int)m_menuWidth*2, 0, video->GetScreenSize().x-(int)m_menuWidth*2, video->GetScreenSize().y)); if ((m_boundingSphere.IsActive() || m_boundingSphere.IsMouseOver()) && m_system.boundingSphere >= 1) { m_sphereSprite->SetOrigin(Sprite::EO_CENTER); m_sphereSprite->DrawShaped(m_v2Pos + ETHGlobal::ToVector2(m_manager->GetStartPos()), Vector2(m_system.boundingSphere, m_system.boundingSphere), BSPHERE_COLOR, BSPHERE_COLOR, BSPHERE_COLOR, BSPHERE_COLOR); } const bool zBuffer = video->GetZBuffer(); video->SetZBuffer(false); if (m_provider->GetShaderManager()->BeginParticlePass(m_system)) { m_manager->DrawParticleSystem(Vector3(1,1,1),v2Screen.y,-v2Screen.y, ETHParticleManager::SAME_DEPTH_AS_OWNER, ETH_DEFAULT_ZDIRECTION, Vector2(0,0), 1.0f); m_provider->GetShaderManager()->EndParticlePass(); } video->SetZBuffer(zBuffer); video->UnsetScissor(); if (m_manager->Finished() || m_manager->Killed()) { ShadowPrint(Vector2(200.0f, video->GetScreenSizeF().y/2), REPLAY_MESSAGE, GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE); if (input->GetKeyState(GSK_SPACE) == GSKS_HIT || input->GetLeftClickState() == GSKS_HIT) { m_manager->Play(m_v2Pos, Vector3(m_v2Pos, 0), m_systemAngle); m_manager->Kill(false); } } str_type::stringstream ss; ss << m_system.bitmapFile; ss << GS_L(" | ") << GS_L("Active particles: ") << m_manager->GetNumActiveParticles() << GS_L("/") << m_manager->GetNumParticles(); const float infoTextSize = m_menuSize * m_menuScale; ShadowPrint(Vector2(m_menuWidth*2+5,v2Screen.y-infoTextSize-m_menuSize), ss.str().c_str(), GS_L("Verdana14_shadow.fnt"), gs2d::constant::WHITE); }
void RayTracer::traceOnePixel(int x, int y, int threadID) { //used for constructing viewport Vector2 tmp(m_settings.width, m_settings.height); Ray primaryRay; // If one ray per pixel: (kinda debugging mode with blue color for places with no surfel hit if (m_settings.raysPerPixel == 1){ //Get the primary ray from the pixel x,y primaryRay = m_camera->worldRay(x + 0.5f, y + 0.5f, Rect2D(tmp)); //Get the first surfel hit. //Can't call L_i unfortunately because we want the blue background for debugging const shared_ptr<Surfel>& s = RayTracer::castRay(primaryRay, finf(), 0); //If there is a surfel hit, get the direct illumination value and apply to the pixel if (s){ //Call L_scatteredDirect to get direct illumination. Invert primaryRay to get the direction for incident light m_image->set(Point2int32(x,y), L_o(s, -primaryRay.direction(), m_settings.recursiveBounces, *(m_rnd[threadID]))); } else{ //Set the pixels with no surfel hit. Include this line so we could make it a specific color for debug purposes. m_image->set(Point2int32(x,y), Color3(0,0,1)); } } else { Radiance3 L(0,0,0); //If more than one ray, randomly generate required number of rays within the pixel for (int i = 0; i < m_settings.raysPerPixel; ++i){ primaryRay = m_camera->worldRay(x + m_rnd[threadID]->uniform(), y + m_rnd[threadID]->uniform(), Rect2D(tmp)); L += L_i(primaryRay.origin(), primaryRay.direction(), m_settings.recursiveBounces, *(m_rnd[threadID])); } m_image->set(Point2int32(x,y), L/m_settings.raysPerPixel); } }
Rect2D CircleCollisionHull::getAABB() { Point2D topLeft(m_currentPosition._x - m_radius, m_currentPosition._y - m_radius); Point2D bottomRight(m_currentPosition._x + m_radius, m_currentPosition._y + m_radius); return Rect2D(topLeft, bottomRight); }
/** * Draw the map. * * @param painter Reference to a Painter object. */ void Window::draw(Painter& painter) { Component::draw(painter); painter.setLineColor(Color(0, 0, 0, 0xff)); painter.drawRectangle(Rect2D(0, 0, width, height)); }
void Image::draw(Painter& painter) { if(width != texture->getWidth() || height != texture->getHeight()) painter.drawStretchTexture(texture, Rect2D(0, 0, width, height)); else painter.drawTexture(texture, Vector2(0, 0)); }
AntargisMap::AntargisMap(int w,int h): mHeight(POINTS_PER_TILE*(w+2),POINTS_PER_TILE*(w+2),1,10,20), mGrass(POINTS_PER_TILE*(w+2),POINTS_PER_TILE*(w+2),2,5,10), // 1 is no-var. mEntities(Rect2D(0,0,w*TILE_SIZE,h*TILE_SIZE)),mW(w),mH(h),mRubyObject(false) { myAntargisMap=this; mPaused=false; maxID=0; }
// TODO - these functions should probably cache values to be more efficient Rect2D CameraRenderNode::getWorldBounds() { // TODO - this is inefficient Vector2 min = convertToWorldCoords(Vector2(0.0f,0.0f)); Rect2D cameraBounds = getCameraBounds(); // TODO - this doesn't handle rotation correctly, is inefficient Vector2 max = convertToWorldCoords(Vector2((cameraBounds.max.X() * 2)/zoomFactor, (cameraBounds.max.Y() * 2)/zoomFactor)); return Rect2D(min, max); }
void ETHLight::SetLightScissor(const VideoPtr& video, const Vector2& zAxisDir) const { const float squareEdgeSize = range * 2.0f; Vector2 sum(zAxisDir * pos.z * 2.0f); sum.x = Abs(sum.x); sum.y = Abs(sum.y); const Vector2 squareSize(Vector2(squareEdgeSize, squareEdgeSize) + sum); const Vector2 absPos(ETHGlobal::ToScreenPos(pos, zAxisDir) - video->GetCameraPos() - (squareSize * 0.5f)); video->SetScissor(Rect2D(absPos.ToVector2i(), squareSize.ToVector2i())); }
void Document::draw(Painter& painter) { if(style.background.a != 0) { painter.setFillColor(style.background); painter.fillRectangle(Rect2D(0, 0, width, height)); } Component::draw(painter); }
void App::samplePixel(int x, int y, int threadID) { float randX,randY,randZ; Random& rng = m_rng[threadID]; for (int i = 0; i < m_featureData.getSamplePerPixelToGo(x,y) ; ++i){ rng.sphere(randX,randY,randZ); randX = (randX/2.0) + 0.5; randY = (randY/2.0) + 0.5; Ray initialRay = m_debugCamera->worldRay(x + randX, y + randY ,Rect2D(Vector2(m_imgWidth,m_imgHeight))); Point3 pointInFocalPlane = initialRay.intersection(m_focalPlane); rng.sphere(randX,randY,randZ); Point3 newCamPos = initialRay.origin() + (Vector3(randX,randY,0.0)*m_world->blurRadius); Vector3 newDir = (pointInFocalPlane - newCamPos).unit(); tracePath(Ray(newCamPos,newDir), m_world, rng,x,y); } }
void App::onInit() { tick(); message("Loading..."); renderDevice->setSwapBuffersAutomatically(true); m_world = new World(m_worldScene); // Create one random number generator per thread m_rng.resize(GThread::numCores()); for (int i = 0; i < m_rng.size(); ++i) { //m_rng[i].reset(0xF018A4D2 ^ i, false); //m_rng[i].reset(uint32(System::time()) ^ i); } Array<Plane,10> clipPlanes; float a,b,c,d; showRenderingStats = false; createDeveloperHUD(); developerWindow->setVisible(false); developerWindow->cameraControlWindow->setVisible(false); m_debugCamera->filmSettings().setAntialiasingEnabled(false); m_debugCamera->filmSettings().setAntialiasingHighQuality(false); m_debugCamera->filmSettings().setBloomStrength(0.0f); m_debugCamera->setFrame(m_world->frame); m_debugCamera->setFieldOfView(m_world->FOVDeg*pi()/180.0,FOVDirection::VERTICAL); m_debugCamera->getClipPlanes(Rect2D(Vector2(window()->width(),window()->height())),clipPlanes); clipPlanes[0].getEquation(a,b,c,d); m_focalPlane = Plane::fromEquation(-a,-b,-c,-(d-(m_world->focalDist))); makeGUI(); // Force re-render on first frame m_prevCFrame = CFrame(Matrix3::zero()); float time = tock("Loading scene"); //Initialize StatsData class m_featureData.init(m_imgWidth,m_imgHeight,m_sampleBudget,m_samplesPerIteration); //Initialize filter with the features data pointers; m_CBFilter.init(&m_featureData); }
void TableLayout::draw(Painter& painter) { Component::draw(painter); if(border) { float r = 0; float c = 0; painter.setLineColor(Color(0, 0, 255)); for(size_t row = 0; row < rowproperties.size(); ++row) { float nextr = r + rowproperties[row].realval; for(size_t col = 0; col < colproperties.size(); ++col) { float nextc = c + colproperties[col].realval; painter.drawRectangle(Rect2D(c, r, nextc, nextr)); c = nextc; } r = nextr; c = 0; } } }
Rect2D PoligonCollisionHull::getAABB() { float minX = std::numeric_limits<float>::max(); float minY = std::numeric_limits<float>::max(); float maxX = std::numeric_limits<float>::min(); float maxY = std::numeric_limits<float>::min(); for(IPhysics::PointList::iterator it = m_currentPoints.begin(); it != m_currentPoints.end(); ++it) { float x = (*it)._x; float y = (*it)._y; minX = (minX > x) ? x : minX; minY = (minY > y) ? y : minY; maxX = (maxX < x) ? x : maxX; maxY = (maxY < y) ? y : maxY; } return Rect2D(Point2D(minX, minY), Point2D(maxX, maxY)); }
ResultsUI::ResultsUI(SpriteList *spriteList) : Screen(spriteList) { mHeaderFont = FontManager::Load("definitionBody"); mHeaderBar = new HeaderBar(mSpriteList, mHeaderFont); mLeaderboard = new Leaderboard(mSpriteList); mSummary = new Summary(mSpriteList); mSummary->mVisible = false; mSummary->mActive = false; mLeaderboard->mVisible = false; mLeaderboard->mActive = false; mSummary->mVisible = false; mSummary->mActive = false; mFillRectangle = new UI::Rectangle(Vec2(-2, -2), Vec2((float)::Screen::Width() + 4, 36), Color(0xff, 0x50, 0x50, 0x50), Color::Black, 2); mFillRectangle->mHitRect = Rect2D(Point2D(-1, -1), Size2D(0,0)); mCloseTexture = Texture::Load("icon_close.png"); mCloseButton = new UI::ImageButton(mCloseTexture, Vec2(::Screen::Width() - 48.0f, 0), Vec2(48, 48)); AddUIItem(mFillRectangle); AddUIItem(mCloseButton); mHeaderBar->AddButton("High scores", mLeaderboard); mHeaderBar->AddButton("Summary", mSummary); mCloseButton->OnPress = [this] () { Activate(false); if(OnClose != null) { OnClose(); } }; Activate(false); this->mZIndex = 2; mHeaderBar->mZIndex = 3; mLeaderboard->mZIndex = 0; mSummary->mZIndex = 0; }
Rect2D SceneNode::getBoundBox() { return Rect2D(); }
void OsmAnd::AtlasMapRendererDebugStage_OpenGL::addRect2D(const AreaF& rect, const uint32_t argbColor, const float angle /*= 0.0f*/) { _rects2D.push_back(qMove(Rect2D(rect, argbColor, angle))); }
void Renderer::DrawRect(double left, double top, double width, double height, float lineWidth) { DrawRect(Rect2D(left, top, left + width, top + height), lineWidth); }
shared_ptr<Entity> Scene::intersectEyeRay(const shared_ptr<Camera>& camera, const Vector2& pixel, const Rect2D& viewport, const Vector2int16 guardBandThickness, bool hitMarkers, const Array<shared_ptr<Entity> >& exclude, Model::HitInfo& selectionInfo) const { const Ray& ray = camera->worldRay(pixel.x + guardBandThickness.x, pixel.y + guardBandThickness.y, Rect2D(Vector2(viewport.width() + 2 * guardBandThickness.x, viewport.height() + 2 * guardBandThickness.y))); // clear old selection info selectionInfo.clear(); float distance = finf(); return intersect(ray, distance, hitMarkers, exclude, selectionInfo); }
void Renderer::DrawRect(const Vector2D& lefttop, const Vector2D& rightbottom, float lineWidth) { DrawRect(Rect2D(lefttop, rightbottom), lineWidth); }
void setDirty() { setDirty(Rect2D(0, 0, width, height)); }
Rect2D PointCollisionHull::getAABB() { return Rect2D(); }
void Renderer::FillRect(double left, double top, double width, double height) { FillRect(Rect2D(left, top, left + width, top + height)); }
void Renderer::FillRect(const Vector2D& lefttop, const Vector2D& rightbottom) { FillRect(Rect2D(lefttop, rightbottom)); }
Texture* TextureManagerGL::create(SDL_Surface* image) { int texture_w = powerOfTwo(image->w); int texture_h = powerOfTwo(image->h); //int texture_w = image->w; //int texture_h = image->h; //LOGD("[Lincity]TextureManagerGL::create() - w=%d h=%d w=%d h=%d pitch=%d\n",texture_w,texture_h,image->w,image->h,image->pitch); #if SDL_BYTEORDER == SDL_BIG_ENDIAN SDL_Surface* convert = SDL_CreateRGBSurface(SDL_SWSURFACE, texture_w, texture_h, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); #else SDL_Surface* convert = SDL_CreateRGBSurface(SDL_SWSURFACE, texture_w, texture_h, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); #endif if(convert == 0) { std::ostringstream msg; msg << "Couldn't convert SDL_Surface while creating texture" << " (out of memory?): " << SDL_GetError(); throw std::runtime_error(msg.str()); } SDL_SetAlpha(image, 0, 0); SDL_BlitSurface(image, 0, convert, 0); GLuint handle; glGenTextures(1, &handle); SDL_PixelFormat* format = convert->format; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glBindTexture(GL_TEXTURE_2D, handle); //LOGD("[Lincity]TextureManagerGL::create() - Handle %d\n",handle); //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); //glPixelStorei(GL_UNPACK_ROW_LENGTH, convert->pitch/format->BytesPerPixel); //assert(convert->pitch == texture_w * convert->format->BytesPerPixel); /* glTexImage2D(GL_TEXTURE_2D, 0, format->BytesPerPixel, convert->w, convert->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, convert->pixels); */ glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, convert->w, convert->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, convert->pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP); */ //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_CLAMP_TO_EDGE); //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_CLAMP_TO_EDGE); TextureGL* texture = new TextureGL(handle); texture->rect = Rect2D(0, 0, (float) image->w/(float) texture_w, (float) image->h/(float) texture_h); /* texture->rect = Rect2D(0, 0, 1., 1.); */ texture->width = image->w; texture->height = image->h; SDL_FreeSurface(image); SDL_FreeSurface(convert); if (int a = glGetError() != 0) { LOGD("[Lincity]TextureManagerGL::create() ERROR OCCURED : %d\n",a); switch (a) { case GL_INVALID_ENUM: LOGD("[Lincity]TextureManagerGL::create() GL_INVALID_ENUM\n"); break; case GL_INVALID_VALUE: LOGD("[Lincity]TextureManagerGL::create() GL_INVALID_VALUE\n"); break; case GL_INVALID_OPERATION: LOGD("[Lincity]TextureManagerGL::create() GL_INVALID_OPERATION\n"); break; case GL_STACK_OVERFLOW: LOGD("[Lincity]TextureManagerGL::create() GL_STACK_OVERFLOW\n");; break; case GL_STACK_UNDERFLOW: LOGD("[Lincity]TextureManagerGL::create() GL_STACK_UNDERFLOW\n"); break; case GL_OUT_OF_MEMORY: LOGD("[Lincity]TextureManagerGL::create() GL_OUT_OF_MEMORY\n"); break; } } return texture; }