BulletParticle::BulletParticle() : Particle("bullet_particle") { SetCollisionModel(true, false, false); m_rebound_sound = "weapon/m16_cartridge"; m_left_time_to_live = 1; start_to_fade = 0; image = ParticleEngine::GetSprite(BULLET_spr); image->Scale(1.0,1.0); SetSize(Point2i(1, 1)); }
/* Public */ Camera::Camera(const Point2i &position, const Point2i &dimensions, const Point2i &frameDimensions, const Point2i &textureDimensions) : UIElement(position, dimensions) { this->frameDimensions = frameDimensions; int px = position.getX(); int py = position.getY() + dimensions.getY() - CONTROL_BAR_HEIGHT; int dx = dimensions.getX() - 125; int dy = CONTROL_BAR_HEIGHT; controls = new CameraControls(Point2i(px, py), Point2i(dx, dy)); controls->setClickedCallback(MakeDelegate(this, &Camera::controls_Clicked)); registerEventHandler(controls); mode = new ModeToggle(Point2i(dx, py), Point2i(125, dy), "switch_slide.png", "switch_rub.png"); mode->setClickedCallback(MakeDelegate(this, &Camera::mode_Clicked)); registerEventHandler(mode); GLfloat data[12] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f }; float u0 = 0.0f; float u1 = (float)frameDimensions.getX() / (float)textureDimensions.getX(); float v0 = 0.0f;// float v1 = (float)frameDimensions.getY() / (float)textureDimensions.getY(); GLfloat textureData[8] = { u0, v1, u1, v1, u0, v0, u1, v0 }; vbo = new GLVbo(GL_TRIANGLE_STRIP, GL_STATIC_DRAW, data, 4, textureData); }
void Map::updateSprites() { for (unsigned int sup = 0; sup < 6; sup++) { for (unsigned int x = 0; x < _width; x++) { for (unsigned int y = 0; y < _height; y++) { _cases[x][y].vertexArray[sup].vertices.clear(); _cases[x][y].vertexArray[sup].texture = NULL; } } } for (unsigned int i = 0; i < _width; i++) { for (unsigned int j = 0; j < _height; j++) { for (unsigned int c = 0; c < 5; c++) { if (_cases[i][j].GetCoucheExist(c)) { Point2i tilesetPosition = _cases[i][j].GetTilesetPos(c); unsigned int super = _tileset.GetTilesetCase(tilesetPosition).superpositionPriority; if (_cases[i][j].GetTilesetPos(c).y == 0) { if (_tileset.GetAutotileExist(_cases[i][j].GetTilesetPos(c))) { _tileset.GetAutotile(tilesetPosition)->GetSprites((_cases[i - 1][j - 1].GetTilesetPos(c) == tilesetPosition), (_cases[i][j - 1].GetTilesetPos(c) == tilesetPosition), (_cases[i + 1][j - 1].GetTilesetPos(c) == tilesetPosition), (_cases[i - 1][j].GetTilesetPos(c) == tilesetPosition), (_cases[i + 1][j].GetTilesetPos(c) == tilesetPosition), (_cases[i - 1][j + 1].GetTilesetPos(c) == tilesetPosition), (_cases[i][j + 1].GetTilesetPos(c) == tilesetPosition), (_cases[i + 1][j + 1].GetTilesetPos(c) == tilesetPosition), Point2i(i, j), _cases[i][j].vertexArray[super].vertices); _cases[i][j].vertexArray[super].texture = _tileset.GetAutotile(tilesetPosition)->GetTexture(); } } else { sfUse::Sprite2VertexArray(GetSprite(i, j, c), _cases[i][j].vertexArray[super].vertices); _cases[i][j].vertexArray[super].texture = _tileset.GetTexture(); } } } } } }
void RealisticCamera::RenderExitPupil(Float sx, Float sy, const char *filename) const { Point3f pFilm(sx, sy, 0); const int nSamples = 2048; Float *image = new Float[3 * nSamples * nSamples]; Float *imagep = image; for (int y = 0; y < nSamples; ++y) { Float fy = (Float)y / (Float)(nSamples - 1); Float ly = Lerp(fy, -RearElementRadius(), RearElementRadius()); for (int x = 0; x < nSamples; ++x) { Float fx = (Float)x / (Float)(nSamples - 1); Float lx = Lerp(fx, -RearElementRadius(), RearElementRadius()); Point3f pRear(lx, ly, LensRearZ()); if (lx * lx + ly * ly > RearElementRadius() * RearElementRadius()) { *imagep++ = 1; *imagep++ = 1; *imagep++ = 1; } else if (TraceLensesFromFilm(Ray(pFilm, pRear - pFilm), nullptr)) { *imagep++ = 0.5f; *imagep++ = 0.5f; *imagep++ = 0.5f; } else { *imagep++ = 0.f; *imagep++ = 0.f; *imagep++ = 0.f; } } } WriteImage(filename, image, Bounds2i(Point2i(0, 0), Point2i(nSamples, nSamples)), Point2i(nSamples, nSamples)); delete[] image; }
void SplitContainer::_notification(int p_what) { switch (p_what) { case NOTIFICATION_SORT_CHILDREN: { _resort(); } break; case NOTIFICATION_MOUSE_ENTER: { mouse_inside = true; update(); } break; case NOTIFICATION_MOUSE_EXIT: { mouse_inside = false; update(); } break; case NOTIFICATION_DRAW: { if (!_getch(0) || !_getch(1)) return; if (collapsed || (!mouse_inside && get_constant("autohide"))) return; int sep = dragger_visibility != DRAGGER_HIDDEN_COLLAPSED ? get_constant("separation") : 0; Ref<Texture> tex = get_icon("grabber"); Size2 size = get_size(); if (dragger_visibility == DRAGGER_VISIBLE) { if (vertical) draw_texture(tex, Point2i((size.x - tex->get_width()) / 2, middle_sep + (sep - tex->get_height()) / 2)); else draw_texture(tex, Point2i(middle_sep + (sep - tex->get_width()) / 2, (size.y - tex->get_height()) / 2)); } } break; } }
template<typename I, typename O> int denoiseModifiedNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, bool dump = true) { ModifiedNLMeansDenoiser<I, O> *denoiser = new ModifiedNLMeansDenoiser<I, O>(r, f, k, sigma, dump); TBitmap<I> *inputA = new TBitmap<I>; //BitmapI *inputsppA = new BitmapI; TBitmap<I> *inputsppA = new TBitmap<I>; TBitmap<I> *inputvarA = new TBitmap<I>; TBitmap<I> *inputvarsA = new TBitmap<I>; TBitmap<I> *inputB = new TBitmap<I>; //BitmapI *inputsppB = new BitmapI; TBitmap<I> *inputsppB = new TBitmap<I>; TBitmap<I> *inputvarB = new TBitmap<I>; TBitmap<I> *inputvarsB = new TBitmap<I>; Assert(inputA->loadBitmap(inputfile + "_A", inputtype), "Input bitmap A failed to load!"); Assert(inputsppA->loadBitmap(inputfile + "_spp_A", inputtype), "Input spp bitmap A failed to load!"); Assert(inputvarA->loadBitmap(inputfile + "_variance_A", inputtype), "Input variance bitmap A failed to load!"); Assert(inputvarsA->loadBitmap(inputfile + "_variance_square_A", inputtype), "Input variance square bitmap A failed to load!"); Assert(inputB->loadBitmap(inputfile + "_B", inputtype), "Input bitmap B failed to load!"); Assert(inputsppB->loadBitmap(inputfile + "_spp_B", inputtype), "Input spp bitmap B failed to load!"); Assert(inputvarsB->loadBitmap(inputfile + "_variance_square_B", inputtype), "Input variance square bitmap B failed to load!"); Assert(inputvarB->loadBitmap(inputfile + "_variance_B", inputtype), "Input variance bitmap B failed to load!"); DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), inputA->getSize(), 1, false, inputA, inputsppA, inputvarA, inputvarsA)); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), inputB->getSize(), 1, false, inputB, inputsppB, inputvarB, inputvarsB)); DenoiserOutput<O> *dOutput = denoiser->denoise(dInput); LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration()); dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype); inputA->unloadBitmap(); inputsppA->unloadBitmap(); inputvarA->unloadBitmap(); inputvarsA->unloadBitmap(); inputB->unloadBitmap(); inputsppB->unloadBitmap(); inputvarB->unloadBitmap(); inputvarsB->unloadBitmap(); std::cin.get(); _CrtDumpMemoryLeaks(); // prints mem leaks return 0; }
Point2i InputProcessing::getRightEyeCorner(Mat gray, Rect rightEye) { Rect rightEyeCorner = rightEye; //omit top 1/4 of image rightEyeCorner.y += rightEyeCorner.height * .25; rightEyeCorner.height /= 2; rightEyeCorner.x += .5 * rightEyeCorner.width; rightEyeCorner.width *= .5; Mat im = Mat(gray, rightEyeCorner); vector<Point2i> features; // GaussianBlur(im, im, Size(3, 3), 0, 0); goodFeaturesToTrack(im, features, 15, .15, rightEyeCorner.height / 16); double minDist = DBL_MAX, minIndex = -1, i = 0; for (Point2i p : features) { //ydist = distnace from middle of inner edge of leftEye rectangle double ydist = (p.y - (rightEye.height / 4)); double xdist = (p.x - (rightEye.width / 2)); double dist = xdist * xdist + ydist * ydist * 4; if (dist < minDist) { minDist = dist; minIndex = i; } i++; } if (minIndex >= 0) { Point2i res = features[minIndex] + Point2i(rightEyeCorner.x, rightEyeCorner.y); if (DEBUG_MODE) { //circle(drawFrame, Point2i(rightEye.x + rightEye.width, rightEye.y + rightEye.height / 2), 1, Scalar(255, 10, 10)); } return res; } return Point2i(-1, -1); }
PolecatFart::PolecatFart() : Particle("polecat_fart_particle") { m_initial_time_to_live = 50; m_left_time_to_live = m_initial_time_to_live; m_time_between_scale = 100; SetCollisionModel(false, false, false); is_active = true; image = ParticleEngine::GetSprite(POLECAT_FART_spr); image->Scale(1.0,1.0); SetSize( Point2i(10, 10) ); }
void Chat::ShowInput() { if (!check_input) { check_input = true; /* Enable key repeat when chatting :) */ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } if (!input) { input = new Text("", c_white); msg = new Text(_("Say: "), c_red); } /* FIXME where do those constants come from ?*/ int ypos = GetMainWindow().GetHeight() - 100; msg->DrawLeftTop(Point2i(25, ypos)); if (input->GetText() != "") { input->DrawLeftTop(Point2i(25 + msg->GetWidth() + 5, ypos)); input->DrawCursor(Point2i(25 + msg->GetWidth() + 5, ypos), cursor_pos); } }
void CAdvancedAnnotator::EventMouseRelease(int x, int y, int keyFlag) { if(m_bMouseEvent == true) { m_ptMouseRelease = Point2i(x,y); m_rectDrawing = Rect_<int>(m_ptMouseRelease,m_ptMousePress); if(m_rectDrawing.area() > RECT_MINIMUM_AREA) { CGroundTruth tempGT(m_rectDrawing); if(m_pvecGTSaved->size() > 0) tempGT.Id = m_pvecGTSaved->at(m_pvecGTSaved->size()-1).Id + 1; else tempGT.Id = 0; m_pvecGTSaved->push_back(tempGT); m_idxSelectedRect = m_pvecGTSaved->size()-1; } else { // 가장 가까운 곳에 위치한 사각형을 선택함 Rect_<int> rectExpand; rectExpand.x = x - RECT_SELECT_DIST; rectExpand.y = y - RECT_SELECT_DIST; rectExpand.width = RECT_SELECT_DIST * 2; rectExpand.height = RECT_SELECT_DIST * 2; size_t maxIdx = -1; float maxVal = 0; for (size_t i=0; i<m_pvecGTSaved->size(); i++) { int cap = (rectExpand & m_pvecGTSaved->at(i).rectROI).area(); if(cap == 0) continue; else if(m_pvecGTSaved->at(i).eCondition == CGroundTruth::GT_DELETE) continue; int cup = (rectExpand | m_pvecGTSaved->at(i).rectROI).area(); float overlapRatio = (float)cap / (float)cup; if(maxVal < overlapRatio) { maxVal = overlapRatio; maxIdx = i; } } m_idxSelectedRect = maxIdx; } m_rectDrawing = Rect_<int>(-1,-1,0,0); m_bMouseEvent = false; } }
void CControl::Draw_debug(Mat n_img,vector<Point2f> n_linevct,char* n_windowname) { //draw point3f; /* Mat n_img2; // nImgRaw.copyTo(n_img2); cout<<n_linevct.size()<<endl; for(int i=0;i<n_linevct.size();i++) { //case1: Point2f n_pt1(0,0); Point2f n_pt2(nWidth,0); Point3f n_lineparam=n_linevct.at(i); // if(n_lineparam.y==0) // continue; // n_pt1.y=-(n_lineparam.z+n_lineparam.x*n_pt1.x)/n_lineparam.y; // n_pt2.y=-(n_lineparam.z+n_lineparam.x*n_pt2.x)/n_lineparam.y; //draw line,; // line(n_img,Point2i(n_pt1.x,n_pt1.y),Point2i(n_pt2.x,n_pt2.y),Scalar(255,255,255)); cout<<"get lines "<<n_lineparam<<endl; } imshow("2",n_img); waitKey(0);*/ //draw Point2f Mat n_img2; n_img.copyTo(n_img2); for(int i=0;i<n_linevct.size();i++) { Point2f n_pt1=n_linevct.at(i++); Point2f n_pt2=n_linevct.at(i); // cout<<n_pt1<<' '<<n_pt2<<endl; line(n_img2,Point2i(n_pt1.x,n_pt1.y),Point2i(n_pt2.x,n_pt2.y),Scalar(255,255,255)); } imshow(n_windowname,n_img2); //imwrite("temp.png",n_img); // waitKey(0); }
HammersleySampler(Stream *stream, InstanceManager *manager) : Sampler(stream, manager) { m_arrayStartDim = stream->readUInt(); m_arrayEndDim = stream->readUInt(); m_offset = stream->readULong(); m_stride = stream->readULong(); m_scramble = stream->readInt(); m_logHeight = stream->readUInt(); m_samplesPerBatch = stream->readSize(); m_factor = stream->readFloat(); m_resolution = Vector2i(stream); m_pixelPosition = Point2i(0); configure(); }
Size2 OS_X11::get_screen_size(int p_screen) const { // Using Xinerama Extension int event_base, error_base; const Bool ext_okay = XineramaQueryExtension(x11_display, &event_base, &error_base); if( !ext_okay ) return Size2i(0,0); int count; XineramaScreenInfo* xsi = XineramaQueryScreens(x11_display, &count); if( p_screen >= count ) return Size2i(0,0); Size2i size = Point2i(xsi[p_screen].width, xsi[p_screen].height); XFree(xsi); return size; }
void Label::mouseMoveEvent(QMouseEvent* event) { if (m_mousePosition) { Point2i oldMousePosition = *m_mousePosition; *m_mousePosition = Point2i(event->pos().x(), event->pos().y()); Vector2i displacement = *m_mousePosition - oldMousePosition; if (sqrLength(displacement) > 0) { emit mouseMoved(*m_mousePosition, displacement); } } else { m_mousePosition = new Point2i(event->pos().x(), event->pos().y()); emit mouseEntered(*m_mousePosition); } event->accept(); }
HaltonSampler(Stream *stream, InstanceManager *manager) : Sampler(stream, manager) { m_arrayStartDim = stream->readUInt(); m_arrayEndDim = stream->readUInt(); m_offset = stream->readULong(); m_stride = stream->readULong(); m_multInverse[0] = stream->readULong(); m_multInverse[1] = stream->readULong(); m_scramble = stream->readInt(); m_primePowers = Vector2i(stream); m_primeExponents = Vector2i(stream); m_pixelPosition = Point2i(0); configure(); }
bool HaloRefImage::resize(uint w, uint h, CNDCvec& v) { // returns true if size changes bool ret = RefImage::resize(w,h,v); // handle scratch texture now too assert(_scratch_tex); const Image& img = _scratch_tex->image(); if (Point2i(w,h) != img.dims()) { _scratch_tex->image().resize(w,h); } return ret; }
Point2i InputProcessing::getLeftEyeCorner(Mat gray, Rect leftEye) { Rect leftEyeCorner = leftEye; //omit top 1/4 of image leftEyeCorner.y += (int) (leftEyeCorner.height * .25); leftEyeCorner.height /= 2; leftEyeCorner.width *= .5; Mat im = Mat(gray, leftEyeCorner); vector<Point2i> features; // GaussianBlur(im, im, Size(3, 3), 0, 0); goodFeaturesToTrack(im, features, 15, .15, leftEyeCorner.height / 8); double minDist = DBL_MAX, minIndex = -1, i = 0; for (Point2i p : features) { //ydist = distnace from middle of inner edge of leftEye rectangle double ydist = (p.y - (leftEye.height / 4)); double dist = p.x * p.x + ydist * ydist * 4; // y difference is less likely for eye corner if (dist < minDist) { minDist = dist; minIndex = i; } i++; } if ( minIndex >= 0 ) { Point2i res = features[minIndex] + Point2i(leftEyeCorner.x, leftEyeCorner.y); if (DEBUG_MODE) { //circle(drawFrame, Point2i(leftEyeCorner.x, leftEyeCorner.y + leftEye.height / 4), 1, Scalar(10, 10, 255)); } return res; } return Point2i(-1,-1); }
void NodeGraphDisplay::drawGraph(GlInterface &gl) { AVec graph_step = virtualToAbsoluteVec(BASE_GRAPH_STEP), inv_graph_step = AVec(1.0f/graph_step.x, 1.0f/graph_step.y), dist_to_origin = virtualToAbsolutePoint(APoint(0, 0)), dist_after_origin = size - dist_to_origin; APoint first_offset = APoint(fmod(dist_to_origin.x, graph_step.x), fmod(dist_to_origin.y, graph_step.y)), last_offset = APoint(fmod(dist_after_origin.x, graph_step.x), fmod(dist_after_origin.y, graph_step.y)); Point2i lines_before_origin = Point2i(floor(dist_to_origin.x*inv_graph_step.x), floor(dist_to_origin.y*inv_graph_step.y)), lines_after_origin = Point2i(floor(dist_after_origin.x*inv_graph_step.x), floor(dist_after_origin.y*inv_graph_step.y)), num_lines = lines_before_origin + Vec2i(1, 1) + lines_after_origin; std::vector<TVertex> points; points.reserve(2*(num_lines.x + num_lines.y)); //Add vertical lines int i = 0; for(float x = first_offset.x; x < size.x; x += graph_step.x, i++) { Color c = (i != lines_before_origin.x ? Color(0.0f, 0.0f, 0.0f, 1.0f) : Color(1.0f, 0.0f, 0.0f, 1.0f)); points.push_back(TVertex(APoint(x, 0.0f), c)); points.push_back(TVertex(APoint(x, size.y), c)); } //Add horizontal lines i = 0; for(float y = first_offset.y; y < size.y; y += graph_step.y, i++) { Color c = (i != lines_before_origin.y ? Color(0.0f, 0.0f, 0.0f, 1.0f) : Color(1.0f, 0.0f, 0.0f, 1.0f)); points.push_back(TVertex(APoint(0.0f, y), c)); points.push_back(TVertex(APoint(size.x, y), c)); } //Draw lines gl.drawShape(GL_LINES, points); }
/** * Plots the axes in the ploter * * @param plot A pointer to the image. If set to NULL in outputs the * coordinates in seperate window */ void WorldPlotter::plotAxes(cv::Mat &plot) { int marker_x, marker_y; line(plot, cvPoint(plot_size_x / 2, 0), cvPoint(plot_size_x / 2, plot_size_y), x_color); line(plot, cvPoint(0, plot_size_y / 2), cvPoint(plot_size_x, plot_size_y / 2), y_color); for(int i = -real_size_x / 2; i < real_size_x / 2; ++i) { marker_x = i / real_size_x * plot_size_x + plot_size_x / 2; marker_y = plot_size_y / 2; line(plot, Point(marker_x, marker_y - marker_size), Point(marker_x, marker_y + marker_size), x_color); stringstream sstr; sstr << i; putText(plot, sstr.str(), Point2i(marker_x, marker_y - marker_size * 1.5), FONT_HERSHEY_PLAIN, font_scale, x_color); } for(int i = -real_size_y / 2; i < real_size_y / 2; ++i) { marker_y = i / real_size_y * plot_size_y + plot_size_y / 2; marker_x = plot_size_x / 2; line(plot, Point(marker_x, marker_y - marker_size), Point(marker_x, marker_y + marker_size), y_color); stringstream sstr; sstr << i; putText(plot, sstr.str(), Point2i(marker_x + marker_size * 1.5, marker_y), FONT_HERSHEY_PLAIN, font_scale, y_color); } }
void SamplingIntegrator::renderBlock(const Scene *scene, const Sensor *sensor, Sampler *sampler, ImageBlock *block, const bool &stop, const std::vector< TPoint2<uint8_t> > &points) const { Float diffScaleFactor = 1.0f / std::sqrt((Float) sampler->getSampleCount()); bool needsApertureSample = sensor->needsApertureSample(); bool needsTimeSample = sensor->needsTimeSample(); RadianceQueryRecord rRec(scene, sampler); Point2 apertureSample(0.5f); Float timeSample = 0.5f; RayDifferential sensorRay; block->clear(); uint32_t queryType = RadianceQueryRecord::ESensorRay; if (!sensor->getFilm()->hasAlpha()) /* Don't compute an alpha channel if we don't have to */ queryType &= ~RadianceQueryRecord::EOpacity; for (size_t i = 0; i<points.size(); ++i) { Point2i offset = Point2i(points[i]) + Vector2i(block->getOffset()); if (stop) break; sampler->generate(offset); for (size_t j = 0; j<sampler->getSampleCount(); j++) { rRec.newQuery(queryType, sensor->getMedium()); Point2 samplePos(Point2(offset) + Vector2(rRec.nextSample2D())); if (needsApertureSample) apertureSample = rRec.nextSample2D(); if (needsTimeSample) timeSample = rRec.nextSample1D(); Spectrum spec = sensor->sampleRayDifferential( sensorRay, samplePos, apertureSample, timeSample); sensorRay.scaleDifferential(diffScaleFactor); spec *= Li(sensorRay, rRec); block->put(samplePos, spec, rRec.alpha); sampler->advance(); } } }
void PhysicalObj::SetXY(const Point2d &position) { CheckOverlapping(); // Don't use METER_PER_PIXEL here: bad truncation occurs if (IsOutsideWorldXY(Point2i(position.x, position.y)) && can_be_ghost) { SetPhysXY(position / PIXEL_PER_METER); Ghost(); SignalOutOfMap(); } else { SetPhysXY(position / PIXEL_PER_METER); if (FootsInVacuum()) StartMoving(); } }
ExplosionParticle::ExplosionParticle() : Particle("explosion_particle") { SetCollisionModel(false,false,false); image = ParticleEngine::GetSprite(EXPLOSION_spr); m_initial_time_to_live = image->GetFrameCount(); m_time_left_to_live = m_initial_time_to_live; m_time_between_scale = image->GetCurrentDelay(); image->SetCurrentFrame(0); image->Start(); SetSize( Point2i(1,1) ); }
bool PhysicalObj::PutOutOfGround(Double direction, Double max_distance) { if (IsOutsideWorld(Point2i(0, 0))) return false; if (IsInVacuum(Point2i(0, 0), false)) return true; Double dx = cos(direction); Double dy = sin(direction); // (dx,dy) is a normal vector (cos^2+sin^2==1) Double step=1; while (step<max_distance && !IsInVacuum(Point2i(dx * step, dy * step), false)) step+=1.0; if (step<max_distance) SetXY(Point2i(dx*step + GetX(), dy*step + GetY())); else return false; //Can't put the object out of the ground return true; }
void Mine::Add(int x, int y) { projectile->SetXY(Point2i(x, y)); projectile->SetOverlappingObject(&ActiveCharacter()); // add the character speed if(ActiveCharacter().GetDirection() == 1) projectile->SetSpeed(1.0, -QUARTER_PI); else projectile->SetSpeed(1.0, -THREE * QUARTER_PI); ObjectsList::GetRef().AddObject (projectile); projectile = NULL; ReloadLauncher(); }
BenchmarkMenu::BenchmarkMenu() : Menu("menu/bg_option", vOk) { const Surface& window = GetMainWindow(); tests = new VBox(window.GetWidth()*FACTOR, true, true, true); tests->SetPosition(window.GetSize()* (1.0f - FACTOR)/2); tests->AddWidget(new BenchItem(BENCH_MENU, _("Menu"), 48)); tests->AddWidget(new BenchItem(BENCH_GRAPHICS, _("Graphics"), 48)); graph = new GraphCanvas(Point2i(window.GetWidth(), (window.GetHeight()-50)*FACTOR - 2*(48+5)), _("Time"), _("FPS")); tests->AddWidget(graph); widgets.AddWidget(tests); widgets.Pack(); }
void HaloRefImage::copy_to_tex_aux() { check_resize(); assert(_texture && _texture->image().dims() == Point2i(VIEW::cur_size())); glPushAttrib(GL_ENABLE_BIT); // Specify texture _texture->apply_texture(); // GL_ENABLE_BIT if (use_fbos) { //copy contents of the frame buffer to output texture glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo); // Copies the frame buffer into a texture in gpu texture memory. glCopyTexImage2D( GL_TEXTURE_2D, // The target to which the image data will be changed. 0, // Level of detail, 0 is base detail GL_RGBA, // internal format 0, // x-coord of lower left corner of the window 0, // y-coord of lower left corner of the window _width, // texture width _height, // texture height 0); // border size, must be 0 or 1 glBindFramebuffer(GL_FRAMEBUFFER, 0); } else { //copy contents of the aux0 buffer to output texture glReadBuffer(GL_AUX0); // Copies the frame buffer into a texture in gpu texture memory. glCopyTexImage2D( GL_TEXTURE_2D, // The target to which the image data will be changed. 0, // Level of detail, 0 is base detail GL_RGBA, // internal format 0, // x-coord of lower left corner of the window 0, // y-coord of lower left corner of the window _width, // texture width _height, // texture height 0); // border size, must be 0 or 1 } glPopAttrib(); }
void Label::SetCenter(Point2i centerPoint) { lastPosition = centerPoint; Size2i size = GetTextSize(); Position = Point2i(centerPoint.x, centerPoint.y); if (centerX) Position.x = centerPoint.x - size.width/2; if (centerY) Position.y = centerPoint.y + size.height/2; //if (Position.x < 0 || Position.y < 0) //{ // LOGW(LOGTAG_INPUT,"Attempted to place label outside of screen! (%d,%d)",Position.x,Position.y); // Position = Point2i(0,0); //} }
void WeaponMenuItem::Draw(Surface * dest) { Double scale = DEFAULT_ICON_SCALE; if (zoom || zoom_start_time + GetZoomTime() > GameTime::GetInstance()->Read()) { scale = (GameTime::GetInstance()->Read() - zoom_start_time) / (Double)GetZoomTime(); if (zoom) { scale = DEFAULT_ICON_SCALE + (MAX_ICON_SCALE - DEFAULT_ICON_SCALE) * scale; scale = (scale > MAX_ICON_SCALE ? MAX_ICON_SCALE : scale); } else { scale = MAX_ICON_SCALE - (MAX_ICON_SCALE - DEFAULT_ICON_SCALE) * scale; scale = (scale > DEFAULT_ICON_SCALE ? scale : DEFAULT_ICON_SCALE); } } item->SetAlpha(1); item->Scale(scale, scale); int nb_bullets = ActiveTeam().ReadNbAmmos(weapon->GetType()); Point2i tmp = GetOffsetAlignment() + Point2i(0, item->GetWidth() - 10); char buffer[5] = { 0, }; if (nb_bullets == INFINITE_AMMO) { #define UTF8_INFINITE "\xE2\x88\x9E" PolygonItem::Draw(dest); Font::GetInstance(Font::FONT_MEDIUM, Font::FONT_BOLD)->WriteLeft(tmp, UTF8_INFINITE, dark_gray_color); } else if (nb_bullets == 0) { int num = weapon->AvailableAfterTurn() - (int)Game::GetInstance()->GetCurrentTurn(); if (num > -1){ PolygonItem::Draw(dest); tmp.y -= 4; m_parent->m_not_yet_available->Blit(*dest, tmp); tmp.x += m_parent->m_not_yet_available->GetWidth()-5; tmp.y += 10; snprintf(buffer, 4, "%i ", num); Font::GetInstance(Font::FONT_SMALL, Font::FONT_BOLD)->WriteLeft(tmp, buffer, dark_red_color); } else { item->SetAlpha(0.3); PolygonItem::Draw(dest); } } else { PolygonItem::Draw(dest); std::ostringstream txt; snprintf(buffer, 4, "%i ", nb_bullets); Font::GetInstance(Font::FONT_MEDIUM, Font::FONT_BOLD)->WriteLeft(tmp, buffer, dark_gray_color); } }
bool Blowtorch::p_Shoot() { Point2i hole = ActiveCharacter().GetCenter(); Double angle = ActiveCharacter().GetFiringAngle(); uint h = cfg().range; Double dx = cos(angle) * h; Double dy = sin(angle) * h; Point2i pos = Point2i(hole.x+(int)dx, hole.y+(int)dy); int char_height = ActiveCharacter().GetHeight(); int char_width = ActiveCharacter().GetWidth(); int size = ((int)sqrt(Double(char_height * char_height + char_width * char_width)))/2; GetWorld().Dig(pos, size); JukeBox::GetInstance()->Play("default", "weapon/blowtorch"); return true; }
template<typename I, typename O> int denoiseNLMeans(std::string inputfile, EBitmapType inputtype, std::string outputfile, EBitmapType outputtype, int r = 3, int f = 1, Float k = 0.7, Float sigma = 0.1, bool dump = true) { NLMeansDenoiser<I, O> *denoiser = new NLMeansDenoiser<I, O>(sigma, dump); TBitmap<I> *input = new TBitmap<I>(); if (!input->loadBitmap(inputfile, inputtype)){ std::cout << "Input bitmap " << inputfile << " failed to load!\n"; std::cin.get(); return 0; } DenoiserInput<I> *dInput = new DenoiserInput<I>(outputfile); dInput->addImageBlock(new TImageBlock<I>(Point2i(0., 0.), input->getSize(), 1, false, input)); DenoiserOutput<O> *dOutput = denoiser->denoise(dInput); LOG(EInfo, "Denoising finished. Time taken = %d seconds", dOutput->getDenoiseDuration()); dumpMap(dOutput->getDenoisedImage()->getBitmap(), outputfile, outputtype); input->unloadBitmap(); std::cin.get(); _CrtDumpMemoryLeaks(); // prints mem leaks return 0; }