gl orientation and "moving forward"
i’m sure this is obvious… apologies if so.
i’m testing something out for a project (after a while from jsui) and just trying to
rotate + ‘move forward’,
but can’t figure out what’s going wrong…
do i have to use jitter-js and import the jitter-utils?
so far, i’ve got:
var origin = [0,0,0];
var length = 0.5;
line(0,length,0); //draw a line up w/ reg orient
moveto(0,length,0); //move to line’s end loc
glrotate(90,0,0,1); //rotate 90 cw
line(0,length,0); //draw another line w/ new orient???
thanks so much,
what i meant to write rather than glrotate was
anyway; the point is that i’m trying to change the orientation of the ‘sketch perspective’
could this be accomplished with gl command?
On Jan 8, 2008, at 10:56 PM, jLubow wrote:
> what i meant to write rather than glrotate was
> anyway; the point is that i’m trying to change the orientation of
> the ‘sketch perspective’
> could this be accomplished with gl command?
Yes with gltranslate()/glrotate(). You won’t accomplish it with
moveto/shapeorient as these just affect the specific drawing
primitives rather than the OpenGL state. Please see the Jitter sketch
tutorial (40), and even better, the OpenGL RedBook for more
information on how to transform the modelview matrix. Changes are
you’ll want to use glmatrixpush/glmatrixpop. Search jitter mailing
list archives for more details. The commands in the JS Sketch class
and jit.gl.sketch are essentially the same.
thank you joshua.
It’s nice to experiment with the js so you can determine the commands that are possible, and be able to do just what you want. That said, you should also look at jit.gl.sketch and its cousins (gridshape is another good one) since there’s a lot taken care of already, and may be better optimized (?). I did a lot of stuff within jsui, and while I don’t regret the time spent fiddling, there was a lot ready-to-go in the jit.gl.sketch that I should have explored first, which can readily take advantage of simple max messages (i.e., "color 1. 0. 0. 0.5" for red at 50% alpha, formatted thru a swatch and a slider).
Not only that, but you can then attach a jit.gl.handle to your Render object, so you can accomplish lots of perspective changing intuitively. Most of the commands to jit.gl.sketch also work for jit.gl.render, so stuff like "rotatexyz" will work on an object-by-object basis for the jit.gl.sketch parts, and a scene basis for the jit.gl.render part (with multiple streams going at once if you want). Controlling things like color / alpha, blend modes, line width or point size, etc., is easy and gives you a lot of options…. textures are also readily available to apply to whatever shapes you have.
For more crazy fun check out jit.gl.model and use a 3D program to generate some .obj models, then use them in your sketch scene… great stuff!
Yes, it’s fun to work with jit.gl.sketch w/ js.
But when you don’t have jitter on a given machine, it’s always nice to have a backup. :)
I don’t mind spending the time if I can port the code over in some fashion…