• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

polpoint

Members
  • Content count

    47
  • Joined

  • Last visited

Community Reputation

122 Neutral

About polpoint

  • Rank
    Member
  1. I have broken everything down to its simplest form: [url="http://www.mediafire.com/?xwevgekf8ndrrpv"]http://www.mediafire.com/?xwevgekf8ndrrpv[/url] (should be able to download from above link without having to wait/ enter any captcha) This project contains all the files for a simple WINAPI program utilizing SAPI speech recognition. It was created in VS2010 using the default Win32 project settings. *After compiling and executing the program a window will be displayed with a word (gloves). *After saying the command "START" the program will load the first dynamic grammar word/ rule(which in this case would be the word "GLOVES") *The program is then supposed to start listening for the word displayed. If you say "GLOVES" it will reset the dynamic grammar and load the next word. There are four words in total (gloves, fox, computer, dog). **My issue is that the rules are not consistent. At times I can say "GLOVES" when it is supposed to only accept "COMPUTER"
  2. Good morning. I have been making a Speech to Text program using SAPI and am having some problems with loading, activating and deactivating dynamic grammars. Basically I am displaying a picture on the screen. If the user states the correct response, as defined by the dynamic grammar rule, then that rule is deactivated, and another picture is displayed and its corresponding grammar rule is activated. I want the dynamic rules to be topLevel, so they just have to state the object without any prefix etc. My problem is the rules activating/ deactivating do not seem to be consistent. Sometimes the grammar will accept any of the rules, sometimes it will accept only the correct rule. Any help would be appreciated. If you need more info/ code please let me know. Thanks! I am pretty sure it is something I am missing when it comes to the grammar rules/ word transition. The other thing I thought might be possible was that I am somehow creating a rule with the memory address of LPCWSTR pikk as opposed to the actual data - but that doesn't seem like it is the problem since the first parameter of GetRule is a LPCWSTR - unless I am converting incorrectly? Loading dynamic grammar rules: [CODE] //curNumb = current number of exercise //curNumbID = curNumb + numOffest (500) so I reserve #1-500 for whatever other hard-coded grammar rules I add std::wstring stemp; LPCWSTR pikk; //add in the grammar: //reserve curNumb int reserveNum = curNumb; //loop through all object_data and load dynamic rules into grammar: for(int pip = 0; pip < data.numObjects.size(); pip++) { stemp = s2ws(data.object_data[curNumb].title); pikk = stemp.c_str(); hr = g_cpCmdGrammar->GetRule(pikk, data.object_data[curNumb].programID, SPRAF_TopLevel, TRUE, &hStateTravel); if(FAILED(hr)) { ErrorDescription(hr); } //loop through all words in object_data std::list<std::string>::iterator st_it = data.object_data[curNumb].words.begin(); for(; st_it != data.object_data[curNumb].words.end(); st_it++) { std::cout<<"adding word: "<<(*st_it)<<"\n"; stemp = s2ws((*st_it)); pikk = stemp.c_str(); hr = g_cpCmdGrammar->AddWordTransition(hStateTravel, NULL, pikk, L"", SPWT_LEXICAL, 1, NULL); if(FAILED(hr)) { ErrorDescription(hr); } } curNumb++; } //reset curNumb back to reserveNum curNumb = reserveNum; //activate curNumb grammar rule stemp = s2ws(data.object_data[curNumb].title); pikk = stemp.c_str(); std::cout<<"activate new rules "<<curNumbID<<"/"<<curNumb<<" ("<<data.object_data[curNumb].title<<")\n"; hr = g_cpCmdGrammar->SetRuleIdState(curNumbID, SPRS_ACTIVE); if(FAILED(hr)) { ErrorDescription(hr); std::cout<<"FAILURE at activate previous rules "<<curNumbID<<"/"<<curNumb<<" ("<<data.object_data[curNumb].title<<")\n"; } else { std::cout<<"ruleActivated...\n"; } hr = g_cpCmdGrammar->Commit(0); [/CODE] //deactivate old rule/ activate new rule code: [CODE] std::cout<<"curScore++ ("<<curScore<<"->"; curScore++; std::cout<<curScore<<")\n"; //clear old exercise: std::wstring stemp = s2ws(data.object_data[curNumb].title); LPCWSTR pikk = stemp.c_str(); std::cout<<"deactivate previous rules "<<curNumbID<<"/"<<curNumb<<" ("<<data.object_data[curNumb].title<<")\n"; hr = g_cpCmdGrammar->SetRuleIdState(curNumbID, SPRS_INACTIVE); if(FAILED(hr)) { ErrorDescription(hr); std::cout<<"FAILURE at deactivate previous rules "<<curNumbID<<"/"<<curNumb<<" ("<<data.object_data[curNumb].title<<")\n"; } else { std::cout<<"ruleDeactivated...\n"; } curNumb++; if(curNumb > data.numObjects.size()) { curNumb = 1; } curNumbID = curNumb + exerciseOffset; //activate next rule: stemp = s2ws(data.object_data[curNumb].title); pikk = stemp.c_str(); std::cout<<"activate new rules "<<curNumbID<<"/"<<curNumb<<" ("<<data.object_data[curNumb].title<<")\n"; hr = g_cpCmdGrammar->SetRuleIdState(curNumbID, SPRS_ACTIVE); if(FAILED(hr)) { ErrorDescription(hr); std::cout<<"FAILURE at activate previous rules "<<curNumbID<<"/"<<curNumb<<" ("<<data.object_data[curNumb].title<<")\n"; } else { std::cout<<"ruleActivated...\n"; } [/CODE]
  3. Yes, you are dreaming too big. Even the smartest, most dedicated and ____EXPERIENCED____ person would find what you are attempting to be pretty daunting. If you don't want to listen to people try to dissuade you (which is exactly what you just asked everybody to do) you should just jump in and start creating. In a year or two you will figure out what you are doing wrong and correct it, start over, or go in a different direction. Look at how other people are doing the stuff you want to emulate. And it sounds like you are starting from the top, with all the minute details, like voice acting. I would not even worry about that for a looooooong time, and that can _easily_ (comparatively) be bolted on at a later date. You want to make some completely open-ended, intricately detailed 3-d world where you can do anything, attain whatever social status, do almost any action and have all the actors respond appropriately. And you have never made a game before? Good luck! Honestly, don't. Start with a small "snapshot" of what you are attempting. Say, one tiny, isolated hamlet, and see what issues you encounter.
  4. I've got to thank you for all your help, iMalc! This is what I wound up doing (I broke up the function into a couple of different code quotes because it is kind of long): void smoothifyRegion(int wX, int wY, int aX, int aY) { std::stringstream ddp; //this figures the elevation from the surrounding areamaps and smoothifies everything int quadrant = -1; ACORD cd; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //n cd.aY--; //if aY < 0 then we need to modify wY until the coords are valid! cd = fixCoordinates(cd); //n is the elevation of the areamap to the north int n = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //ne cd.aY--; cd.aX++; cd = fixCoordinates(cd); int ne = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //e cd.aX++; cd = fixCoordinates(cd); int e = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //se cd.aX++; cd.aY++; cd = fixCoordinates(cd); int se = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //s cd.aY++; cd = fixCoordinates(cd); int s = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //sw cd.aY++; cd.aX--; cd = fixCoordinates(cd); int sw = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //w cd.aX--; cd = fixCoordinates(cd); int w = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; cd.wX = wX; cd.wY = wY; cd.aX = aX; cd.aY = aY; //nw cd.aX--; cd.aY--; cd = fixCoordinates(cd); int nw = world.wMap[cd.wX][cd.wY].area.aMap[cd.aX][cd.aY].region.baseHt; CORD N, NE, E, SE, S, SW, W, NW; //capital directions represent the coordinates of the center of the surrounding areamaps N.X = halfRMAP_X; N.Y = -halfRMAP_Y; NE.X = halfRMAP_X + RMAP_X; NE.Y = -halfRMAP_Y; E.X = halfRMAP_X + RMAP_X; E.Y = halfRMAP_Y; SE.X = halfRMAP_X + RMAP_X; SE.Y = halfRMAP_Y + RMAP_Y; S.X = halfRMAP_X; S.Y = halfRMAP_Y + RMAP_Y; SW.X = -halfRMAP_X; SW.Y = halfRMAP_Y + RMAP_Y; W.X = -halfRMAP_X; W.Y = halfRMAP_Y; NW.X = -halfRMAP_X; NW.Y = -halfRMAP_Y; //haaa less typing! AREAMAP &sourceArea = world.wMap[wX][wY].area; REGIONMAP &destRegion = sourceArea.aMap[aX][aY].region; //do the center of the square first! destRegion.rMap[halfRMAP_X][halfRMAP_Y].elevation = destRegion.baseHt; //ok - do the 8 cardinal directions next! int pix; int piy; //n pix = halfRMAP_X; for(piy = halfRMAP_Y-1; piy >= 0; piy--) { float nDist = 1 / linearDist(pix,piy,N.X,N.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = nDist + centDist; nDist = nDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = n*nDist + destRegion.baseHt*centDist; } //ne for(pix = halfRMAP_X+1, piy = halfRMAP_Y-1; pix < RMAP_X && piy >= 0; pix++, piy--) { float neDist = 1 / linearDist(pix,piy,NE.X,NE.Y); float nDist = 1 / linearDist(pix,piy,N.X,N.Y); float eDist = 1 / linearDist(pix,piy,E.X,E.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = neDist + nDist + eDist + centDist; neDist = neDist / sum; nDist = nDist / sum; eDist = eDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = ne*neDist + n*nDist + e*eDist + destRegion.baseHt*centDist; } //e piy = halfRMAP_Y; for(pix = halfRMAP_X+1; pix < RMAP_X; pix++) { float eDist = 1 / linearDist(pix,piy,E.X,E.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = eDist + centDist; eDist = eDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = e*eDist + destRegion.baseHt*centDist; } //se for(pix = halfRMAP_X+1, piy = halfRMAP_Y+1; pix < RMAP_X && piy < RMAP_Y; pix++, piy++) { float seDist = 1 / linearDist(pix,piy,SE.X,SE.Y); float eDist = 1 / linearDist(pix,piy,E.X,E.Y); float sDist = 1 / linearDist(pix,piy,S.X,S.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = seDist + centDist + sDist + eDist; seDist = seDist / sum; eDist = eDist / sum; sDist = sDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = se*seDist + s*sDist + e*eDist + destRegion.baseHt*centDist; } //s pix = halfRMAP_X; for(piy = halfRMAP_Y+1; piy < RMAP_Y; piy++) { float sDist = 1 / linearDist(pix,piy,S.X,S.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = sDist + centDist; sDist = sDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = s*sDist + destRegion.baseHt*centDist; } //sw for(pix = halfRMAP_X-1, piy = halfRMAP_Y+1; pix >= 0 && piy < RMAP_Y; pix--, piy++) { float swDist = 1 / linearDist(pix,piy,SW.X,SW.Y); float sDist = 1 / linearDist(pix,piy,S.X,S.Y); float wDist = 1 / linearDist(pix,piy,W.X,W.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = swDist + sDist + wDist + centDist; swDist = swDist / sum; sDist = sDist / sum; wDist = wDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = sw*swDist + s*sDist + w*wDist + destRegion.baseHt*centDist; } //w piy = halfRMAP_Y; for(pix = halfRMAP_X-1; pix >= 0; pix--) { float wDist = 1 / linearDist(pix,piy,W.X,W.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = wDist + centDist; wDist = wDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = w*wDist + destRegion.baseHt*centDist; } //nw for(pix = halfRMAP_X-1, piy = halfRMAP_Y-1; pix >= 0 && piy >= 0; pix--, piy--) { float nwDist = 1 / linearDist(pix,piy,NW.X,NW.Y); float wDist = 1 / linearDist(pix,piy,W.X,W.Y); float nDist = 1 / linearDist(pix,piy,N.X,N.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = nwDist + wDist + nDist + centDist; nwDist = nwDist / sum; wDist = wDist / sum; nDist = nDist / sum; centDist = centDist / sum; destRegion.rMap[pix][piy].elevation = nw*nwDist + w*wDist + n*nDist + destRegion.baseHt*centDist; } //octodrants go //\7 | 0 / // \ | / // \ | / //6 \|/ 1 //----+---- //5 /|\ 2 // / | \ // / | \ /// 4 |3 \ //0! //starts at halfRMAP_X+2, halfRMAP_Y-2 // int pipY; int pipX; int popp; int counter; //0 //starts at halfRMAP_X+1, halfRMAP_Y-2 pipX = halfRMAP_X + 1; counter = 1; for(pipY = halfRMAP_Y - 2; pipY >= 0; pipY--, counter++) { for(int popp = 0; popp < counter; popp++) { float nDist = 1 / linearDist(pipX + popp, pipY, halfRMAP_X, pipY); float neDist = 1 / linearDist(pipX + popp, pipY, halfRMAP_X + counter + 1, pipY); float sum = nDist + neDist; nDist = nDist / sum; neDist = neDist / sum; destRegion.rMap[pipX + popp][pipY].elevation = destRegion.rMap[halfRMAP_X][pipY].elevation * nDist + destRegion.rMap[halfRMAP_X + counter + 1][pipY].elevation * neDist; } } //1 //starts at halfRMAP_X + 2, halfRMAP_Y -1 pipY = halfRMAP_Y-1; counter = 1; for(pipX = halfRMAP_X + 2; pipX < RMAP_X; pipX++, counter++) { for(int popp = 0; popp < counter; popp++) { float eDist = 1 / linearDist(pipX, pipY - popp, pipX, halfRMAP_Y); float neDist = 1 / linearDist(pipX, pipY - popp, pipX, halfRMAP_Y - counter - 1); float sum = eDist + neDist; eDist = eDist / sum; neDist = neDist / sum; destRegion.rMap[pipX][pipY - popp].elevation = destRegion.rMap[pipX][halfRMAP_Y].elevation * eDist + destRegion.rMap[pipX][halfRMAP_Y - counter - 1].elevation * neDist; } } //2 //starts at halfRMAP_X + 2, halfRMAP_Y+1 pipY = halfRMAP_Y+1; counter = 1; for(pipX = halfRMAP_X + 2; pipX < RMAP_X; pipX++, counter++) { for(int popp = 0; popp < counter; popp++) { float eDist = 1 / linearDist(pipX, pipY + popp, pipX, halfRMAP_Y); float seDist = 1 / linearDist(pipX, pipY + popp, pipX, halfRMAP_Y + counter + 1); float sum = eDist + seDist; eDist = eDist / sum; seDist = seDist / sum; destRegion.rMap[pipX][pipY + popp].elevation = destRegion.rMap[pipX][halfRMAP_Y].elevation * eDist + destRegion.rMap[pipX][halfRMAP_Y + counter + 1].elevation * seDist; } } //3! //starts at halfRMAP_X+1, halfRMAP_Y + 2 pipX = halfRMAP_X+1; counter = 1; for(pipY = halfRMAP_Y + 2; pipY < RMAP_Y; pipY++, counter++) { for(int popp = 0; popp < counter; popp++) { float sDist = 1 / linearDist(pipX + popp, pipY, halfRMAP_X, pipY); float seDist = 1 / linearDist(pipX + popp, pipY, halfRMAP_X + counter + 1, pipY); float sum = sDist + seDist; sDist = sDist / sum; seDist = seDist / sum; destRegion.rMap[pipX + popp][pipY].elevation = destRegion.rMap[halfRMAP_X][pipY].elevation * sDist + destRegion.rMap[halfRMAP_X + counter + 1][pipY].elevation * seDist; } } //4! //starts at halfRMAP_X-1, halfRMAP_Y + 2 pipX = halfRMAP_X-1; counter = 1; for(pipY = halfRMAP_Y + 2; pipY < RMAP_Y; pipY++, counter++) { for(int popp = 0; popp < counter; popp++) { float sDist = 1 / linearDist(pipX - popp, pipY, halfRMAP_X, pipY); float swDist = 1 / linearDist(pipX - popp, pipY, halfRMAP_X - counter - 1, pipY); float sum = sDist + swDist; sDist = sDist / sum; swDist = swDist / sum; destRegion.rMap[pipX - popp][pipY].elevation = destRegion.rMap[halfRMAP_X][pipY].elevation * sDist + destRegion.rMap[halfRMAP_X - counter - 1][pipY].elevation * swDist; } } //5 //starts at halfRMAP_X-2, halfRMAP_Y-1 pipY = halfRMAP_Y + 1; counter = 1; for(pipX = halfRMAP_X - 2; pipX >= 0; pipX--, counter++) { for(int popp = 0; popp < counter; popp++) { float wDist = 1 / linearDist(pipX, pipY + popp, pipX, halfRMAP_Y); float swDist = 1 / linearDist(pipX, pipY + popp, pipX, halfRMAP_Y + counter + 1); float sum = wDist + swDist; wDist = wDist / sum; swDist = swDist / sum; destRegion.rMap[pipX][pipY + popp].elevation = destRegion.rMap[pipX][halfRMAP_Y].elevation * wDist + destRegion.rMap[pipX][halfRMAP_Y + counter + 1].elevation * swDist; } } //6 //starts at halfRMAP_X-2, halfRMAP_Y-1 pipY = halfRMAP_Y - 1; counter = 1; for(pipX = halfRMAP_X - 2; pipX >= 0; pipX--, counter++) { for(int popp = 0; popp < counter; popp++) { float wDist = 1 / linearDist(pipX, pipY - popp, pipX, halfRMAP_Y); float nwDist = 1 / linearDist(pipX, pipY - popp, pipX, halfRMAP_Y - counter - 1); float sum = wDist + nwDist; wDist = wDist / sum; nwDist = nwDist / sum; destRegion.rMap[pipX][pipY - popp].elevation = destRegion.rMap[pipX][halfRMAP_Y].elevation * wDist + destRegion.rMap[pipX][halfRMAP_Y - counter - 1].elevation * nwDist; } } //7 //starts at halfRMAP_X-1, halfRMAP_Y-2 pipX = halfRMAP_X - 1; counter = 1; for(pipY = halfRMAP_Y - 2; pipY >= 0; pipY--, counter++) { for(int popp = 0; popp < counter; popp++) { float nDist = 1 / linearDist(pipX - popp, pipY, halfRMAP_X, pipY); float nwDist = 1 / linearDist(pipX - popp, pipY, halfRMAP_X - counter - 1, pipY); float sum = nDist + nwDist; nDist = nDist / sum; nwDist = nwDist / sum; destRegion.rMap[pipX - popp][pipY].elevation = destRegion.rMap[halfRMAP_X][pipY].elevation * nDist + destRegion.rMap[halfRMAP_X - counter - 1][pipY].elevation * nwDist; } } world.wMap[wX][wY].area.aMap[aX][aY].region.reflectREle(wX,wY,aX,aY,3); } and I went from this: to this: Which is good enough for my needs, even though it produces little strips every once in a while - since I am going to be modifying this map slightly, the extra processing will hide whatever little artifacts show up.
  5. I think I am just missing some minor step in my function somewhere - I need 'e' to only take into account 5 & 2, because at that point, both 4 & 7 and 1 & 8 should have 0% influence on the value I only have odd sized maps at this magnification so I think it might produce the results I want if I calculate the 8 cardinal directions first and then interpolate inbetween those values to fill in the remainder. I'll have to write that up when I get the chance & test it out. +---+---+---+ |???|???|???| |?5?|?1?|?4?| |???|???|???| +---+---+---+ |???|abc|???| |?9?|d5e|?2?| |???|fgh|???| +---+---+---+ |???|???|???| |?3?|?8?|?7?| |???|???|???| +---+---+---+
  6. Yeah, that code is pretty funked up - the lowercase n, ne, e, se, s, sw, w & nw are the surrounding big square's base elevation values (or the A, B & D in the example where we try to calculate the values for the C square - the A would be n, the B would be ne and the D would be e) CORD N, NE, E, SE, S, SW, W, NW; N.X = halfRMAP_X; N.Y = -halfRMAP_Y; NE.X = halfRMAP_X + RMAP_X; NE.Y = -halfRMAP_Y; E.X = halfRMAP_X + RMAP_X; E.Y = halfRMAP_Y; SE.X = halfRMAP_X + RMAP_X; SE.Y = halfRMAP_Y + RMAP_Y; S.X = halfRMAP_X; S.Y = halfRMAP_Y + RMAP_Y; SW.X = -halfRMAP_X; SW.Y = halfRMAP_Y + RMAP_Y; W.X = -halfRMAP_X; W.Y = halfRMAP_Y; NW.X = -halfRMAP_X; NW.Y = -halfRMAP_Y; //quadrants go: // 0 1 // 2 3 for(int pix = 0; pix < RMAP_X; pix++) { for(int piy = 0; piy < RMAP_Y; piy++) { quadrant = -1; if(pix < (halfRMAP_X) && piy <(halfRMAP_Y)) { quadrant = 0; } else if(pix >= (halfRMAP_X) && piy < (halfRMAP_Y)) { quadrant = 1; } else if(pix < (halfRMAP_X) && piy >= (halfRMAP_Y)) { quadrant = 2; } else if(pix >= (halfRMAP_X) && piy >= (halfRMAP_Y)) { quadrant = 3; } if(quadrant == 0) { float wDist = 1 / linearDist(pix,piy,W.X,W.Y); float nwDist = 1 / linearDist(pix,piy,NW.X,NW.Y); float nDist = 1 / linearDist(pix,piy,N.X,N.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = nDist + wDist + nwDist + centDist; nDist = nDist / sum; wDist = wDist / sum; nwDist = nwDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = n*nDist + w*wDist + nw*nwDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } else if(quadrant == 1) { float nDist = 1 / linearDist(pix,piy,N.X,N.Y); float neDist = 1 / linearDist(pix,piy,NE.X,NE.Y); float eDist = 1 / linearDist(pix,piy,E.X,E.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = nDist + eDist + neDist + centDist; nDist = nDist / sum; eDist = eDist / sum; neDist = neDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = n*nDist + e*eDist + ne*neDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } else if(quadrant == 2) { float sDist = 1 / linearDist(pix,piy,S.X,S.Y); float swDist = 1 / linearDist(pix,piy,SW.X,SW.Y); float wDist = 1 / linearDist(pix,piy,W.X,W.Y); float centDist = 1 / linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); float sum = sDist + wDist + swDist + centDist; sDist = sDist / sum; wDist = wDist / sum; swDist = swDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = s*sDist + w*wDist + sw*swDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } else if(quadrant == 3) { float eDist = linearDist(pix,piy,E.X,E.Y); float seDist = linearDist(pix,piy,SE.X,SE.Y); float sDist = linearDist(pix,piy,S.X,S.Y); float centDist = linearDist(pix,piy,halfRMAP_X,halfRMAP_Y); eDist = 1 / eDist; seDist = 1 / seDist; sDist = 1 / sDist; if(centDist != 0) { centDist = 1 / centDist; } else { eDist = 0; seDist = 0; sDist = 0; centDist = 1; } float sum = sDist + eDist + seDist + centDist; sDist = sDist / sum; eDist = eDist / sum; seDist = seDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = s*sDist + e*eDist + se*seDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } } } float linearDist(float x1,float y1,float x2,float y2) { float dx = x2 - x1; float dy = y2 - y1; dx = dx * dx + dy * dy; if(dx != 0) { return sqrt(dx); } else { return 0; } }
  7. I don't really understand - so if I do something like your diagram to calculate only the central 5-value square: +---+---+---+ |5??|?1?|??4| |???|???|???| |???|???|???| +---+---+---+ |???|???|???| |9??|?5?|??2| |???|???|???| +---+---+---+ |???|???|???| |???|???|???| |3??|?8?|??7| +---+---+---+ Then if I move one square to the north and calculate the 1-value square like this: +---+---+---+ |7??|?2?|??3| |???|???|???| |???|???|???| +---+---+---+ |???|???|???| |5??|?1?|??4| |???|???|???| +---+---+---+ |???|???|???| |???|???|???| |9??|?5?|??2| +---+---+---+ will it line up with the calculated values for the 5-value square? It doesn't seem like it would - it seems like it would be missing one row (the three ?'s that are right between the 5 and the 1)
  8. Thanks for the thorough description iMalc! I don't think I explained the specifics of my problem very well or else I am not completely understanding your explanation. I am not doing anything with graphics, I let openGL handle all of the resampling of my graphics. I am trying to smooth out the elevation of my heightmap after zooming in to a different "magnification" (but it seems that you understand that with the very loose usage of source and destination pixel) I start out with this: +-+-+-+ |5|1|4| +-+-+-+ |9|5|2| +-+-+-+ |3|8|7| +-+-+-+ Then increase my magnification to this: +---+---+---+ |555|111|444| |555|111|444| |555|111|444| +---+---+---+ |999|555|222| |999|555|222| |999|555|222| +---+---+---+ |333|888|777| |333|888|777| |333|888|777| +---+---+---+ At this point I only have the center 5-value square loaded in memory for the new magnification and all of the squares at the previous magnification loaded in memory, so I basically know what the "base" surrounding values are supposed to be. Then I want to smooth out the values so I get something close to this (the values in the center square are a close enough approximation for this example): +---+---+---+ |555|111|444| |555|111|444| |555|111|444| +---+---+---+ |999|635|222| |999|754|222| |999|566|222| +---+---+---+ |333|888|777| |333|888|777| |333|888|777| +---+---+---+ So I am coming close to figuring it out, but I don't have access to the extra row & column and it seems like, from your example, I need a specific "start position," which would be the upper-left-most square (or whichever corner). I am using this to smooth out the elevation of a heightmap for a huge area that is divided up into smaller chunks. So the code that I posted above (minus the stupid method I utilized to figure the coordinates for the surrounding center squares) works, but only within one quadrant and the surrounding square's bordering quadrants. I edited one of the pictures above to highlight this. The arrows point to the center of the big squares (the values of that specific tile are messed up because I divided by 0 distance from the center) and the black square is outlining the se, sw, ne, and nw quadrant of 4 adjoining big squares. As you can see everything is lining up within the black square, but it does not line up with that same big square's other 3 quadrants. I tried doing the same thing utilizing all 8 surrounding big square's values along with the central big square that I am modifying but that doesn't work either. Ah! problems that I can not solve are frustrating!
  9. The code seems to be interpolating correctly within each quadrant, but the 4 quadrants don't line up correctly. And there are those little low elevation squares (the little blue squares evenly spaced around) that mark the exact center of each square. if I take into account all 8 of the surrounding elevation levels (as opposed to how I am doing it now and only taking into account the three closest) will that make everything smooth inbetween the 4 quadrants?
  10. Quote: +---0,0---+---1,0---+ |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? A ? ?|? ? B ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... +---0,1---+---1,1---+ |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? C ? ?|? ? D ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... +---------+---------+ | ... | ... |... I know the values of A, B, C & D and I want to interpolate between those values to fill in the rest of the ?'s Below is the source code as I currently have it, but I am doing something wrong somewhere and I can't figure it out. In the code below the NW quadrant == 0 NE quadrant == 1 SW quadrant == 2 SE quadrant == 3 for(int pix = 0; pix < RMAP_X; pix++) { for(int piy = 0; piy < RMAP_Y; piy++) { quadrant = -1; if(pix < (halfRMAP_X) && piy <(halfRMAP_Y)) { quadrant = 0; } else if(pix >= (halfRMAP_X) && piy < (halfRMAP_Y)) { quadrant = 1; } else if(pix < (halfRMAP_X) && piy >= (halfRMAP_Y)) { quadrant = 2; } else if(pix >= (halfRMAP_X) && piy >= (halfRMAP_Y)) { quadrant = 3; } if(quadrant == 0) { //nw quadrant - //pix < halfRMAP_X //piy < halfRMAP_Y float nwDist = 0; float nDist = 0; float wDist = 0; float centDist = 0; nDist = 1 / linearDist(pix,piy,pix + (halfRMAP_X - pix),piy - (halfRMAP_Y + piy)); wDist = 1 / linearDist(pix,piy,pix - (halfRMAP_X + pix),piy + (halfRMAP_Y - piy)); nwDist = 1 / linearDist(pix,piy, pix - (halfRMAP_X + pix), piy - (halfRMAP_Y - piy)); centDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X - pix), piy + (halfRMAP_Y - piy)); float sum = nDist + wDist + nwDist + centDist; nDist = nDist / sum; wDist = wDist / sum; nwDist = nwDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = nw*nwDist + n*nDist + w*wDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } else if(quadrant == 1) { //ne quadrant //pix >= halfRMAP_X //piy < halfRMAP_Y float neDist = 0; float nDist = 0; float eDist = 0; float centDist = 0; nDist = 1 / linearDist(pix,piy, pix - (pix - halfRMAP_X), piy - (halfRMAP_Y + piy)); eDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X + (RMAP_X - pix)), piy + (halfRMAP_Y - piy)); neDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X + (RMAP_X - pix)), piy - (halfRMAP_Y + piy)); centDist = 1 / linearDist(pix,piy, pix - (pix - halfRMAP_X), piy + (halfRMAP_Y - piy)); float sum = nDist + eDist + neDist + centDist; nDist = nDist / sum; eDist = eDist / sum; neDist = neDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = ne*neDist + n*nDist + e*eDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } else if(quadrant == 2) { //sw quadrant //pix < halfRMAP_X //piy >= halfRMAP_Y float swDist = 0; float sDist = 0; float wDist = 0; float centDist = 0; wDist = 1 / linearDist(pix,piy,pix - (halfRMAP_X + pix), piy - (piy - halfRMAP_Y)); sDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X - pix), piy + (halfRMAP_Y + (RMAP_Y - piy))); swDist = 1 / linearDist(pix,piy, pix - (halfRMAP_X + pix), piy + (halfRMAP_Y + (RMAP_Y - piy))); centDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X - pix), piy - (piy - halfRMAP_Y)); float sum = sDist + wDist + swDist + centDist; sDist = sDist / sum; wDist = wDist / sum; swDist = swDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = sw*swDist + s*sDist + w*wDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } else if(quadrant == 3) { //se quadrant //pix >= halfRMAP_X //piy >= halfRMAP_Y float seDist = 0; float sDist = 0; float eDist = 0; float centDist = 0; eDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X + (RMAP_X - pix)), piy - (piy - halfRMAP_Y)); sDist = 1 / linearDist(pix,piy, pix - (pix - halfRMAP_X), piy + (halfRMAP_Y + (RMAP_Y - piy))); seDist = 1 / linearDist(pix,piy, pix + (halfRMAP_X + (RMAP_X - pix)), piy + (halfRMAP_Y + (RMAP_Y - piy))); centDist = 1 / linearDist(pix,piy, pix - (pix - halfRMAP_X), piy - (piy - halfRMAP_Y)); float sum = sDist + eDist + seDist + centDist; sDist = sDist / sum; eDist = eDist / sum; seDist = seDist / sum; centDist = centDist / sum; world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = se*seDist + s*sDist + e*eDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } } } My results are below: as you can see, things don't line up correctly and some other stuff isn't working out correctly. It looks like it is something with the se quadrant, because it seems from the shore in the 2nd picture that the sw & ne quadrants will line up, but I'm not sure. [Edited by - polpoint on September 28, 2009 7:08:48 PM]
  11. ok - now I am having trouble with implementation: for(int pix = 0; pix < RMAP_X; pix++) { for(int piy = 0; piy < RMAP_Y; piy++) { quadrant = -1; if(pix < (halfRMAP_X) && piy <(halfRMAP_Y)) { quadrant = 0; } else if(pix >= (halfRMAP_X) && piy < (halfRMAP_Y)) { quadrant = 1; } else if(pix < (halfRMAP_X) && piy >= (halfRMAP_Y)) { quadrant = 2; } else if(pix >= (halfRMAP_X) && piy >= (halfRMAP_Y)) { quadrant = 3; } //find the percentages ! //now we interpolate between the current square and three of it's neighbors. if(quadrant == 0) { //nw //get the elevations of the west, north & nw float wDist = 1 / (linearDist(pix, piy, halfRMAP_X + pix, halfRMAP_Y - piy)); float nDist = 1 / (linearDist(pix, piy, halfRMAP_X - pix, halfRMAP_Y + piy)); float nwDist = 1 / (linearDist(pix, piy, halfRMAP_X + pix, halfRMAP_Y + piy)); float centDist = 1 / (linearDist(pix, piy ,halfRMAP_X - pix, halfRMAP_Y - piy)); float sum = wDist + nDist + nwDist + centDist; wDist = wDist / sum; nDist = nDist / sum; nwDist = nwDist / sum; centDist = centDist / sum; //this is so I can check on the values ddp.str(""); ddp<<wDist<<","<<nDist<<","<<nwDist<<"["<<centDist<<"]-("<<pix<<","<<piy<<")-"<<sum; setMess(ddp.str()); //set the elvation world.wMap[wX][wY].area.aMap[aX][aY].region.rMap[pix][piy].elevation = nw*nwDist + n*nDist + w*wDist + world.wMap[wX][wY].area.aMap[aX][aY].region.baseHt*centDist; } } } float linearDist(float x1,float y1,float x2,float y2) { float dx = x2 - x1; float dy = y2 - y1; return sqrt(dx*dx+dy*dy); } I am getting results like this (in the nw quadrant of square 1,1): if square 1,1's elevation == 4 +---0,0---+---1,0---+ |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? 3 ? ?|? ? 9 ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... +---0,1---+---1,1---+ |? ? ? ? ?|2 2 2 ? ?|... |? ? ? ? ?|2 3 2 ? ?|... |? ? 5 ? ?|2 2 2 ? ?|... |? ? ? ? ?|? ? ? ? ?|... |? ? ? ? ?|? ? ? ? ?|... +---------+---------+ | ... | ... |...
  12. Hodgman, that is basically what I was picturing, but it seems so much easier the way you wrote it out than the way I was envisioning it. Thanks!
  13. Hey! I have a 2d-grid of squares. Each square contains it's own grid of lets say 11x11 squares. Every square also has an elevation value. I want to average out the elevation of the little squares within one of the larger squares with the surrounding larger squares elevations. Basically I want the middle small square to equal it's large square's elevation and the little squares surrounding that to gradually equal 1/2 the dif between the original big square's elevation and the neighbor big square's elevation while taking into account at least 2 of the other 7 neighboring large square's elevation. What sorts of solutions are available to solve my problem? [Edited by - polpoint on September 28, 2009 6:41:54 PM]
  14. yeah, that is exactly what I am looking for - thanks SriLumpa!
  15. I am sure it is something as simple as that. Now how do I pick which regionTile[pix][piy].var1, var2, or var3 the function edits?