Re: Viewpoint rotating around a sphere



Hi Pete,

I would use gluLookAt, which lets you actually position the camera (in
contrast to what was said in this group before). gluLookAt takes three
3D-vectors as arguments. The first is the position of the eye (the camera),
the second the center to where it is looking at (this would be constant in
your case) and the third is the up direction (changing this, lets your view
roll around the view direction).

In your case the center is constant the position of your model. If you move
the mouse up, you want to change the y-coordinate of the camera, as it
points upwards. The x coordinate would be constant, as you don´t move the
mouse in that direction. Now you have to consider, that you want to move on
a sphere. The formula for a sphere is x^2 + y^2 + z^2 = Radius. This means,
that the z-coordinate follows directly from your x-coordinate, the new
y-coordinate and the radius of the sphere. What is left is the up vector. I
guess, you could can leave the coordinates zero, as it adjusts itself, but I
am not sure about that. So just try it.

I hope this was useful,
Alex


"Pete" <pdavis68@xxxxxxxxxxxxxxxxxxx> schrieb im Newsbeitrag
news:ufednTSZ4qbJk6HbnZ2dnUVZ_hynnZ2d@xxxxxxxxxxxxxxx
Okay, I'm still not getting it. I suspect it has to do with the order that
I'm doing things.

I've tried a bunch of different orders and I can't seem to quite get it
right. If I take rotation out of the equation altogether, it works fine,
of
course, except that it doesn't rotate

Basically I'm drawing a bunch of atoms (gluSphere) and a bunch of bond
(gluCylinder).

so assuming it's something like this:

public void DrawAtoms(AtomCollection atoms)
{
foreach(Atom atom in atoms)
{
GL.glLoadIdentity();
GL.glTranslatef((float)atom.Location.X * 10, (float)atom.Location.Y *
10, (float)(atom.Location.Z * 10) - 100);
GLUquadric q = GL.gluNewQuadric();
GL.gluQuadricDrawStyle(q,GL.GLU_SMOOTH);
GL.gluSphere(q, ((float) atom.Element.CovalentRadius) * 10, 32, 32);
GL.gluDeleteQuadric(q);
}

That all works fine if I use the Identity matrix as the starting point for
each atom. The problem is, I don't want to do the rotation based on the
identity matrix. So how do I apply the rotation matrix that's not based on
the identity matrix but still be able to use the identity matrix for
translating everything?

Or am I going about this all wrong?

Thanks. I really appreciate how helpful you guys have been.

Pete

"Pete" <pdavis68@xxxxxxxxxxxxxxxxxxx> wrote in message
news:l4udna9wNsbNRKbbnZ2dnUVZ_r-onZ2d@xxxxxxxxxxxxxxx
Thank you guys for you help. I'll rework the code to deal with it
properly.

Pete

"Andy V" <nobody@xxxxxxxxxxx> wrote in message
news:tqOdnejGy-jwS6bbnZ2dnUVZ_j6dnZ2d@xxxxxxxxxxxxxx
Pete wrote:

I'm confused. Do I do this on the projection matrix or on the model
view
matrix?

I haven't tried it on the model view matrix because I'll have to
reorganize the code a bit to achieve that, so I want to verify before
i
go through the trouble.

You definitely want to do this on the model-view matrix. Reserve the
projection matrix for the basic projection.

I tried doing it on the projection matrix and it doesn't quite work,
but
I think that's because my object is centered at 0, 0, -100, while my
view appears to rotate around 0, 0, 0, which makes sense. What seems
really weird is the lighting seems to change on the molecule when I do
this as well, which is not an effect I want. I want the lighting to
remain relative to the model and indeed, I set up the lighting in the
modelview matrix.

That's why you don't want to put rotation/scaling/translation/etc. in
the
projection matrix -- it confuses the lighting.

--
Andy V






.



Relevant Pages

  • Re: Nikon maintains DSLR lead over Canon
    ... The sensor "moving" systems always have the sensor perpendicular to ... camera moves in translation in the x and y directions. ... What Pentax have added is a rotation around the lens axis (not tilts ...
    (rec.photo.digital.slr-systems)
  • Re: globe trotting?
    ... // First we do the look up and down rotation on the x axis. ... consider storing only a camera origin ... > where R is "big enough" to put the camera outside the sphere. ...
    (comp.graphics.algorithms)
  • Re: globe trotting?
    ... A good camera scheme has a minimal set of "just right" independent ... Assume the world origin at the center of the sphere. ... of the whole camera about the world origin on an axis perpendicular to ... The angle of the rotation is a function of walking speed, ...
    (comp.graphics.algorithms)
  • Re: globe trotting?
    ... A good camera scheme has a minimal set of "just right" independent ... Assume the world origin at the center of the sphere. ... of the whole camera about the world origin on an axis perpendicular to ... The angle of the rotation is a function of walking speed, ...
    (comp.graphics.algorithms)
  • superconductivity
    ... If you have atoms in a lattice and wonder how those do exchange influences, you naturally think about pushes and charges. ... The influence of objects from one to the other I call for some reason influences. ... Mass is the sum of intensities of rotation in a certain hyperarea that is 'flowing' into its future. ... It has a timelike axis and spacelike axis. ...
    (sci.physics.relativity)