Forums > Jitter

gl using mouse to move camera around

October 18, 2006 | 10:09 am

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


October 18, 2006 | 11:10 am

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
>
>
>
>


October 18, 2006 | 11:21 am

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 3×3 rotation matrix can
be calculateed from the axis/angle representation. Note also that
along the diagonal of the 3×3 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
>
>
>
>


October 18, 2006 | 1:37 pm

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


October 18, 2006 | 1:44 pm

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 3×3 rotation matrix can
> be calculateed from the axis/angle representation. Note also that
> along the diagonal of the 3×3 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.
>
>
>


October 18, 2006 | 3:59 pm

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 3×3 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 3×3 rotation matrix can
> > be calculateed from the axis/angle representation. Note also that
> > along the diagonal of the 3×3 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.
> >
> >
> >
>
>
>
>
>


October 18, 2006 | 4:18 pm

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

#P user jit.pwindow 29 33 100 73 1 0 0 0 1 1;
#X name handle;
#P objectname $1_camera;
#P hidden outlet 248 352 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P hidden newex 389 374 34 196617 t 750;
#P hidden newex 389 355 61 196617 mousefilter;
#P hidden newex 452 355 27 196617 t 30;
#P hidden newex 450 49 55 196617 loadbang;
#P hidden message 502 156 313 196617 reset , color 0.5 0.5 0.5 1. ,
poly_mode 1 1 , shapeslice 5 , plane 0.8;
#P hidden newex 502 206 95 196617 jit.gl.sketch handle;
#P window linecount 2;
#P hidden newex 248 308 256 196617 jit.gl.handle handle @visible 1
@auto_rotate 1 @radius 2 @rgb_axes 0 @tracking 0.3 @inherit_transform 1;
#P window linecount 1;
#P hidden newex 350 394 49 196617 qlim 500;
#P hidden newex 367 435 401 196617 jit.gl.render handle @camera 0. 0.
3. @erase_color 1 1 1 1 @two_sided 0 @antialias 1;
#P hidden newex 367 413 49 196617 t b erase;
#P comment 67 354 174 196617 out to other GL objects to be rotated;
#P hidden connect 6 0 5 0;
#P hidden connect 7 0 3 0;
#P hidden connect 7 0 10 0;
#P hidden connect 7 0 6 0;
#P hidden connect 12 1 9 0;
#P hidden connect 12 1 8 0;
#P hidden fasten 8 0 3 1 457 392 394 392;
#P hidden connect 10 0 3 1;
#P hidden connect 9 0 10 0;
#P hidden fasten 3 0 1 0 355 412 372 412;
#P hidden fasten 3 0 2 0 355 432 372 432;
#P hidden connect 1 0 2 0;
#P hidden fasten 1 1 2 0 411 433 372 433;
#P hidden connect 4 0 11 0;
#P hidden connect 4 0 3 0;
#P window clipboard copycount 13;

If you move the main camera system, make sure to use an
inherit_transform 1, otherwise things get wonky.

v a d e //

http://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
>


October 18, 2006 | 4:20 pm

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.

v a d e //

http://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 3×3 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 3×3 rotation
>> matrix can
>> > be calculateed from the axis/angle representation. Note also that
>> > along the diagonal of the 3×3 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.
>> >
>> >
>> >
>>
>>
>>
>>
>>


October 18, 2006 | 6:08 pm

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


October 18, 2006 | 7:45 pm

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
>
>
>


October 19, 2006 | 10:20 am

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


Viewing 11 posts - 1 through 11 (of 11 total)