bool RShape::flipHorizontal() { return mirror(RLine(RVector(0,0), RVector(0,1))); }
void BinaryTree<T>::mirror() { // your code here mirror((*this).root); }
void BinaryTree<T>::mirror() { mirror(root); // your code here }
int match(int n, char array[n][n], char array2[n][n]) { int m=0; if (n==2){ if (compare(n,array,array2)==1) { return 1; } rotate(n, array2, two); if (compare(n,array, two)==1) { return 1; } copy(n,two, two2); rotate(n, two2, two); if (compare(n,array, two)==1) { return 1; } copy(n,two, two2); rotate(n, two, two2); if (compare(n,array, two)==1) { return 1; } copy(n,two, two2); mirror(n, two2, two); if (compare(n,array, two)==1) { return 1; } copy(n,two, two2); rotate(n, two2, two); if (compare(n,array, two)==1) { return 1; } copy(n,two, two2); rotate(n, two2, two); if (compare(n,array, two)==1) { return 1; } copy(n,two, two2); rotate(n, two2, two); if (compare(n,array, two)==1) { return 1; } } else if (n==3){ if (compare(n,array,array2)==1) { return 1; } rotate(n, array2, three); if (compare(n,array, three)==1) { return 1; } copy(n,three, three2); rotate(n, three2, three); if (compare(n,array, three)==1) { return 1; } copy(n,three, three2); rotate(n, three, three2); if (compare(n,array, three)==1) { return 1; } copy(n,three, three2); mirror(n, three2, three); if (compare(n,array, three)==1) { return 1; } copy(n,three, three2); rotate(n, three2, three); if (compare(n,array, three)==1) { return 1; } copy(n,three, three2); rotate(n, three2, three); if (compare(n,array, three)==1) { return 1; } copy(n,three, three2); rotate(n, three2, three); if (compare(n,array, three)==1) { return 1; } } return 0; }
void ofPixels_<PixelType>::rotate90(int nClockwiseRotations){ if (bAllocated == false){ return; } // first, figure out which type of rotation we have int rotation = nClockwiseRotations; while (rotation < 0){ rotation+=4; } rotation %= 4; // if it's 0, do nothing. if it's 2, do it by a mirror operation. if (rotation == 0) { return; // do nothing! } else if (rotation == 2) { mirror(true, true); return; } // otherwise, we will need to do some new allocaiton. int bytesPerPixel = channels; PixelType * oldPixels = pixels; int newWidth = height; int newHeight = width; PixelType * newPixels = new PixelType[newWidth*newHeight*bytesPerPixel]; if(rotation == 1){ for (int i = 0; i < width; i++){ for (int j = 0; j < height; j++){ int pixela = (j*width + i); int pixelb = ((i) * newWidth + (height - j - 1)); for (int k = 0; k < bytesPerPixel; k++){ newPixels[pixelb*bytesPerPixel + k] = oldPixels[pixela*bytesPerPixel + k]; } } } } else if(rotation == 3){ for (int i = 0; i < width; i++){ for (int j = 0; j < height; j++){ int pixela = (j*width + i); int pixelb = ((width-i-1) * newWidth + j); for (int k = 0; k < bytesPerPixel; k++){ newPixels[pixelb*bytesPerPixel + k] = oldPixels[pixela*bytesPerPixel + k]; } } } } delete [] pixels; pixels = newPixels; width = newWidth; height = newHeight; }
uint8 Board::Memory::read(unsigned addr) const { return data[mirror(addr, size)]; }
uint8 Board::chr_read(unsigned addr) { if(chrram.size) return chrram.data[mirror(addr, chrram.size)]; if(chrrom.size) return chrrom.data[mirror(addr, chrrom.size)]; return 0u; }
void TMoveStatic::disp(SDL_Surface *sf, TFont *font, int x, int y, int w, int h, int myfg, int mybg, int xoptions) { int fg = myfg, bg = mybg; char buff[256]; /* Copy the string to allow to modify it without problem */ strcpy(buff,menu->label); char *s = buff; char *old = s; int old_min = min_font_size; min_font_size = 1; font->set_utf(is_utf); int white = mymakecol(255,255,255); // All the translations are taken from http://home.comcast.net/~plotor/command.html while (*s) { if (*s != '_' && *s != '^' && *s != '@') { s++; continue; } char pre = *s; if (s > old) { // Eventually display what's before *s = 0; int w,h; font->dimensions(old,&w,&h); font->surf_string(sf,x,y,old,fg,bg,w); x += w; *s = pre; } s++; font->dimensions("mp",&w,&h); int col = 0; char str[4]; TFont *f0 = NULL; str[0] = *s; str[1] = 0; TSketcher *d = new TSketcher(sf,x,y,w,h,10,9); if (pre == '_') { switch(*s) { case 'A': case 'a': case 'S': case '5': col = mymakecol(255,64,64); break; case 'B': case 'b': col = mymakecol(255,238,0); break; case 'C': case 'c': col = mymakecol(0,255,64); break; case 'D': case 'd': col = mymakecol(0,170,255); break; case 'P': case 'e': col = mymakecol(255,0,170); break; case 'K': case 'Z': case 'f': col = mymakecol(170,0,255); break; case 'g': col = mymakecol(0,255,204); break; case 'i': col = mymakecol(255,160,0); break; case 'G': col = mymakecol(0,170,255); break; case 'H': case 'h': col = mymakecol(255,0,255); break; case 'j': col = mymakecol(190,190,190); break; } if (*s >= 'a' && *s <= 'j') sprintf(str,"%d",*s-'a'+1); else if (*s == 'L') sprintf(str,">>"); // too many drawings !!! else if (*s == 'M') sprintf(str,"<<"); else if (*s == 'X') sprintf(str,"TAP"); else if (*s == '^') sprintf(str,"AIR"); else if (*s == '?') sprintf(str,"DIR"); else if (*s == 'S') sprintf(str,"St"); // tss... else if (*s == '.') sprintf(str,"..."); d->set_filled_poly(1); } else if (pre == '^') { d->set_filled_poly(0); switch (*s) { case 'S': case 'E': col = mymakecol(255,238,0); break; case 's': case 'F': col = mymakecol(255,160,0); break; case 'G': col = mymakecol(255,64,64); break; case 'H': col = mymakecol(190,190,190); break; case 'I': col = mymakecol(0,255,204); break; case 'J': col = mymakecol(0,170,255); break; case 'T': col = mymakecol(170,0,255); break; case 'W': case 'U': col = mymakecol(255,0,170); break; case 'V': col = mymakecol(170,0,255); break; } if (*s >= 'E' && *s <= 'J') { if (has_input(KB_DEF_P1_B6)) { // Street fighter games char *keys[] = { "lp","mp","sp","lk","mk","sk" }; sprintf(str,"%s",keys[*s-'E']); } else sprintf(str,"b%d",*s-'E'+1); // button n for other games } else if (*s == 'T') sprintf(str,"3K"); else if (*s == 'U') sprintf(str,"3P"); else if (*s == 'V') sprintf(str,"2K"); else if (*s == 'W') sprintf(str,"2P"); else if (*s == 'S') sprintf(str,"SE"); // ?! else if (*s == 'M') sprintf(str,"MAX"); } else if (pre == '@') { if (!strncmp(s,"W-button",8)) { sprintf(str,"W"); col = mymakecol(255,238,0); s += 7; } } // I finally keep a constant base width to have all the circles of the // same size... // font->dimensions(str,&w,&h); // w += 2; // some small margin if (col) filledEllipseColor(sf, x+w/2, y+h/2, w/2,h/2, col); if (strlen(str) > 2) { // Try to find a font size which fits in this space ! f0 = font; int h = f0->get_font_height()/2; do { font = new TFont_ttf(h,"VeraMono.ttf"); if (h <= 3) break; int w0,h0; font->dimensions(str,&w0,&h0); if (w0 > w) { h--; delete font; font = NULL; } } while (!font); } // The coordinates below are supposed to be on & 10x9 matrix, except // that the picture I am using has clearly been resized and so it's // only an approximation... // For the arrows they are rotated and mirrored, so I do the rotation/ // mirror instead of risking more errors with more coordinates... Sint16 kx[13] = {1,3,6,4,4,7,7,9,9,7,4,2,2}; Sint16 ky[13] = {3,1,3,3,5,5,3,3,5,7,7,5,3}; Sint16 mkx[13],mky[13]; mirror(13,kx,mkx); mirror(13,ky,mky); Sint16 ox[10] = {1,3,3,5,5,7,7,5,3,3}; Sint16 oy[10] = {6,4,5,5,1,1,5,7,7,8}; Sint16 mox[10],moy[10]; mirror(10,ox,mox); mirror(10,oy,moy); Sint16 wx[16] = {3,1,1,3,6,8,8,10,7,5,7,5,3,3,5,4}; Sint16 wy[16] = {8,6,3,1,1,3,5,5, 7,5,5,3,3,6,7,8},mwx[16],mwy[16]; mirror(16,wx,mwx); mirror(16,wy,mwy); if (pre == '@') { // Very special case, W Button, 1 letter. font->surf_string(sf,x+w/4,y,str,(col ? 0 : fg),bg,w); goto end_loop; } if (*s == '1') d->poly(white, 6,1, 2,6, 1,5, 1,8, 4,8, 3,7, 8,2, -1,-1); else if (*s == '2') d->poly(white, 2,1, 2,6, 1,6, 3,8, 5,6, 4,6, 4,1, -1,-1); else if (*s == '3') d->poly(white, 0,2, 5,8, 4,9, 8,9, 8,5, 7,6, 3,1, -1,-1); else if (*s == '4') d->poly(white, 3,2, 0,5, 3,7, 3,6, 9,6, 9,4, 3,4, -1,-1); else if (*s == '6') d->poly(white, 1,4, 6,4, 6,2, 9,5, 6,7, 6,6, 1,6, -1,-1); else if (*s == '7') d->poly(white, 1,1, 1,5, 2,4, 8,9, 9,7, 4,2, 5,1, -1,-1); else if (*s == '8') d->poly(white, 2,8, 2,3, 1,3, 3,1, 5,3, 4,3, 4,8, -1,-1); else if (*s == '9') d->poly(white, 8,1, 8,5, 7,4, 1,9, 0,7, 5,2, 4,1, -1,-1); else if (*s == 'k') d->polytab(13,kx,ky,white); else if (*s == 'm') // horizontal mirror of k (10-x) d->polytab(13,mkx,ky,white); else if (*s == 'l') // vertical mirror of m (8-y) d->polytab(13,mkx,mky,white); else if (*s == 'n') // horizontal mirror of l (10-x) d->polytab(13,kx,mky,white); else if (*s == 'o') d->polytab(10,ox,oy,white); else if (*s == 'p') d->polytab(10,moy,ox,white); else if (*s == 'q') d->polytab(10,mox,moy,white); else if (*s == 'r') d->polytab(10,oy,mox,white); else if (*s == 's' && pre == '_') d->polytab(10,mox,oy,white); else if (*s == 't') d->polytab(10,oy,ox,white); else if (*s == 'u') d->polytab(10,ox,moy,white); else if (*s == 'v') d->polytab(10,moy,mox,white); else if (*s == 'w') d->polytab(16,wx,wy,white); else if (*s == 'x') d->polytab(16,mwx,mwy,white); else if (*s == 'y') d->polytab(16,wx,mwy,white); else if (*s == 'z') d->polytab(16,mwx,wy,white); else if (*s == 'Q') d->poly(white, 1,1, 1,3, 3,3, 3,4, 1,6, 7,6, 7,7, 9,5, 7,3, 7,4, 4,4, 4,3, 6,1, -1,-1); else if (*s == 'R') // horiz mirror of Q (10-x) d->poly(white, 9,1, 9,3, 7,3, 7,4, 9,6, 3,6, 3,7, 1,5, 3,3, 3,4, 6,4, 6,3, 4,1, -1,-1); else if (*s == '-' && pre == '_') { // not used for any raine game afaik d->lineC(3,1,7,1,white); d->lineC(3,5,5,3,white); d->lineC(5,3,7,5,white); d->lineC(5,3,5,7,white); } else if (*s == '-' && pre == '^') { d->lineC(1,4,6,4,white); d->lineC(6,4,4,2,white); d->lineC(6,4,4,6,white); d->lineC(8,2,8,6,white); } else if (*s == '=' && pre == '^') { d->lineC(1,4,6,4,white); d->lineC(1,4,3,2,white); d->lineC(1,4,3,6,white); d->lineC(8,2,8,6,white); } else if (*s == '`' && pre == '_') { filledCircleColor(sf, x+w/2, y+h/2, w/10, white); } else if (str[1] == 0) { int ws,hs; font->dimensions(str,&ws,&hs); font->surf_string(sf,x+(w-ws)/2,y,str,(col ? 0 : fg),bg,w); } else { int ws,hs; font->dimensions(str,&ws,&hs); font->surf_string(sf,x+(w-ws)/2,y,str,(col ? 0 : fg),bg,w); } if (f0) { delete font; font = f0; } delete d; end_loop: s++; old = s; x += w; } if (*old) font->surf_string(sf,x,y,old,fg,bg,w); min_font_size = old_min; }
bool Magic3D::TGA::decode(DataBuffer* file) { bool result = false; if (file) { if (file->read(&header, sizeof(header)) == 0) { Log::log(eLOG_FAILURE, "Not a TGA"); } bool compressed; switch (header.type){ case TGA_Map: case TGA_RGB: case TGA_Mono: compressed = false; break; case TGA_RLEMap: case TGA_RLERGB: case TGA_RLEMono: compressed = true; break; default: { Log::log(eLOG_FAILURE, "Unknown TGA image type"); return false; } } if (header.width == 0 || header.height == 0 || header.bpp == 0 || header.cmapLength > 256) { Log::log(eLOG_FAILURE, "bad TGA header"); return false; } if (header.bpp != 8 && header.bpp != 15 && header.bpp != 16 && header.bpp != 24 && header.bpp != 32) { Log::log(eLOG_FAILURE, "bad TGA header"); return false; } if (header.idLength > 0) { file->seeki(header.idLength, SEEK_CUR); } create(header.width, header.height, header.bpp); if (isValid()) { if (header.cmapType != 0) { ColorRGBpack pal[256]; file->read(pal, header.cmapLength * sizeof(ColorRGBpack)); for (int i = 0; i < header.cmapLength; i++) { setPaletteColor((byte)i, pal[i].r, pal[i].g, pal[i].b); } } if (header.type == TGA_Mono || header.type == TGA_RLEMono) { setGrayPalette(); } bool xReversed = ((header.desc & 16) == 16); bool yReversed = ((header.desc & 32) == 32); byte* dest; int itY = 0; for (int y = 0; y < header.height; y++){ if (file && !file->eof()) { if (yReversed) { itY = header.height - y - 1; } else { itY = y; } if ((itY >= 0) && (itY <= (int)header.height)) { dest = (byte*)dib + effWidth * itY; if (compressed) { expandCompressedLine(dest, file, header.width); } else { expandUncompressedLine(dest, file, header.width); } } } } if (xReversed) { mirror(); } } } return result; }
/** * Mirrors this vector at the X-axis. */ RVector RVector::flipVertical() { return mirror(RVector(0,0,0), RVector(1,0,0)); }
static void outmap( fint lpt , /* number of points in X */ fint mpt , /* number of points in Y */ fint lmin , /* lower x map coordinate */ fint mmin , /* lower y map coordinate */ fchar set[] , /* set name */ fint sub[] , /* subset levels */ fint nset , /* number of sets */ fint modo ) /* output mode, amp./pha. or cos./sin. */ { fint i, itab, k, m, md, mi, mj, ms, mph, mphh; fint q, r, ri, rj, rs, row; fint n; fint count[MAXSET], nblank[MAXSET]; float rbuf[2*SIZE], cbuf[2*SIZE]; float datamax[MAXSET], datamin[MAXSET]; float fr, fi, zr, zi; for ( k = 0; k < nset; count[k++] = 0 ); if ( FORM == -1 ) { /* complex ---FFT---> real */ k = 0; /* set number */ rs = MIN( mpt, ( 2 * SIZE ) / lpt ); /* number of rows per pass */ for ( r = 0 ; r < mpt; r += rs ) {/* loop to get data from scratch file */ getrow( rbuf, rs * lpt, r / rs ); md = 0; do { m = shiftr( mmin, mpt, r + md ); ms = MIN( rs - md, mpt + mmin - m ); i = md * lpt; writxy( set[k], sub[k], lmin, m, &rbuf[i], lpt, ms ); md = md + ms; } while ( md != rs ); n = lpt * rs; minmax3_c( rbuf, &n, &datamin[k], &datamax[k], &nblank[k], &count[k] ); } } else if ( FORM == 0 ) { /* real ---FFT---> complex */ q = POWTAB[ MAXP2 - LOGP2Y - 1 ]; /* table offset factor */ mph = mpt / 2; /* y-dimension of transform */ mphh = mph / 2 + 1; getrow( cbuf, 2 * lpt, 0 ); /* create row MPH */ putrow( cbuf, 2 * lpt, mph ); fr = 0.5 * SIGN; fi = 0.5; for ( ri = 0; ri < mphh; ri++ ) { rj = mph - ri; itab = ri * q; /* calculate table position */ zr = 0.5 - fr * SINTAB[itab]; zi = fi * COSTAB[itab]; getrow( cbuf, 2 * lpt, ri ); getrow( rbuf, 2 * lpt, rj ); fxrl( zr, zi, cbuf, rbuf, ri, rj, lpt ); /* fixup real ---> complex */ fftx( cbuf ); /* do the FFT in x-direction */ vector( cbuf, lpt, 1, modo ); mi = shiftr( mmin, mpt, ri ); for ( k = 0; k < nset; k++ ) { i = k * lpt; writxy( set[k], sub[k], lmin, mi, &cbuf[i], lpt , 1 ); minmax3_c( &cbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k], &count[k] ); } if ( ri > 0 ) { /* do not double lines */ mirror( cbuf, lpt, -lmin ); mi = shiftr( mmin, mpt, mpt - ri ); for ( k = 0; k < nset; k++ ) { i = k * lpt; writxy( set[k], sub[k], lmin, mi, &cbuf[i], lpt, 1 ); minmax3_c( &cbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k], &count[k] ); } } if ( ri == rj ) break; /* we've done it */ fftx( rbuf ); /* do the FFT in x-direction */ vector( rbuf, lpt, 1, modo ); mj = shiftr( mmin, mpt, rj ); for ( k = 0; k < nset; k++ ) { i = k * lpt; writxy( set[k], sub[k], lmin, mj, &rbuf[i], lpt, 1 ); minmax3_c( &rbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k], &count[k] ); } if ( rj < mph ) { /* do not double lines */ mirror( rbuf, lpt, -lmin ); mj = shiftr( mmin, mpt, mpt - rj ); for ( k = 0; k < nset; k++ ) { i = k * lpt; writxy( set[k], sub[k], lmin, mj, &rbuf[i], lpt, 1 ); minmax3_c( &rbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k], &count[k] ); } } } } else if ( FORM == 1 ) { /* complex ---FFT---> complex */ for ( row = 0; row < mpt; row++ ) { getrow( cbuf, 2 * lpt, row ); vector( cbuf, lpt, 1, modo ); m = shiftr( mmin, mpt, row ); for ( k = 0; k < nset; k++ ) { i = k * lpt; writxy( set[k], sub[k], lmin, m, &cbuf[i], lpt, 1 ); minmax3_c( &cbuf[i], &lpt, &datamin[k], &datamax[k], &nblank[k], &count[k] ); } } } { fint change = 1; fint one = 1; for ( k = 0; k < nset; k++ ) { wminmax_c( set[k], &sub[k], &datamin[k], &datamax[k], &nblank[k], &one, &change ); } } }
/** * Mirrors this vector at the Y-axis. */ RVector RVector::flipHorizontal() { return mirror(RVector(0,0,0), RVector(0,1,0)); }
RVector RVector::mirror(const RVector& axis1, const RVector& axis2) { return mirror(RLine(axis1, axis2)); }
bool RShape::flipVertical() { return mirror(RLine(RVector(0,0), RVector(1,0))); }
void ImageView::reload() { if (GData::enableImageInfoFS) { if (currentImageFullPath.left(1) == ":") { setInfo("No Image"); } else if (currentImageFullPath.isEmpty()) { setInfo("Clipboard"); } else { setInfo(QFileInfo(currentImageFullPath).fileName()); } } if (!GData::keepTransform) { GData::cropLeftPercent = GData::cropTopPercent = GData::cropWidthPercent = GData::cropHeightPercent = 0; GData::rotation = 0; GData::flipH = GData::flipV = false; } GData::scaledWidth = GData::scaledHeight = 0; GData::cropLeft = GData::cropTop = GData::cropWidth = GData::cropHeight = 0; if (newImage || currentImageFullPath.isEmpty()) { newImage = true; currentImageFullPath = CLIPBOARD_IMAGE_NAME; origImage.load(":/images/no_image.png"); displayImage = origImage; displayPixmap = QPixmap::fromImage(displayImage); imageLabel->setPixmap(displayPixmap); pasteImage(); mainWindow->setWindowTitle(tr("Clipboard") + " - Phototonic"); isAnimation = false; return; } imageReader.setFileName(currentImageFullPath); isAnimation = GData::enableAnimations? imageReader.supportsAnimation() : false; if (isAnimation) { if (anim) { delete anim; } anim = new QMovie(currentImageFullPath); imageLabel->setMovie(anim); anim->start(); } else { if (imageReader.size().isValid()) { origImage.load(currentImageFullPath); displayImage = origImage; transform(); if (GData::colorsActive || GData::keepTransform) { colorize(); } if (mirrorLayout) { mirror(); } displayPixmap = QPixmap::fromImage(displayImage); } else { displayPixmap = QIcon::fromTheme("image-missing", QIcon(":/images/error_image.png")).pixmap(128, 128); } imageLabel->setPixmap(displayPixmap); } resizeImage(); }
segment2<T> mirror( const segment2<T>& target, const line2<T>& over ) { return segment2<T>{ mirror( target.pt1, over ), mirror( target.pt2, over ) }; }
void GenEcho::step() { // Implement a simple sine oscillator //float deltaTime = engineGetSampleTime(); float amp_out = 0.0; // handle the 3 switches for accumlating and mirror toggle // and probability distrobution selection is_accumulating = (int) params[ACCM_PARAM].value; is_mirroring = (int) params[MIRR_PARAM].value; dt = (DistType) params[PDST_PARAM].value; // read in cv vals for astp, dstp and bpts bpts_sig = 5.f * quadraticBipolar((inputs[BPTS_INPUT].value / 5.f) * params[BPTSCV_PARAM].value); astp_sig = quadraticBipolar((inputs[ASTP_INPUT].value / 5.f) * params[ASTPCV_PARAM].value); dstp_sig = quadraticBipolar((inputs[DSTP_INPUT].value / 5.f) * params[DSTPCV_PARAM].value); max_amp_step = rescale(params[ASTP_PARAM].value + (astp_sig / 4.f), 0.0, 1.0, 0.05, 0.3); max_dur_step = rescale(params[DSTP_PARAM].value + (dstp_sig / 4.f), 0.0, 1.0, 0.01, 0.3); sample_length = (int) (clamp(params[SLEN_PARAM].value, 0.1, 1.f) * MAX_SAMPLE_SIZE); bpt_spc = (unsigned int) params[BPTS_PARAM].value + 800; bpt_spc += (unsigned int) rescale(bpts_sig, -1.f, 1.f, 1.f, 200.f); num_bpts = sample_length / bpt_spc + 1; env_dur = bpt_spc / 2; // snap knob for selecting envelope for the grain int env_num = (int) clamp(roundf(params[ENVS_PARAM].value), 1.0f, 4.0f); if (env.et != (EnvType) env_num) { env.switchEnvType((EnvType) env_num); } // handle sample reset if (smpTrigger.process(params[TRIG_PARAM].value) || resetTrigger.process(inputs[RSET_INPUT].value / 2.f)) { for (unsigned int i=0; i<MAX_SAMPLE_SIZE; i++) sample[i] = _sample[i]; for (unsigned int i=0; i<MAX_BPTS; i++) { mAmps[i] = 0.f; mDurs[i] = 1.f; } } // handle sample trigger through gate if (g2Trigger.process(inputs[GATE_INPUT].value / 2.f)) { // reset accumulated breakpoint vals for (unsigned int i=0; i<MAX_BPTS; i++) { mAmps[i] = 0.f; mDurs[i] = 1.f; } num_bpts = sample_length / bpt_spc; sampling = true; idx = 0; s_i = 0; } if (sampling) { if (s_i >= MAX_SAMPLE_SIZE - 50) { float x,y,p; x = sample[s_i-1]; y = sample[0]; p = 0.f; while (s_i < MAX_SAMPLE_SIZE) { sample[s_i] = (x * (1-p)) + (y * p); p += 1.f / 50.f; s_i++; } debug("Finished sampling"); sampling = false; } else { sample[s_i] = inputs[WAV0_INPUT].value; _sample[s_i] = sample[s_i]; s_i++; } } if (phase >= 1.0) { phase -= 1.0; amp = amp_next; index = (index + 1) % num_bpts; // adjust vals astp = max_amp_step * rg.my_rand(dt, randomNormal()); dstp = max_dur_step * rg.my_rand(dt, randomNormal()); if (is_mirroring) { mAmps[index] = mirror((is_accumulating ? mAmps[index] : 0.f) + astp, -1.0f, 1.0f); mDurs[index] = mirror(mDurs[index] + (dstp), 0.5, 1.5); } else { mAmps[index] = wrap((is_accumulating ? mAmps[index] : 0.f) + astp, -1.0f, 1.0f); mDurs[index] = wrap(mDurs[index] + dstp, 0.5, 1.5); } amp_next = mAmps[index]; // step/adjust grain sample offsets g_idx = g_idx_next; g_idx_next = 0.0; } // change amp in sample buffer sample[idx] = wrap(sample[idx] + (amp * env.get(g_idx)), -5.f, 5.f); amp_out = sample[idx]; idx = (idx + 1) % sample_length; g_idx = fmod(g_idx + (1.f / (4.f * env_dur)), 1.f); g_idx_next = fmod(g_idx_next + (1.f / (4.f * env_dur)), 1.f); phase += 1.f / (mDurs[index] * bpt_spc); // get that amp OUT outputs[SINE_OUTPUT].value = amp_out; }
line2<T> mirror( const line2<T>& target, const line2<T>& over ) { return line2<T>{ mirror( target.start_pt( ), over ), mirror( target.end_pt( ), over ) }; }
void Board::Memory::write(unsigned addr, uint8 byte) { if(writable) data[mirror(addr, size)] = byte; }
void NeuralNetwork::mirror() { mirror(front()); }
void Board::chr_write(unsigned addr, uint8 data) { if(chrram.size) chrram.data[mirror(addr, chrram.size)] = data; }
void mainLevel(RenderWindow &window) { //>>>>>>>>>>>>>>>---Level---<<<<<<<<<<<<<<<<<<<<<<<<<<< Level lvl; lvl.LoadFromFile("map.tmx"); //>>>>>>>>>>>>>>>>---Load basic image for level1----<<<<<<<<<<<<<<<<< Texture texture; texture.loadFromFile("images/level1empty.jpg"); Sprite level(texture); Texture texture2; texture2.loadFromFile("images/levelShad.png"); Sprite level2(texture2); Texture texture3; texture3.loadFromFile("images/level12.png"); Sprite level3(texture3); //>>>>>>>>>>>>>>>>---Music---<<<<<<<<<<<<<<<<<<<<<<<<<< Music mainSong; mainSong.openFromFile("music/level1.ogg"); mainSong.play(); mainSong.setLoop(true); mainSong.setVolume(75); //>>>>>>>>>>>>>>>>---Create a cat---<<<<<<<<<<<<<<<<<<< Object player = lvl.GetObject("cat"); Player cat("cat.png", lvl, player.rect.left, player.rect.top, 60, 120, 55, 25); Clock clock; //>>>>>>>>>>>>>>>>---Sounds----<<<<<<<<<<<<<<<<<<< SoundBuffer buf1, buf2; buf1.loadFromFile("music/meow1.ogg"); buf2.loadFromFile("music/meow2.ogg"); Sound meow1, meow2; meow1.setBuffer(buf1); meow2.setBuffer(buf2); SoundBuffer buf; buf.loadFromFile("music/steklo.ogg"); Sound glass; glass.setBuffer(buf); glass.setVolume(100); //Objects Furniture posters("tayles1.png", 160, 660, 210, 250, 280, 215); Furniture bed("tayles1.png", 420, 80, 280, 310, 250, 440); Furniture toys("tayles1.png", 120, 470, 180, 150, 220, 545); Furniture upShelf("tayles1.png", 700, 652.5, 120, 97.5, 350, 83); Furniture cabinet("tayles1.png", 75, 40, 250, 350, 605, 305); Furniture mop("tayles1.png", 515, 785, 165, 241, 587, 385); Furniture flower("tayles1.png",780, 65, 170, 330, 147, 285); Furniture ball("tayles1.png", 905, 615, 40, 55, 357, 190); Furniture books("tayles1.png", 860, 735, 125, 80, 290, 187); Furniture brokenBall("tayles1.png",920, 540, 90, 42, 430, 430); Furniture door("tayles2.png", 0, 560, 80, 340, 870, 350); Furniture brokenLight("tayles2.png", 10, 110, 50, 70, 795, 430); Furniture light("tayles2.png", 20, 20, 35, 70, 220, 565); Furniture bath("tayles2.png", 80, 50, 320, 380, 1010, 330); Furniture carpet("tayles2.png", 100, 500, 100, 140, 870, 530); Furniture mirror("tayles2.png", 90, 700, 110, 290, 1200, 300); Furniture sink("tayles2.png", 290, 440, 150, 240, 1190, 450); int cntMeow = 0; Object ob = lvl.GetObject("catPlace"); while (window.isOpen()) { float time = clock.getElapsedTime().asMicroseconds(); clock.restart(); time = time/500; Vector2i pos = Mouse::getPosition(window); Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if (event.type == Event::MouseButtonPressed){ if (event.key.code == Mouse::Left) { int cntMeow = meow(meow1, meow2, cat, pos); //>>>>>>BALL<<<<<<<<<<<<<< if(cat.sprite.getGlobalBounds().intersects(ob.rect)) { if(cntMeow == -1) { ball.falling(event, window, pos, lvl, time); glass.play(); ball.moving(event, window, pos, "ball", lvl); } } cat.clickedThings(window, light); //BOOKS>>>>----<<<<<< if(books.isPlayed == false) { if (books.sprite.getGlobalBounds().contains(pos.x, pos.y)) { mainSong.pause(); MiniGame_Books(); books.isPlayed = true; mainSong.play(); } } } } toys.moving(event, window, pos, "toys", lvl); if(light.isPlayed == false) light.moving(event, window, pos, "light", lvl); } cat.Update(time); window.clear(Color::Black); lvl.Draw(window); if(cat.room == 0) window.draw(level); if(cat.room == 1) window.draw(level2); if(cat.room == 2) window.draw(level3); window.draw(posters.sprite); window.draw(bed.sprite); window.draw(light.sprite); window.draw(toys.sprite); window.draw(upShelf.sprite); window.draw(cabinet.sprite); window.draw(mop.sprite); window.draw(flower.sprite); if(ball.isPlayed == false) window.draw(ball.sprite); else window.draw(brokenBall.sprite); window.draw(books.sprite); if(cat.room == 2){ window.draw(bath.sprite); window.draw(mirror.sprite); window.draw(sink.sprite); } if(cat.room == 1 || cat.room == 2){ if(light.isPlayed == false) window.draw(brokenLight.sprite); window.draw(carpet.sprite); window.draw(door.sprite); } window.draw(cat.sprite); window.display(); } }
Main::Main(QCanvas& c, QWidget* parent, const char* name, WFlags f) : QMainWindow(parent,name,f), canvas(c) { editor = new FigureEditor(canvas,this); // 繼承canvas view而來 QMenuBar* menu = menuBar(); QPopupMenu* file = new QPopupMenu( menu ); // 當parent被刪除,則子類別也會被刪除 file->insertItem("&Fill canvas", this, SLOT(init()), CTRL+Key_F); file->insertItem("&Erase canvas", this, SLOT(clear()), CTRL+Key_E); file->insertItem("&New view", this, SLOT(newView()), CTRL+Key_N); file->insertSeparator(); file->insertItem("&Print...", this, SLOT(print()), CTRL+Key_P); file->insertSeparator(); file->insertItem("E&xit", qApp, SLOT(quit()), CTRL+Key_Q); menu->insertItem("&File", file); // 建立一個工具列名為File的label QPopupMenu* edit = new QPopupMenu( menu ); edit->insertItem("Add &Circle", this, SLOT(addCircle()), ALT+Key_C); edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), ALT+Key_H); edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), ALT+Key_P); edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), ALT+Key_I); edit->insertItem("Add &Text", this, SLOT(addText()), ALT+Key_T); edit->insertItem("Add &Line", this, SLOT(addLine()), ALT+Key_L); edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), ALT+Key_R); edit->insertItem("Add &Sprite", this, SLOT(addSprite()), ALT+Key_S); edit->insertItem("Create &Mesh", this, SLOT(addMesh()), ALT+Key_M ); edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), ALT+Key_A); menu->insertItem("&Edit", edit); QPopupMenu* view = new QPopupMenu( menu ); view->insertItem("&Enlarge", this, SLOT(enlarge()), SHIFT+CTRL+Key_Plus); view->insertItem("Shr&ink", this, SLOT(shrink()), SHIFT+CTRL+Key_Minus); view->insertSeparator(); view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), CTRL+Key_PageDown); view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), CTRL+Key_PageUp); view->insertItem("&Zoom in", this, SLOT(zoomIn()), CTRL+Key_Plus); view->insertItem("Zoom &out", this, SLOT(zoomOut()), CTRL+Key_Minus); view->insertItem("Translate left", this, SLOT(moveL()), CTRL+Key_Left); view->insertItem("Translate right", this, SLOT(moveR()), CTRL+Key_Right); view->insertItem("Translate up", this, SLOT(moveU()), CTRL+Key_Up); view->insertItem("Translate down", this, SLOT(moveD()), CTRL+Key_Down); view->insertItem("&Mirror", this, SLOT(mirror()), CTRL+Key_Home); menu->insertItem("&View", view); options = new QPopupMenu( menu ); dbf_id = options->insertItem("Double buffer", this, SLOT(toggleDoubleBuffer())); options->setItemChecked(dbf_id, TRUE); menu->insertItem("&Options",options); menu->insertSeparator(); QPopupMenu* help = new QPopupMenu( menu ); help->insertItem("&About", this, SLOT(help()), Key_F1); help->setItemChecked(dbf_id, TRUE); // 很奇怪,當TRUE時,把dbf_id打勾,不懂 menu->insertItem("&Help",help); statusBar(); // 返回這個窗口的狀態條。如果沒有的話 // statusBar()會創建一個空的狀態條,並且如果需要也創建一個工具提示組。 setCentralWidget(editor); printer = 0; init(); }
int main(int argc, char* argv[]) { // Build your scene and setup your camera here, by calling // functions from Raytracer. The code here sets up an example // scene and renders it from two different view points, DO NOT // change this if you're just implementing part one of the // assignment. Raytracer raytracer; int width = 320; int height = 240; if (argc == 3) { width = atoi(argv[1]); height = atoi(argv[2]); } /***********************************************************Testing ******************************** // Camera parameters. Point3D eye(0, 0, 1); Vector3D view(0, 0, -1); Vector3D up(0, 1, 0); double fov = 60; // Defines a material for shading. Material gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648), Colour(0.628281, 0.555802, 0.366065), 51.2,0.3,0,NULL ); Material jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63), Colour(0.316228, 0.316228, 0.316228), 12.8,0.3,0,NULL); // Defines a point light source. raytracer.addLightSource( new PointLight(Point3D(0.0, 0, 5), Colour(0.9, 0.9, 0.9) ) ); // Add a unit square into the scene with material mat. SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &gold ); SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade ); // Apply some transformations to the unit square. double factor1[3] = { 1.0, 2.0, 1.0 }; double factor2[3] = { 6.0, 6.0, 6.0 }; raytracer.translate(sphere, Vector3D(0, 0, -5)); raytracer.rotate(sphere, 'x', -45); raytracer.rotate(sphere, 'z', 45); raytracer.scale(sphere, Point3D(0, 0, 0), factor1); raytracer.translate(plane, Vector3D(0, 0, -7)); raytracer.rotate(plane, 'z', 45); raytracer.scale(plane, Point3D(0, 0, 0), factor2); // Render the scene, feel free to make the image smaller for // testing purposes. raytracer.render(width, height, eye, view, up, fov, "view4.bmp"); // Render it from a different point of view. Point3D eye2(4, 2, 1); Vector3D view2(-4, -2, -6); raytracer.render(width, height, eye2, view2, up, fov, "view5.bmp"); ***********************************************************Testing ********************************/ /***********************************************************Final Scene********************************/ // Camera parameters. // Point3D eye(0, 8, -3); // Vector3D view(0, -1,0); Point3D eye(0, 0, 1); Vector3D view(0, 0, -1); Vector3D up(0, 1, 0); double fov = 60; // Defines a material for shading. Material gold( Colour(0.3, 0.3, 0.3), Colour(0.75164, 0.60648, 0.22648), Colour(0.628281, 0.555802, 0.366065), 51.2,0.2,NULL); // Material jade( Colour(0, 0, 0), Colour(0.54, 0.89, 0.63), // Colour(0.316228, 0.316228, 0.316228), // 12.8,0.5,NULL); Material jade( Colour(0, 0, 0), Colour(0.47, 0.576, 0.859), Colour(0.316228, 0.316228, 0.316228), 12.8,0.5,NULL); Material red( Colour(0.3, 0.3, 0.3), Colour(1, 0, 0), Colour(0.628281, 0.555802, 0.366065), 51.2,0.2,NULL); Material white( Colour(0.3, 0.3, 0.3), Colour(1, 0.8549, 0.7255), Colour(0.628281, 0.555802, 0.366065), 51.2,0.2,NULL); Material pink( Colour(0.3, 0.3, 0.3), Colour(0.9412, 0.502, 0.502), Colour(0.628281, 0.555802, 0.366065), 51.2,0.2,NULL); Material mirror( Colour(0.0, 0.0, 0.0), Colour(0.0, 0.0, 0.0), Colour(0.0, 0.0, 0.0), 51.2,1,NULL); Material glass( Colour(0.3, 0.3, 0.3), Colour(1, 1, 1), Colour(0.628281, 0.555802, 0.366065), 51.2,0,1,NULL); glass.R_index = 1.3; glass.transparency_coef=1; // Defines a point light source. raytracer.addLightSource( new PointLight(Point3D(0, 0, 5), Colour(0.9, 0.9, 0.9) ) ); raytracer.addLightSource( new PointLight(Point3D(0, 6, -1), Colour(0.9, 0.3, 0.1) ) ); Material test( Colour(0.3, 0.3, 0.3), Colour(0.3, 0.60648, 0.22648), Colour(0.628281, 0.555802, 0.366065), 51.2 ,0.1,NULL); Material test3( Colour(0.3, 0.3, 0.3), Colour(0.3, 0.5, 0.22648), Colour(0.628281, 0.555802, 0.366065), 51.2,1,NULL ); Material test2( Colour(0, 0, 0), Colour(0.3, 0.3, 0.3), Colour(1.0, 1.0, 1.0), 51.2,0,NULL ); Texture sky("/Users/bingxu/Documents/graphics/COMP3271_assignment_4_template/raytracerMacOS/sky.bmp"); Texture board("/Users/bingxu/Documents/graphics/COMP3271_assignment_4_template/raytracerMacOS/board.bmp"); Material starrysky(Colour(0, 0, 0),Colour(0, 0, 0), Colour(0.1, 0.1, 0.1), 11.264, 0, &sky); Material board_mat(Colour(0, 0, 0),Colour(0, 0, 0), Colour(0.1, 0.1, 0.1), 11.264, 1, &board); SceneDagNode* plane = raytracer.addObject( new UnitSquare(), &jade ); SceneDagNode* plane1 = raytracer.addObject( new UnitSquare(), &jade ); SceneDagNode* plane2 = raytracer.addObject( new UnitSquare(), &board_mat );//the bottom SceneDagNode* sphere = raytracer.addObject( new UnitSphere(), &mirror); SceneDagNode* sphere1 = raytracer.addObject( new UnitSphere(), &white ); SceneDagNode* mars = raytracer.addObject( new UnitSphere(), &glass ); SceneDagNode* earth = raytracer.addObject( new UnitSphere(), &pink ); SceneDagNode* cylinder1 = raytracer.addObject( new UnitFiniteCylinder(), &gold ); SceneDagNode* cylinder2 = raytracer.addObject( new UnitFiniteCylinder(), &gold ); SceneDagNode* cylinder3 = raytracer.addObject( new UnitFiniteCylinder(), &gold ); SceneDagNode* cone = raytracer.addObject( new UnitFiniteCone(), &red ); double factor1[3] = { 2.0, 2.0, 2.0 }; double factor2[3] = {50,50,50}; double factor3[3] = { 1.0, 1.0, 1.0}; double factor4[3] = { 1.0, 2, 1.0}; double factor5[3] = {0.5,0.5,0.5}; double factor6[3] = {0.5,1.5,0.5}; double factor7[3] = {1.0,4.0,1.0}; //3 squares raytracer.translate(plane, Vector3D(0, 0, -15)); raytracer.scale(plane, Point3D(0, 0, 0), factor2); raytracer.translate(plane1, Vector3D(-15, 0, 0)); raytracer.rotate(plane1, 'y', 90); raytracer.scale(plane1, Point3D(0, 0, 0), factor2); raytracer.translate(plane2, Vector3D(0, -8, 0)); raytracer.rotate(plane2, 'x', -90); raytracer.scale(plane2, Point3D(0, 0, 0), factor2); //four balls raytracer.translate(sphere, Vector3D(-1, -6, -2)); raytracer.scale(sphere, Point3D(0, 0, 0), factor3); raytracer.translate(sphere1,Vector3D(-4.5, -6, 1)); raytracer.scale(sphere1, Point3D(0, 0, 0), factor3); raytracer.translate(mars, Vector3D(3, -3, -1)); raytracer.scale(mars, Point3D(0, 0, 0), factor3); raytracer.translate(earth, Vector3D(-8, -6, -2)); raytracer.scale(earth, Point3D(0, 0, 0), factor3); raytracer.rotate(cylinder1, 'z', -30); //raytracer.rotate(cylinder1, 'x', -15); raytracer.translate(cylinder1, Vector3D(0, -4, -2)); raytracer.scale(cylinder1, Point3D(0, 0, 0), factor7); raytracer.rotate(cylinder2, 'z', -30); raytracer.translate(cylinder2, Vector3D(1.5, -3, -2)); raytracer.scale(cylinder2, Point3D(0, 0, 0), factor6); raytracer.rotate(cylinder3, 'z', -30); raytracer.translate(cylinder3, Vector3D(-1.5, -3, -2)); raytracer.scale(cylinder3, Point3D(0, 0, 0), factor6); raytracer.rotate(cone, 'z', -30); raytracer.translate(cone, Vector3D(0, 2, -2)); raytracer.scale(cone, Point3D(0, 0, 0), factor4); std::clock_t start; double duration; start = std::clock(); // raytracer.render(width, height, eye, view, up, fov, "view4.bmp"); duration = ( std::clock() - start ) / (double) CLOCKS_PER_SEC; //std::cout<<"The rendering duration 1 is .......: "<< duration <<'\n'; // Render it from a different point of view. Point3D eye2(3, 1, 5); Vector3D view2(-10, -8, -15); std::clock_t start1; double duration1; start1 = std::clock(); raytracer.render(width, height, eye2, view2, up, fov, "view5.bmp"); duration1 = ( std::clock() - start1 ) / (double) CLOCKS_PER_SEC; // std::cout<<"The rendering duration 2 is .......: "<< duration1 <<'\n'; /***********************************************************Final Scene********************************/ return 0; }
MainWindow::MainWindow(const QString& initialFilename, QWidget *parent) : QMainWindow(parent), m_appSettings("OpenSource", "Sproxel"), m_activeFilename(""), m_project(new SproxelProject()) { // Project VoxelGridGroupPtr sprite(new VoxelGridGroup(Imath::V3i(DEFAULT_VOXGRID_SZ, DEFAULT_VOXGRID_SZ, DEFAULT_VOXGRID_SZ), ColorPalettePtr())); sprite->setName("unnamed"); m_project->sprites.push_back(sprite); // Windows m_glModelWidget = new GLModelWidget(this, &m_appSettings, &m_undoManager, sprite); setCentralWidget(m_glModelWidget); // The docking palette widget m_paletteDocker = new QDockWidget(tr("Palette"), this); m_paletteDocker->setObjectName("paletteDocker"); m_paletteDocker->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_paletteWidget = new PaletteWidget(this, &m_undoManager); m_paletteDocker->setWidget(m_paletteWidget); m_paletteWidget->setPalette(m_project->mainPalette); addDockWidget(Qt::RightDockWidgetArea, m_paletteDocker); // The docking project widget m_projectDocker=new QDockWidget(tr("Project"), this); m_projectDocker->setObjectName("projectDocker"); m_projectWidget=new ProjectWidget(this, &m_undoManager, &m_appSettings); m_projectDocker->setWidget(m_projectWidget); m_projectWidget->setProject(m_project); addDockWidget(Qt::RightDockWidgetArea, m_projectDocker); // The docking layers widget //m_layersDocker = new QDockWidget(tr("Layers"), this); //m_layersDocker->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); //m_layersWidget = new LayersWidget(this); //m_layersDocker->setWidget(m_layersWidget); //addDockWidget(Qt::RightDockWidgetArea, m_layersDocker); // Connect some window signals together QObject::connect(m_paletteWidget, SIGNAL(activeColorChanged(Imath::Color4f, int)), m_glModelWidget, SLOT(setActiveColor(Imath::Color4f, int))); QObject::connect(m_glModelWidget, SIGNAL(colorSampled(Imath::Color4f, int)), m_paletteWidget, SLOT(setActiveColor(Imath::Color4f, int))); QObject::connect(&m_undoManager, SIGNAL(cleanChanged(bool)), this, SLOT(reactToModified(bool))); QObject::connect(m_projectWidget, SIGNAL(spriteSelected(VoxelGridGroupPtr)), m_glModelWidget, SLOT(setSprite(VoxelGridGroupPtr))); // Toolbar m_toolbar = new QToolBar("Tools", this); m_toolbar->setObjectName("toolbar"); m_toolbar->setOrientation(Qt::Vertical); addToolBar(Qt::LeftToolBarArea, m_toolbar); // Actions & Menus menuBar()->show(); m_menuFile = menuBar()->addMenu("Fi&le"); m_actFileNew = new QAction("&New", this); m_actFileNew->setShortcut(Qt::CTRL + Qt::Key_N); m_menuFile->addAction(m_actFileNew); connect(m_actFileNew, SIGNAL(triggered()), this, SLOT(newGrid())); m_menuFile->addSeparator(); m_actFileOpen = new QAction("&Open", this); m_actFileOpen->setShortcut(Qt::CTRL + Qt::Key_O); m_menuFile->addAction(m_actFileOpen); connect(m_actFileOpen, SIGNAL(triggered()), this, SLOT(openFile())); m_actFileSave = new QAction("&Save", this); m_actFileSave->setShortcut(Qt::CTRL + Qt::Key_S); m_menuFile->addAction(m_actFileSave); connect(m_actFileSave, SIGNAL(triggered()), this, SLOT(saveFile())); m_actFileSaveAs = new QAction("Save &As", this); m_menuFile->addAction(m_actFileSaveAs); connect(m_actFileSaveAs, SIGNAL(triggered()), this, SLOT(saveFileAs())); m_menuFile->addSeparator(); m_actFileImport = new QAction("&Import...", this); m_menuFile->addAction(m_actFileImport); connect(m_actFileImport, SIGNAL(triggered()), this, SLOT(import())); m_actFileExportGrid = new QAction("&Export...", this); m_menuFile->addAction(m_actFileExportGrid); connect(m_actFileExportGrid, SIGNAL(triggered()), this, SLOT(exportGrid())); m_menuFile->addSeparator(); m_actQuit = new QAction("&Quit", this); m_actQuit->setShortcut(Qt::CTRL + Qt::Key_Q); m_menuFile->addAction(m_actQuit); connect(m_actQuit, SIGNAL(triggered()), this, SLOT(close())); // ------ edit menu m_menuEdit = menuBar()->addMenu("&Edit"); m_actUndo=m_undoManager.createUndoAction(this, "Undo"); m_actUndo->setShortcut(Qt::CTRL + Qt::Key_Z); m_menuEdit->addAction(m_actUndo); m_actRedo=m_undoManager.createRedoAction(this, "Redo"); m_actRedo->setShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Z); m_menuEdit->addAction(m_actRedo); m_menuEdit->addSeparator(); m_actShiftUp = new QAction("Shift up", this); m_actShiftUp->setShortcut(Qt::CTRL + Qt::Key_BracketRight); m_menuEdit->addAction(m_actShiftUp); connect(m_actShiftUp, SIGNAL(triggered()), this, SLOT(shiftUp())); m_actShiftDown = new QAction("Shift down", this); m_actShiftDown->setShortcut(Qt::CTRL + Qt::Key_BracketLeft); m_menuEdit->addAction(m_actShiftDown); connect(m_actShiftDown, SIGNAL(triggered()), this, SLOT(shiftDown())); m_actShiftWrap = new QAction("Wrap shift ops", this); m_actShiftWrap->setCheckable(true); m_actShiftWrap->setChecked(m_glModelWidget->shiftWrap()); m_menuEdit->addAction(m_actShiftWrap); connect(m_actShiftWrap, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setShiftWrap(bool))); m_actRotateCw = new QAction("Rotate clockwise", this); m_actRotateCw->setShortcut(Qt::CTRL + Qt::Key_Greater); m_menuEdit->addAction(m_actRotateCw); connect(m_actRotateCw, SIGNAL(triggered()), this, SLOT(rotateCw())); m_actRotateCcw = new QAction("Rotate counter-clockwise", this); m_actRotateCcw->setShortcut(Qt::CTRL + Qt::Key_Less); m_menuEdit->addAction(m_actRotateCcw); connect(m_actRotateCcw, SIGNAL(triggered()), this, SLOT(rotateCcw())); m_actMirror = new QAction("Mirror", this); m_actMirror->setShortcut(Qt::CTRL + Qt::Key_M); m_menuEdit->addAction(m_actMirror); connect(m_actMirror, SIGNAL(triggered()), this, SLOT(mirror())); m_menuEdit->addSeparator(); m_actPreferences = new QAction("Preferences...", this); m_menuEdit->addAction(m_actPreferences); connect(m_actPreferences, SIGNAL(triggered()), this, SLOT(editPreferences())); // ------ grid menu m_menuGrid = menuBar()->addMenu("&Grid"); m_actExtendUp = new QAction("Extend grid dimension up", this); m_actExtendUp->setShortcut(Qt::CTRL + Qt::Key_Plus); m_menuGrid->addAction(m_actExtendUp); connect(m_actExtendUp, SIGNAL(triggered()), this, SLOT(extendUp())); m_actExtendDown = new QAction("Extend grid dimension down", this); m_actExtendDown->setShortcut(Qt::CTRL + Qt::Key_Minus); m_menuGrid->addAction(m_actExtendDown); connect(m_actExtendDown, SIGNAL(triggered()), this, SLOT(extendDown())); m_actContractUp = new QAction("Contract grid dimension from above", this); m_menuGrid->addAction(m_actContractUp); connect(m_actContractUp, SIGNAL(triggered()), this, SLOT(contractUp())); m_actContractDown = new QAction("Contract grid dimension from below", this); m_menuGrid->addAction(m_actContractDown); connect(m_actContractDown, SIGNAL(triggered()), this, SLOT(contractDown())); m_menuGrid->addSeparator(); m_actUpRes = new QAction("Double grid resolution", this); m_menuGrid->addAction(m_actUpRes); connect(m_actUpRes, SIGNAL(triggered()), this, SLOT(upRes())); m_actDownRes = new QAction("Half grid resolution", this); m_menuGrid->addAction(m_actDownRes); connect(m_actDownRes, SIGNAL(triggered()), this, SLOT(downRes())); // ------ view menu m_menuView = menuBar()->addMenu("&View"); QAction *action=new QAction(tr("Frame sprite"), this); action->setShortcut(Qt::Key_Z); m_menuView->addAction(action); connect(action, SIGNAL(triggered()), m_glModelWidget, SLOT(frameFull())); m_actViewGrid = new QAction("View Grid", this); m_actViewGrid->setShortcut(Qt::CTRL + Qt::Key_G); m_actViewGrid->setCheckable(true); m_actViewGrid->setChecked(m_glModelWidget->drawGrid()); m_menuView->addAction(m_actViewGrid); connect(m_actViewGrid, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setDrawGrid(bool))); m_actViewVoxgrid = new QAction("Voxel Grid", this); m_actViewVoxgrid->setShortcut(Qt::Key_G); m_actViewVoxgrid->setCheckable(true); m_actViewVoxgrid->setChecked(m_glModelWidget->drawVoxelGrid()); m_menuView->addAction(m_actViewVoxgrid); connect(m_actViewVoxgrid, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setDrawVoxelGrid(bool))); m_actViewBBox = new QAction("Bounding Box", this); m_actViewBBox->setShortcut(Qt::CTRL + Qt::Key_B); m_actViewBBox->setCheckable(true); m_actViewBBox->setChecked(m_glModelWidget->drawBoundingBox()); m_menuView->addAction(m_actViewBBox); connect(m_actViewBBox, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setDrawBoundingBox(bool))); action=new QAction("Sprite Bounds", this); action->setShortcut(Qt::Key_B); action->setCheckable(true); action->setChecked(m_glModelWidget->drawSpriteBounds()); m_menuView->addAction(action); connect(action, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setDrawSpriteBounds(bool))); // ------ window menu m_menuWindow = menuBar()->addMenu("&Window"); m_menuWindow->addAction(m_toolbar->toggleViewAction()); m_menuWindow->addAction(m_paletteDocker->toggleViewAction()); m_menuWindow->addAction(m_projectDocker->toggleViewAction()); //m_menuWindow->addAction(m_layersDocker->toggleViewAction()); m_menuWindow->addAction(get_python_console_widget()->toggleViewAction()); get_python_console_widget()->toggleViewAction()->setChecked(false); // ------ toolbar hookups // Icons from the brilliant icon pack located at : http://pen-art.ru/ m_toolbarActionGroup = new QActionGroup(this); m_actToolSplat = new QAction("Splat", m_toolbarActionGroup); m_actToolSplat->setIcon(QIcon(QPixmap(":/icons/splat.png"))); m_actToolSplat->setCheckable(true); connect(m_actToolSplat, SIGNAL(toggled(bool)), this, SLOT(setToolSplat(bool))); m_actToolReplace = new QAction("Replace", m_toolbarActionGroup); m_actToolReplace->setIcon(QIcon(QPixmap(":/icons/pencil.png"))); m_actToolReplace->setCheckable(true); connect(m_actToolReplace, SIGNAL(toggled(bool)), this, SLOT(setToolReplace(bool))); m_actToolFlood = new QAction("Flood", m_toolbarActionGroup); m_actToolFlood->setIcon(QIcon(QPixmap(":/icons/paintBucket.png"))); m_actToolFlood->setCheckable(true); connect(m_actToolFlood, SIGNAL(toggled(bool)), this, SLOT(setToolFlood(bool))); m_actToolDropper = new QAction("Dropper", m_toolbarActionGroup); m_actToolDropper->setIcon(QIcon(QPixmap(":/icons/eyeDropper.png"))); m_actToolDropper->setCheckable(true); connect(m_actToolDropper, SIGNAL(toggled(bool)), this, SLOT(setToolDropper(bool))); m_actToolEraser = new QAction("Eraser", m_toolbarActionGroup); m_actToolEraser->setIcon(QIcon(QPixmap(":/icons/eraser.png"))); m_actToolEraser->setCheckable(true); connect(m_actToolEraser, SIGNAL(toggled(bool)), this, SLOT(setToolEraser(bool))); m_actToolSlab = new QAction("Slab", m_toolbarActionGroup); m_actToolSlab->setIcon(QIcon(QPixmap(":/icons/slab.png"))); m_actToolSlab->setCheckable(true); connect(m_actToolSlab, SIGNAL(toggled(bool)), this, SLOT(setToolSlab(bool))); m_actToolLine = new QAction("Line", m_toolbarActionGroup); m_actToolLine->setIcon(QIcon(QPixmap(":/icons/line.png"))); m_actToolLine->setCheckable(true); connect(m_actToolLine, SIGNAL(toggled(bool)), this, SLOT(setToolLine(bool))); m_actToolBox = new QAction("Box", m_toolbarActionGroup); m_actToolBox->setIcon(QIcon(QPixmap(":/icons/box.png"))); m_actToolBox->setCheckable(true); connect(m_actToolBox, SIGNAL(toggled(bool)), this, SLOT(setToolBox(bool))); m_actToolExtrude = new QAction("Extrude", m_toolbarActionGroup); m_actToolExtrude->setIcon(QIcon(QPixmap(":/icons/extrude.png"))); m_actToolExtrude->setCheckable(true); connect(m_actToolExtrude, SIGNAL(toggled(bool)), this, SLOT(setToolExtrude(bool))); //m_actToolRay = new QAction("Ray", this); m_actToolSplat->setChecked(true); m_toolbar->addActions(m_toolbarActionGroup->actions()); // Toolbar widgets for slicing m_toolbar->addSeparator(); m_minSliceBox=new QSpinBox(); m_maxSliceBox=new QSpinBox(); m_toolbar->addWidget(m_maxSliceBox); m_toolbar->addWidget(m_minSliceBox); connect(m_glModelWidget, SIGNAL(sliceChanged(int, int, int)), this, SLOT(updateSlice(int, int, int))); connect(m_minSliceBox, SIGNAL(valueChanged(int)), m_glModelWidget, SLOT(setMinSlice(int))); connect(m_maxSliceBox, SIGNAL(valueChanged(int)), m_glModelWidget, SLOT(setMaxSlice(int))); // axis selection QActionGroup *axisGroup=new QActionGroup(this); QAction *a=new QAction("X", axisGroup); a->setCheckable(true); connect(a, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setAxisX())); m_actAxisX=a; a=new QAction("Y", axisGroup); a->setCheckable(true); connect(a, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setAxisY())); m_actAxisY=a; a=new QAction("Z", axisGroup); a->setCheckable(true); connect(a, SIGNAL(toggled(bool)), m_glModelWidget, SLOT(setAxisZ())); m_actAxisZ=a; m_toolbar->addSeparator(); m_toolbar->addActions(axisGroup->actions()); m_actAxisY->setChecked(true); // Remaining verbosity setWindowTitle(BASE_WINDOW_TITLE); statusBar()->showMessage(tr("Ready")); // Load up some settings if (m_appSettings.value("saveUILayout", true).toBool()) { resize(m_appSettings.value("MainWindow/size", QSize(546, 427)).toSize()); move(m_appSettings.value("MainWindow/position", QPoint(200, 200)).toPoint()); setWindowState((Qt::WindowStates)m_appSettings.value("MainWindow/windowState", Qt::WindowActive).toInt()); restoreState(m_appSettings.value("MainWindow/widgetsState").toByteArray()); m_toolbar->setVisible(m_appSettings.value("toolbar/visibility", true).toBool()); m_paletteDocker->setVisible(m_appSettings.value("paletteWindow/visibility", true).toBool()); m_projectDocker->setVisible(m_appSettings.value("projectWindow/visibility", true).toBool()); //m_layersDocker->setVisible(m_appSettings.value("layersWindow/visibility", true).toBool()); } // Load the commandline supplied filename if (initialFilename != "") { openFile(initialFilename); } // Better way to keep the state in one place //std::cout << (m_toolbarActionGroup->checkedAction()->text() == "Splat") << std::endl; //std::cout << qPrintable(m_toolbarActionGroup->checkedAction()->text()) << std::endl; // Start things off focused on the GLWidget m_glModelWidget->setFocus(); }
void GLWidget::initializeGL() { //Background color will be white glClearColor(1.0, 1.0, 1.0, 1.0); glShadeModel( GL_FLAT ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); glPointSize(5); /// Scene Settings cameraToPicturePlaneDistance = 10.0; picturePlaneZ = 12.0; antiAliasing = false; aaComplex = 5; /// Light Settings sceneAmbience = 0.4; // Overall Ambience in the scene lightPersistence = 5.0; // Increase this number to allow light to travel further unitSegs = 10; // How dense area lights are /// Colours: [0] - Red colour value /// [1] - Green colour value /// [2] - Blue colour value QVector< double > white(3); white[0] = 1.0; white[1] = 1.0; white[2] = 1.0; QVector< double > red(3); red[0] = 0.6196; red[1] = 0.0824; red[2] = 0.1353; QVector< double > blue(3); blue[0] = 0.1215; blue[1] = 0.1804; blue[2] = 0.5686; QVector< double > yellow(3); yellow[0] = 0.9059; yellow[1] = 0.9294; yellow[2] = 0.2235; /// Materials: [0] - Ambient Coefficient /// [1] - Diffuse Coefficient /// [2] - Specular Coefficient /// [3] - Reflection Coefficient QVector< QVector< double > > mirror(4, QVector< double >(3, 0.0)); mirror[3][0] = 1.0; mirror[3][1] = 1.0; mirror[3][2] = 1.0; QVector< QVector< double > > eggShell(4, QVector< double >(3, 0.0)); eggShell[0][0] = 0.2; eggShell[0][1] = 0.2; eggShell[0][2] = 0.2; eggShell[1][0] = 0.7; eggShell[1][1] = 0.7; eggShell[1][2] = 0.7; eggShell[2][0] = 0.3; eggShell[2][1] = 0.3; eggShell[2][2] = 0.3; eggShell[3][0] = 0.0; eggShell[3][1] = 0.0; eggShell[3][2] = 0.0; QVector< QVector< double > > plastic(4, QVector< double >(3, 0.0)); plastic[0][0] = 0.2; plastic[0][1] = 0.2; plastic[0][2] = 0.2; plastic[1][0] = 0.7; plastic[1][1] = 0.7; plastic[1][2] = 0.7; plastic[2][0] = 0.8; plastic[2][1] = 0.8; plastic[2][2] = 0.8; plastic[3][0] = 0.1; plastic[3][1] = 0.1; plastic[3][2] = 0.1; QVector< QVector< double > > wall(4, QVector< double >(3, 0.0)); wall[0][0] = 0.2; wall[0][1] = 0.2; wall[0][2] = 0.2; wall[1][0] = 0.8; wall[1][1] = 0.8; wall[1][2] = 0.8; wall[2][0] = 0.3; wall[2][1] = 0.3; wall[2][2] = 0.3; QVector< QVector< double > > cwall(4, QVector< double >(3, 0.0)); cwall[0][0] = 0.2; cwall[0][1] = 0.2; cwall[0][2] = 0.2; cwall[1][0] = 0.1; cwall[1][1] = 0.1; cwall[1][2] = 0.1; cwall[2][0] = 0.1; cwall[2][1] = 0.1; cwall[2][2] = 0.1; /// Spheres spheres = QVector< Sphere >(); spheres.append(Sphere(QVector3D(2.5, 2.1, 3.0), 2, 100, mirror[0], mirror[1], mirror[2], mirror[3], white)); spheres.append(Sphere(QVector3D(8.0, 5.0, 2.0), 1, 10, eggShell[0], eggShell[1], eggShell[2], eggShell[3], white)); spheres.append(Sphere(QVector3D(9.0, 1.0, 7.0), 1, 100, plastic[0], plastic[1], plastic[2], plastic[3], white)); /// Light Sources // Initialize Point Lights pointLights = QVector< PointLight >(); //pointLights.append(PointLight(QVector3D(2.0, 2.0, 9.0), white)); // Initialize Area Lights areaLights = QVector< AreaLight >(); // Square Ceiling Light // areaLights.append(AreaLight(QVector3D(4.0, 10.0, 6.0), QVector3D(6.0, 10.0, 6.0), // QVector3D(6.0, 10.0, 4.0), QVector3D(4.0, 10.0, 4.0), white)); // Rectangle Ceiling Light areaLights.append(AreaLight(QVector3D(2.0, 10.0, 6.0), QVector3D(8.0, 10.0, 6.0), QVector3D(8.0, 10.0, 4.0), QVector3D(2.0, 10.0, 4.0), white)); /// Triangle // Front Left triangles.append(Triangle(QVector3D(5, 0.0, 8), QVector3D(4, 0.0, 6), QVector3D(5, 2.0, 7), 100, wall[0], wall[1], wall[2], white)); // Front Right triangles.append(Triangle(QVector3D(5, 0.0, 8), QVector3D(5, 2.0, 7), QVector3D(6, 0.0, 6), 100, wall[0], wall[1], wall[2], white)); // Back Face triangles.append(Triangle(QVector3D(4, 0.0, 6), QVector3D(6, 0.0, 6), QVector3D(5, 2.0, 7), 100, wall[0], wall[1], wall[2], white)); /// Boxes // Left Side triangles.append(Triangle(QVector3D(7, 1, 3), QVector3D(7, 1, 1), QVector3D(7, 3, 1), 100, wall[0], wall[1], wall[2], white)); triangles.append(Triangle(QVector3D(7, 1, 3), QVector3D(7, 3, 1), QVector3D(7, 3, 3), 100, wall[0], wall[1], wall[2], white)); // Top Side triangles.append(Triangle(QVector3D(7, 3, 3), QVector3D(7, 3, 1), QVector3D(9, 3, 1), 100, wall[0], wall[1], wall[2], white)); triangles.append(Triangle(QVector3D(7, 3, 3), QVector3D(9, 3, 1), QVector3D(9, 3, 3), 100, wall[0], wall[1], wall[2], white)); // Front Side triangles.append(Triangle(QVector3D(7, 1, 3), QVector3D(7, 3, 3), QVector3D(9, 3, 3), 100, wall[0], wall[1], wall[2], white)); triangles.append(Triangle(QVector3D(7, 1, 3), QVector3D(9, 3, 3), QVector3D(9, 1, 3), 100, wall[0], wall[1], wall[2], white)); /// Square Room Triangles // Draw Room - Left Wall triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(0, 10, 10), QVector3D(0, 10, 0), 100, wall[0], wall[1], wall[2], red)); triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(0, 10, 0), QVector3D(0, 0, 0), 100, wall[0], wall[1], wall[2], red)); //Draw Room - Back Wall triangles.append(Triangle(QVector3D(0, 0, 0), QVector3D(0, 10, 0), QVector3D(10, 10, 0), 100, wall[0], wall[1], wall[2], yellow)); triangles.append(Triangle(QVector3D(0, 0, 0), QVector3D(10, 10, 0), QVector3D(10, 0, 0), 100, wall[0], wall[1], wall[2], yellow)); // Draw Room - Right Wall triangles.append(Triangle(QVector3D(10, 0, 0), QVector3D(10, 10, 0), QVector3D(10, 10, 10), 100, wall[0], wall[1], wall[2], blue)); triangles.append(Triangle(QVector3D(10, 0, 0), QVector3D(10, 10, 10), QVector3D(10, 0, 10), 100, wall[0], wall[1], wall[2], blue)); // Draw Room - Floor triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(0, 0, 0), QVector3D(10, 0, 0), 100, wall[0], wall[1], wall[2], white)); triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(10, 0, 0), QVector3D(10, 0, 10), 100, wall[0], wall[1], wall[2], white)); // Draw Room - Ceiling // triangles.append(Triangle(QVector3D(0, 10, 0), QVector3D(0, 10, 10), QVector3D(10, 10, 10), 100, cwall[0], cwall[1], cwall[2], yellow)); // triangles.append(Triangle(QVector3D(0, 10, 0), QVector3D(10, 10, 10), QVector3D(10, 10, 0), 100, cwall[0], cwall[1], cwall[2], yellow)); /// Rectangle Room Triangles /* // Draw Room - Left Wall triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(0, 10, 10), QVector3D(0, 10, -10), 100, wall[0], wall[1], wall[2], red)); triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(0, 10, -10), QVector3D(0, 0, -10), 100, wall[0], wall[1], wall[2], red)); //Draw Room - Back Wall triangles.append(Triangle(QVector3D(0, 0, -10), QVector3D(0, 10, -10), QVector3D(10, 10, -10), 100, wall[0], wall[1], wall[2], white)); triangles.append(Triangle(QVector3D(0, 0, -10), QVector3D(10, 10, -10), QVector3D(10, 0, -10), 100, wall[0], wall[1], wall[2], white)); // Draw Room - Right Wall triangles.append(Triangle(QVector3D(10, 0, -10), QVector3D(10, 10, -10), QVector3D(10, 10, 10), 100, wall[0], wall[1], wall[2], blue)); triangles.append(Triangle(QVector3D(10, 0, -10), QVector3D(10, 10, 10), QVector3D(10, 0, 10), 100, wall[0], wall[1], wall[2], blue)); // Draw Room - Floor triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(0, 0, -10), QVector3D(10, 0, -10), 100, wall[0], wall[1], wall[2], white)); triangles.append(Triangle(QVector3D(0, 0, 10), QVector3D(10, 0, -10), QVector3D(10, 0, 10), 100, wall[0], wall[1], wall[2], white)); */ preCalculate(); }
void EstimateEMOS2<T,N>::iterate( ){ int l, m; RectDomain<N> rect(this->est_.lbound(), this->est_.ubound()); this->old_ = this->est_; int length = strata_.length(0); int size = length - 2; for ( l = 0; l < length; l++ ) { estF_ = 0; prev_ = this->est_; // get image prediction which is a convolution of est with // interpolation of psfs (multiplication and in Fourier domain) for ( m = 0; m < size; m++ ) { s1_ = 0; if ( m == 0 ) { s1_(strata_(m)) = this->est_(strata_(m)); } else if ( m == size - 1 ) { s1_(strata_(m+2)) = this->est_(strata_(m+2)); } s1_(strata_(m+1)) = this->est_(strata_(m+1)); s2_ = s1_; multiplyStratum(strata_(m+1), s1_, a_, true); multiplyStratum(strata_(m+1), s2_, a_, false); mirror(s1_, s_); fftw_.plan(s_, sF_); fftw_.execute(); estF_ += sF_ * psfsF_(m); mirror(s2_, s_); fftw_.plan(s_, sF_); fftw_.execute(); estF_ += sF_ * psfsF_(m+1); } // convert back to space domain fftw_.plan(estF_, s2_); fftw_.execute(); s2_ /= s2_.size(); this->est_ = s2_(rect); // get the ratio of image and prediction s_ = where( this->est_ > epsilon_, this->img_/this->est_, this->img_/epsilon_); mirror(s_, s2_); fftw_.plan(s2_, estF_); fftw_.execute(); // convolve the ratio with psf and multiply with old estimate this->est_ = 0; for ( m = 0; m < size; m++ ) { sF_ = estF_ * conj(psfsF_(m)); // multiply with old estimate fftw_.plan(sF_, s2_); fftw_.execute(); s2_ /= s2_.size(); s_ = s2_(rect); s_ *= prev_; this->est_ += s_; } this->est_ *= scale_; this->est_ = where( this->est_ > epsilon_, this->est_, 0); } }
void mainLevel(RenderWindow &window) { //>>>>>>>>>>>>>>>---Level---<<<<<<<<<<<<<<<<<<<<<<<<<<< Level lvl; lvl.LoadFromFile("map.tmx"); //>>>>>>>>>>>>>>>>---Load basic image for level1----<<<<<<<<<<<<<<<<< Texture texture; texture.loadFromFile("images/level1empty.jpg"); Sprite level(texture); Texture texture2; texture2.loadFromFile("images/levelShad.png"); Sprite level2(texture2); Texture texture3; texture3.loadFromFile("images/level12.png"); Sprite level3(texture3); //>>>>>>>>>>>>>>>>---Music---<<<<<<<<<<<<<<<<<<<<<<<<<< Music mainSong; Music skyrim, muse, bathMus; bathMus.openFromFile("music/bath.ogg"); Object mus = lvl.GetObject("muse"); muse.openFromFile("music/synd.ogg"); muse.setVolume(100); skyrim.openFromFile("music/skyrim.ogg"); skyrim.setVolume(100); mainSong.openFromFile("music/level1.ogg"); mainSong.play(); mainSong.setLoop(true); mainSong.setVolume(75); //>>>>>>>>>>>>>>>>---Create a cat---<<<<<<<<<<<<<<<<<<< Object player = lvl.GetObject("cat"); Object fish = lvl.GetObject("fish"); Object mo = lvl.GetObject("mouse"); Object ob = lvl.GetObject("catPlace"); Player cat("cat.png", lvl, 68, 429, 60, 120, player.rect.left, player.rect.top, ELSE); Clock clock; Clock gameTimeClock; int sinkCnt = 0; //>>>>>>>>>>>>>>>>---Sounds----<<<<<<<<<<<<<<<<<<< SoundBuffer buf1, buf2; buf1.loadFromFile("music/meow1.ogg"); buf2.loadFromFile("music/meow2.ogg"); Sound meow1, meow2; meow1.setBuffer(buf1); meow2.setBuffer(buf2); SoundBuffer buf, buf3; buf.loadFromFile("music/steklo.ogg"); buf3.loadFromFile("music/mouse.ogg"); Sound glass; Sound mouseS; glass.setBuffer(buf); glass.setVolume(100); mouseS.setBuffer(buf3); //Objects Furniture posters("tayles1.png", 160, 660, 210, 250, 280, 215, POSTERS); Furniture bed("tayles1.png", 420, 80, 280, 310, 250, 440, ELSE); Furniture toys("tayles1.png", 120, 470, 180, 150, 220, 545, TOYS); Furniture upShelf("tayles1.png", 700, 652.5, 120, 97.5, 350, 83, SHELF); Furniture cabinet("tayles1.png", 75, 40, 250, 350, 605, 305, CABINET); Furniture mop("tayles1.png", 515, 785, 165, 241, 587, 385, MOP); Furniture flower("tayles1.png",780, 65, 170, 330, 147, 285, ELSE); Furniture ball("tayles1.png", 905, 615, 40, 55, 357, 190, BALL); Furniture books("tayles1.png", 860, 735, 125, 80, 290, 187, BOOKS); Furniture brokenBall("tayles1.png",920, 540, 90, 42, 430, 430, ELSE); Furniture key("tayles1.png", 1, 1, 25, 25, 430, 425, KEY); Furniture cabinetEnd("cabinet.png", 20, 50, 270, 350, 590, 290, ELSE); Furniture girl("girlHair.png", 1,1, 96, 45, 1075, 350, ELSE); Furniture door("tayles2.png", 0, 560, 80, 340, 870, 350, ELSE); Furniture puddle("tayles1.png",789, 1000, 204, 75, 1057, 559, ELSE); Furniture brokenLight("tayles2.png", 10, 110, 50, 70, 795, 430, ELSE); Furniture light("tayles2.png", 20, 20, 35, 70, 220, 565, ELSE); Furniture bath("tayles2.png", 80, 50, 320, 380, 1010, 330, BATH); Furniture openBath("bathr.png", 264, 79, 339, 369, 1015, 315, ELSE); Furniture carpet("tayles2.png", 100, 500, 100, 140, 870, 530, ELSE); Furniture mirror("tayles2.png", 90, 700, 110, 290, 1200, 300, ELSE); Furniture sink("tayles2.png", 290, 440, 150, 240, 1190, 450, SINK); Furniture sinkWater("bathr.png", 22, 180, 197, 427, 1200, 540, ELSE); Furniture mou("mouse.png", 2, 21, 32, 25, mo.rect.left, mo.rect.top, ELSE); std::list<Furniture> fList; std::list<Furniture>::iterator it; fList.push_back(posters); fList.push_back(toys); fList.push_back(upShelf); fList.push_back(cabinet); fList.push_back(mop); fList.push_back(ball); fList.push_back(books); fList.push_back(key); fList.push_back(puddle); fList.push_back(brokenLight); fList.push_back(bath); fList.push_back(sink); for(it = fList.begin(); it != fList.end(); it++){ it->setSub((void *)&it, writeMess); } int cntMeow = 1, cntGame = 0, click = 0, clickBath = 1, clickSink = 1; bath.isPlayed = true; sink.isPlayed = true; while (window.isOpen()) { float time = clock.getElapsedTime().asMicroseconds(); float sinkTime = gameTimeClock.getElapsedTime().asSeconds(); if(clickSink < 2) gameTimeClock.restart(); clock.restart(); time = time/500; Vector2i pos = Mouse::getPosition(window); Event event; while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) window.close(); if (event.type == Event::MouseButtonPressed) if (event.key.code == Mouse::Left){ if (fish.rect.contains(pos.x, pos.y) && key.isPlayed == true){ mainSong.stop(); finish(); window.close(); } if (cat.sprite.getGlobalBounds().contains(pos.x, pos.y)) { cntMeow++; if(cntMeow == 5) { meow2.play(); cntMeow = 0; } else meow1.play(); } toys.trueMove(pos); if(light.isPlayed == false) light.trueMove(pos); if(ball.isPlayed == true && books.isPlayed == true) key.trueMove(pos); if(puddle.isPlayed == true) mop.trueMove(pos); click = light.clickedThings(pos); clickBath = bath.clickedThings(pos); clickSink = sink.clickedThings(pos); if (upShelf.sprite.getGlobalBounds().contains(pos.x, pos.y)){ skyrim.play(); } if (mus.rect.contains(pos.x, pos.y)){ muse.play(); } if (girl.sprite.getGlobalBounds().contains(pos.x, pos.y) && cat.room == 2){ mainSong.pause(); gameOver(); mainSong.play(); } if(mou.isPlayed == false) { if (mou.sprite.getGlobalBounds().contains(pos.x, pos.y)) { mainSong.pause(); mouseS.play(); //gameRunning(); mou.isPlayed = true; mainSong.play(); } } if(books.isPlayed == false) { if (books.sprite.getGlobalBounds().contains(pos.x, pos.y)) { mainSong.pause(); MiniGame_Books(); books.isPlayed = true; mainSong.play(); } } } if (event.type == Event::MouseButtonReleased) if (event.key.code == Mouse::Left){ toys.isMove = false; key.isMove = false; if(light.isPlayed == false) light.isMove = false; mop.isMove = false; } } if(sinkTime > 5 && clickSink == 2) puddle.isPlayed = true; if(clickBath == 2 && cat.room == 2) bathMus.play(); if(click == -1){} else if(click == 1 || click == 2) cat.room = click; toys.intersect("toys",lvl); toys.move(pos); if(mop.isPlayed == false) { mop.intersect("mop", lvl); mop.move(pos); } if(light.isPlayed == false) { light.intersect("light", lvl); light.move(pos); } if(ball.isPlayed == true && books.isPlayed == true){ if(mop.isPlayed == true) key.intersect("key", lvl); if(key.isPlayed == false) key.move(pos); } if(ball.isPlayed == false && books.isPlayed == true){ if(cat.sprite.getGlobalBounds().intersects(ob.rect)) { if(cntMeow == 0) { ball.falling(event, window, pos, lvl, time); glass.play(); ball.isPlayed = true; ball.intersect("ball", lvl); } } } cat.Update(time); window.clear(Color::Black); lvl.Draw(window); if(cat.room == 0) window.draw(level); if(cat.room == 1) window.draw(level2); if(cat.room == 2) window.draw(level3); window.draw(posters.sprite); window.draw(bed.sprite); if(key.isPlayed == true) window.draw(cabinetEnd.sprite); else window.draw(cabinet.sprite); window.draw(upShelf.sprite); window.draw(flower.sprite); if(ball.isPlayed == false) window.draw(ball.sprite); else { window.draw(brokenBall.sprite); window.draw(key.sprite); } window.draw(books.sprite); if(mou.isPlayed == false){ window.draw(mou.sprite); } else window.draw(light.sprite); window.draw(toys.sprite); if(cat.room == 2){ if(clickBath == 2){ window.draw(girl.sprite); window.draw(openBath.sprite); } else window.draw(bath.sprite); window.draw(mirror.sprite); if(clickSink == 2) window.draw(sinkWater.sprite); else window.draw(sink.sprite); if(puddle.isPlayed == true && mop.isPlayed == false) window.draw(puddle.sprite); } if(cat.room == 1 || cat.room == 2){ if(light.isPlayed == false) window.draw(brokenLight.sprite); window.draw(carpet.sprite); window.draw(door.sprite); } if(mop.isPlayed == false) window.draw(mop.sprite); window.draw(cat.sprite); for(it = fList.begin(); it != fList.end(); it++) { if(it->sprite.getGlobalBounds().contains(pos.x, pos.y)) { if(it->f.cb_fn != NULL) { cb_fn fn; fn = (cb_fn)it->f.cb_fn; fn(&window, it->type, &pos); } } } window.display(); } }
void BinaryTree<T>::mirror() { mirror(root); }
void CPUDebugger::write(uint24 addr, uint8 data) { if((addr & 0x40e000) == 0x2000) return; //$00-3f|80-bf:2000-3fff MMIO if((addr & 0x40e000) == 0x4000) return; //$00-3f|80-bf:4000-5fff MMIO if((addr & 0x40e000) == 0x0000) addr = 0x7e0000 | (addr & 0x1fff); //$00-3f:80-bf:0000-1fff WRAM return SFC::bus.write(mirror(addr), data); }