# Thread: HELP - How to create a Shaky effect?

1. ## HELP - How to create a Shaky effect?

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?

2. ## Re: HELP - How to create a Shaky effect?

guys, any idea?

3. ## Re: HELP - How to create a Shaky effect?

You're redrawing the scene after you change gluLookAt, right?

A bit more code might be helpful

4. ## Re: HELP - How to create a Shaky effect?

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).]

5. ## Re: HELP - How to create a Shaky effect?

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

6. ## Re: HELP - How to create a Shaky effect?

You have an assignment expression in that if clause rather than a relational expression. Looks like you typed = when you meant ==.

7. ## Re: HELP - How to create a Shaky effect?

Thanks for pointing out the mistake Mr.Frey. I got it. It works.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•