PDA

View Full Version : HELP - How to create a Shaky effect?



04-14-2002, 11:38 PM
If i'm walking through a pipe,how to create the shaky effect(in terms of view). In 3Dgames if we walk through a tunnel, the walking effect is depicted as a shaky effect(in terms if view). I want to create something like that.

I'm using glLookAt for viewing. I introduced a variable for y axis(which is my updirection) and i keep adding and subtracting(0.2) alternatively.


zz - variable for walking
yy - variable for shaky effect

...
gluLookAt(7, -12+yy, 5+zz, 3, -12, 5, 0, 1, 0);
.....


window_idle()
...
changed yy value to -1 and +1
....


But I can't see the effect. Anything wrong in my logic or this logic won't work to create that effect?

04-15-2002, 03:25 AM
guys, any idea?

Deiussum
04-15-2002, 04:39 AM
You're redrawing the scene after you change gluLookAt, right?

A bit more code might be helpful

DFrey
04-15-2002, 04:41 AM
Try shaking the reference point in addition to shaking the eye point (not necessarily by the same amount or phase). Also you might want to implement a smoother shaking algorithm, one that continuously (or rather piecewise continuously) oscillates rather than makes discrete steps.


[This message has been edited by DFrey (edited 04-15-2002).]

04-15-2002, 10:46 AM
I got it. but now i have new trouble. I'm not able to retain a value in a variable in windows_idle function

window_idle()
{
if (*p=0)
{
yy=yy+1.0;
printf("I'm in");
*p=1;
}
else
{
yy=yy-1.0;
printf("I'm in p= %d",&p);
*p=0;
}
glutPostRedisplay();
}

p is a global pointer and 'pp' holds the value 0 or 1. I assigned the pointer to pp in initialising function. but no effect. it always fails in the if condition and executes the else part. so the viewpoint moves away from the model.

help me guys

DFrey
04-15-2002, 11:07 AM
You have an assignment expression in that if clause rather than a relational expression. Looks like you typed = when you meant ==.

04-15-2002, 10:59 PM
Thanks for pointing out the mistake Mr.Frey. I got it. It works.