Monday, April 21, 2008

Coordinates in OpenGL

Here is a patch that lets you play with a 3-D Cartesian coordinate system using OpenGL.
OpenGL uses Cartesian coordinates x, y, z for placement of objects, light source, viewpoint and focus point. The code is in the comments section.

1 comment:

Tony said...

max v2;
#N vpatcher 383 252 709 490;
#P origin -19 51;
#P window setfont "Sans Serif" 9.;
#P flonum 237 108 35 9 -2.5 2.5 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 198 108 35 9 -2.5 2.5 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 159 108 35 9 -2.5 2.5 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont "Sans Serif" 18.;
#P comment 236 77 34 196626 z;
#P comment 198 78 34 196626 y;
#P comment 159 77 34 196626 x;
#P window setfont "Sans Serif" 9.;
#N vpatcher 477 249 1077 649;
#P origin 0 326;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 50 368 86 196617 jit.gl.sketch food;
#P hidden newex 8 62 48 196617 loadbang;
#P message 282 272 227 196617 blend_enable 1 \, depth_enable 1 \, blend_mode 6 1;
#P message 158 359 230 196617 blend_enable 1 \, depth_enable 0 \, blend_mode 6 1;
#P message 110 80 310 196617 blend_enable 0 \, depth_enable 1 \, blend_mode 6 1 \, lighting_enable 1;
#P window linecount 3;
#P message 148 316 321 196617 reset \, glcolor 0. 0.3 0. \, shapeorient 90 0 0 \, moveto 0 \$2 0 \, plane 2.5 \, glcolor 0.3 0. 0. \, shapeorient 0 0 90 \, moveto 0 0 \$3 \, plane 2.5 \, glcolor 0. 0. 0.3 \, shapeorient 0 90 0 \, moveto \$1 0 0 \, plane 2.5;
#P window linecount 1;
#P newex 272 220 89 196617 pak 0. 0. 0.;
#P message 272 254 266 196617 reset \, glcolor 0.5 0.5 0.5 \, moveto \$1 \$2 \$3 \, sphere 0.1;
#P newex 272 292 86 196617 jit.gl.sketch food;
#P window linecount 2;
#P message 93 48 399 196617 reset \, glcolor 0.5 0.5 0.5 \, shapeorient 0 90 0 \, cylinder 0.025 0.025 2.5 \, shapeorient 0 0 0 \, cylinder 0.025 0.025 2.5 \, shapeorient 90 0 0 \, cylinder 0.025 0.025 2.5;
#P window linecount 1;
#P newex 93 109 86 196617 jit.gl.sketch food;
#P inlet 490 126 15 0;
#P inlet 383 126 15 0;
#P inlet 272 128 15 0;
#P connect 8 0 13 0;
#P connect 10 0 13 0;
#P hidden connect 12 0 4 0;
#P connect 4 0 3 0;
#P connect 9 0 3 0;
#P hidden connect 12 0 9 0;
#P hidden connect 12 0 8 0;
#P connect 7 0 8 0;
#P hidden connect 12 0 10 0;
#P hidden connect 12 0 7 0;
#P connect 0 0 7 0;
#P hidden connect 12 0 6 0;
#P connect 7 0 6 0;
#P connect 6 0 5 0;
#P connect 11 0 5 0;
#P hidden connect 12 0 11 0;
#P connect 1 0 7 1;
#P connect 2 0 7 2;
#P pop;
#P newobj 159 128 88 196617 p sketch;
#P hidden message 0 183 70 196617 size 320 240;
#P hidden newex 18 21 50 196617 loadbang;
#P hidden message 2 151 70 196617 camera 2 4 4;
#P newex 72 202 152 196617 jit.window food @depthbuffer 1;
#P newex 72 76 43 196617 jit.qball;
#P number 117 27 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 72 27 15 0;
#P newex 72 53 55 196617 metro 20;
#P newex 72 107 50 196617 t b erase;
#P newex 72 182 87 196617 jit.gl.render food;
#P hidden connect 8 0 9 0;
#P hidden connect 8 0 7 0;
#P hidden connect 8 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 1 0;
#P fasten 1 1 0 0 95 131 77 131;
#P connect 1 0 0 0;
#P hidden fasten 7 0 0 0 7 172 77 172;
#P hidden connect 9 0 6 0;
#P connect 4 0 2 1;
#P connect 14 0 10 0;
#P connect 15 0 10 1;
#P connect 16 0 10 2;
#P pop;