News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Help needed!

Started by Raa, May 25, 2010, 03:26:24 PM

Previous topic - Next topic

Raa

Hi, I started programming a 3d world in Opengl. But i spend a lot of time trying to solve one case.  :(
How to make an object to rotate for some angle when Camera gets closer to it???
For Camera movement i use gluLookAt.

oex

You will need to post some code for a proper answer but use


Change Angle each frame to rotate
invoke glRotatef, Angle,CFLT(0.0),CFLT(1.0),CFLT(0.0) <---- rotates on Y axis
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Raa

I walk in a scene using gluLookAt to move camera:
...
gluLookAt(
position[0], position[1], position[2], // eye
position[0]+STEP*cos(viewAngle*DEG_TO_RAD), position[1]+STEP * sin(slope * DEG_TO_RAD), position[2] + STEP * sin(viewAngle * DEG_TO_RAD), // center(center-eye)
0.0, position[1]+sin(slope*DEG_TO_RAD), 0.0  // up vector
);

...
i just +/- STEP when i move...  and use mouse to turn viewing angle.

the position of the object(which is OBJ) is only translated to the place i need. it is constant. all i need is kinda make a circle around this object, so when camera gets inside this circle the object rotates once to some angle. When camera gets out of the circle the object turns back to his basic position. 

any ideas?

oex

You want to get distance from the object with

SQUAREROOT X2+Y2+Z2

http://freespace.virgin.net/hugo.elias/routines/r_dist.htm

And rotate the object as I indicated above
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Raa


oex

We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv