Jump to content

  • Log In with Google      Sign In   
  • Create Account


polpoint

Member Since 13 Jul 2006
Offline Last Active Mar 08 2012 09:19 AM

Posts I've Made

In Topic: Problem with SAPI Dynamic Grammars in C++

06 March 2012 - 11:11 AM

I have broken everything down to its simplest form:
http://www.mediafire.com/?xwevgekf8ndrrpv
(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"

In Topic: Am I dreaming far too big, even if I know how all of it will work?

22 February 2011 - 04:06 PM

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.

In Topic: Need help with some errors in my bilinear interpolation function

01 October 2009 - 06:05 PM

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.

In Topic: Need help with some errors in my bilinear interpolation function

30 September 2009 - 11:30 AM

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?|
|???|???|???|
+---+---+---+


In Topic: Need help with some errors in my bilinear interpolation function

30 September 2009 - 07:49 AM

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;
}
}



PARTNERS