gl using mouse to move camera around
Hi,
I'm building this interface that looks similar to what "perspective view"
would be in a 3d modelling application. Its basically a horizontal grid
plane with a collection of shapes/models sitting on top. Now I'd like
implement the same mouse interfacing as a regular 3d app, were you can click
and drag on the screen to move the camera viewpoint in relation to the
complete scene.
I started by putting a jit.gl.handle in the middle, but that's as far as I
got. It outputs axis/rotation. How can I convert that to the xyz position of
the camera? Or is this not the way to go?
cheers,
-thijs
i think vade posted a patch like this, search around
2006/10/18, Thijs Koerselman :
>
> Hi,
>
> I'm building this interface that looks similar to what "perspective view"
> would be in a 3d modelling application. Its basically a horizontal grid
> plane with a collection of shapes/models sitting on top. Now I'd like
> implement the same mouse interfacing as a regular 3d app, were you can click
> and drag on the screen to move the camera viewpoint in relation to the
> complete scene.
>
> I started by putting a jit.gl.handle in the middle, but that's as far as I
> got. It outputs axis/rotation. How can I convert that to the xyz position of
> the camera? Or is this not the way to go?
>
> cheers,
>
> -thijs
>
>
>
>
If you want to know where an object is given axis/rotation and
position which handle outputs, take a look at the opengl docs about
the structure of the modelview matrix. It has the basic form:
[R R R T]
[R R R T]
[R R R T]
[0 0 0 1]
where R is rotation and T is translation. the 3x3 rotation matrix can
be calculateed from the axis/angle representation. Note also that
along the diagonal of the 3x3 R matrix are the glScale parameters, but
you probably don't need to worry about this. To find a point given
this matrix, do M*p = p' where M is the matrix above, p is your point
and p' is your new point. Anyway, you might not need to go here, just
thought I'd mention it since you asked.
wes
On 10/18/06, Thijs Koerselman wrote:
> Hi,
>
> I'm building this interface that looks similar to what "perspective view"
> would be in a 3d modelling application. Its basically a horizontal grid
> plane with a collection of shapes/models sitting on top. Now I'd like
> implement the same mouse interfacing as a regular 3d app, were you can click
> and drag on the screen to move the camera viewpoint in relation to the
> complete scene.
>
> I started by putting a jit.gl.handle in the middle, but that's as far as I
> got. It outputs axis/rotation. How can I convert that to the xyz position of
> the camera? Or is this not the way to go?
>
> cheers,
>
> -thijs
>
>
>
>
On 10/18/06, yair reshef wrote:
>
> i think vade posted a patch like this, search around
>
>
I found the patch, but it's not what I'm looking for. Vade's patch has 4
fixed camera settings and some breakpoint functions to move the camera
around. I'm looking for one viewport with a mouse interface similar to using
an objects with a gl.handle. Only I want to move around the camera instead
of one object.
-thijs
Thanks Wes, but this is exactly where my math knowledge is lacking. I'll try
to read through the docs and see if I can figure it out, but for now I have
no clue. It would be great though if I could finally understand these matrix
calculations, cause I seem to keep running into them.
-thijs
On 10/18/06, Wesley Smith wrote:
>
> If you want to know where an object is given axis/rotation and
> position which handle outputs, take a look at the opengl docs about
> the structure of the modelview matrix. It has the basic form:
>
> [R R R T]
> [R R R T]
> [R R R T]
> [0 0 0 1]
>
> where R is rotation and T is translation. the 3x3 rotation matrix can
> be calculateed from the axis/angle representation. Note also that
> along the diagonal of the 3x3 R matrix are the glScale parameters, but
> you probably don't need to worry about this. To find a point given
> this matrix, do M*p = p' where M is the matrix above, p is your point
> and p' is your new point. Anyway, you might not need to go here, just
> thought I'd mention it since you asked.
>
>
>
Well, check out http://en.wikipedia.org/wiki/Rotation_matrix Under the
heading Three Dimensions is the equation M(v, theta) that shows the
equation for converting from axis/angle to a 3x3 rot matrix.
wes
On 10/18/06, Thijs Koerselman wrote:
> Thanks Wes, but this is exactly where my math knowledge is lacking. I'll try
> to read through the docs and see if I can figure it out, but for now I have
> no clue. It would be great though if I could finally understand these matrix
> calculations, cause I seem to keep running into them.
>
> -thijs
>
>
>
>
> On 10/18/06, Wesley Smith wrote:
> > If you want to know where an object is given axis/rotation and
> > position which handle outputs, take a look at the opengl docs about
> > the structure of the modelview matrix. It has the basic form:
> >
> > [R R R T]
> > [R R R T]
> > [R R R T]
> > [0 0 0 1]
> >
> > where R is rotation and T is translation. the 3x3 rotation matrix can
> > be calculateed from the axis/angle representation. Note also that
> > along the diagonal of the 3x3 R matrix are the glScale parameters, but
> > you probably don't need to worry about this. To find a point given
> > this matrix, do M*p = p' where M is the matrix above, p is your point
> > and p' is your new point. Anyway, you might not need to go here, just
> > thought I'd mention it since you asked.
> >
> >
> >
>
>
>
>
>
yeah that other patch is a keyframe animator that moves the camera,
however, here is a patch I use to rotate/move the objects in my
patch, based off of a second jit.gl.handle/render system, so you even
have a preview of where things are.
I removed some other crap I had in the patch, but you can add
position/rotation controls as messages to jit.gl.handle in the
subpatcher, as well as name the pwindow/renderer #1_handle or
somesuch so it can be resused
If you move the main camera system, make sure to use an
inherit_transform 1, otherwise things get wonky.
v a d e //
www.vade.info
abstrakt.vade.info
On Oct 18, 2006, at 9:37 AM, Thijs Koerselman wrote:
>
> On 10/18/06, yair reshef wrote:
> i think vade posted a patch like this, search around
>
>
> I found the patch, but it's not what I'm looking for. Vade's patch
> has 4 fixed camera settings and some breakpoint functions to move
> the camera around. I'm looking for one viewport with a mouse
> interface similar to using an objects with a gl.handle. Only I want
> to move around the camera instead of one object.
>
> -thijs
>
hehe, I try to avoid that sort of math as much as possible and figure
out some hacks to re-use the jitter objects that have this already
coded (see the patch I posted above).
What might be helpful are these paches Pelado posted a while back
very nicely done.
v a d e //
www.vade.info
abstrakt.vade.info
On Oct 18, 2006, at 11:59 AM, Wesley Smith wrote:
> Well, check out http://en.wikipedia.org/wiki/Rotation_matrix Under the
> heading Three Dimensions is the equation M(v, theta) that shows the
> equation for converting from axis/angle to a 3x3 rot matrix.
>
> wes
>
> On 10/18/06, Thijs Koerselman wrote:
>> Thanks Wes, but this is exactly where my math knowledge is
>> lacking. I'll try
>> to read through the docs and see if I can figure it out, but for
>> now I have
>> no clue. It would be great though if I could finally understand
>> these matrix
>> calculations, cause I seem to keep running into them.
>>
>> -thijs
>>
>>
>>
>>
>> On 10/18/06, Wesley Smith wrote:
>> > If you want to know where an object is given axis/rotation and
>> > position which handle outputs, take a look at the opengl docs about
>> > the structure of the modelview matrix. It has the basic form:
>> >
>> > [R R R T]
>> > [R R R T]
>> > [R R R T]
>> > [0 0 0 1]
>> >
>> > where R is rotation and T is translation. the 3x3 rotation
>> matrix can
>> > be calculateed from the axis/angle representation. Note also that
>> > along the diagonal of the 3x3 R matrix are the glScale
>> parameters, but
>> > you probably don't need to worry about this. To find a point given
>> > this matrix, do M*p = p' where M is the matrix above, p is your
>> point
>> > and p' is your new point. Anyway, you might not need to go
>> here, just
>> > thought I'd mention it since you asked.
>> >
>> >
>> >
>>
>>
>>
>>
>>
On 10/18/06, vade wrote:
>
> hehe, I try to avoid that sort of math as much as possible and figure out
> some hacks to re-use the jitter objects that have this already coded (see
> the patch I posted above).
> What might be helpful are these paches Pelado posted a while back
>
> http://www.pelado.co.uk/?cat=4
>
> very nicely done.
>
I figured it out. I was a lot easier than I thought, but the patches were an
eyeopener. For now I only need a handle to the render context with
@inherit_transform 1. I'll look into matrix calculations later on. For now
I'm all set. Thanks a lot everyone.
cheers,
-thijs
If you get stuck again, and you don't mind using a little Javascript,
you could investigate the handy matrix functions in Jitter3Dutils.js.
-Randy
On Oct 18, 2006, at 11:08 AM, Thijs Koerselman wrote:
>
> On 10/18/06, vade wrote:
> hehe, I try to avoid that sort of math as much as possible and
> figure out some hacks to re-use the jitter objects that have this
> already coded (see the patch I posted above).
>
> What might be helpful are these paches Pelado posted a while back
>
> http://www.pelado.co.uk/?cat=4
>
> very nicely done.
>
>
> I figured it out. I was a lot easier than I thought, but the
> patches were an eyeopener. For now I only need a handle to the
> render context with @inherit_transform 1. I'll look into matrix
> calculations later on. For now I'm all set. Thanks a lot everyone.
>
> cheers,
> -thijs
>
>
>
On 10/18/06, Randy Jones wrote:
>
>
>
> If you get stuck again, and you don't mind using a little Javascript,
> you could investigate the handy matrix functions in Jitter3Dutils.js.
>
> -Randy
Thanks for the tip. I do most of my jittering in js lately so thats only a
plus :-)
best, -thijs