indexicality

12-08-2005, 10:33 AM

Trying to simulate this effect by placing a stationary surface(centred at 0,0) and applying texture transforms to give the appearance of movement. I have set the original texture coordinates such that the texture origin lies at the centre of the surface. I can now happily rotate the texture to look in different directions. The problem is when I move forward. I am calculating what I think ought to be the correct translation in x and y to produce the desired effect but whilst the texture moves it doesnt move in the right direction so as to simulate a camera moving forward. Gettin desperate. Here is the relevent code. Any suggestions greatly appreciated.

if (direction == 'l') // left

{

theta = theta + 3 ;

}

if (direction =='r') // right

{

theta = theta - 3 ;

}

if (direction == 'f') // forward

{

txinc = sin(0.0175*theta) ;

tyinc = cos(0.0175*theta) ;

txpos = txpos + txinc ;

typos = typos + tyinc ;

}

glMatrixMode(GL_TEXTURE) ;

glLoadIdentity() ;

glTranslatef(txpos, typos, 0) ;

glRotatef(theta, 0.0,0.0, 1.0) ;

glMatrixMode(GL_MODELVIEW) ;

if (direction == 'l') // left

{

theta = theta + 3 ;

}

if (direction =='r') // right

{

theta = theta - 3 ;

}

if (direction == 'f') // forward

{

txinc = sin(0.0175*theta) ;

tyinc = cos(0.0175*theta) ;

txpos = txpos + txinc ;

typos = typos + tyinc ;

}

glMatrixMode(GL_TEXTURE) ;

glLoadIdentity() ;

glTranslatef(txpos, typos, 0) ;

glRotatef(theta, 0.0,0.0, 1.0) ;

glMatrixMode(GL_MODELVIEW) ;