texture projection onto jit.gl.model

Jun 13, 2007 at 6:36am

texture projection onto jit.gl.model

Thanks to an example posted here last week, here’s a patch that emulates
texture projection, or more precisely a static projection which is only
projected on objects when they enter a particular part of the screen.

However, the problem I am having is that while torus (jit.gl.gridshape)
updates its texturing information accordingly whenever its position changes
(use fullscreen and drag the object by clicking onto the screen), for the
jit.gl.model, the only way this texturing changes is if the texture is
disabled and reenabled which seems like an awful hack.

Hence, I was wondering if:

1) there is a way to make the jit.gl.gridshape trick work for the
jit.gl.model
2) whether there is a better way of doing the texture projection which would
also avoid texture being wrapped around the object (or projected on both its
sides)? To be more precise here, I am simply looking for a way to project an
invisible video which becomes visible only when an object enters specific
coordinates.

Any help is most appreciated!

Here’s the patch in question:

#P window setfont “Sans Serif” 10.;
#P flonum 98 147 35 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 11 166 98 9109514 pak camera 0. 0. 0.;
#P flonum 598 222 35 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 670 222 35 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 634 222 35 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 596 241 105 9109514 pak rotatexyz 0. 0. 0.;
#P message 670 293 88 9109514 texture proj2 proj;
#P message 670 272 40 9109514 texture;
#P window setfont “Sans Serif” 9.;
#P window linecount 5;
#P comment 778 226 105 9109513 texture coordinates ; 0 – use existing ; 1
- object space ; 2 – reflection ; 3 – eye map;
#P window linecount 1;
#P message 706 242 62 9109513 tex_map $1;
#P number 706 222 35 9 0 3 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 2;
#P newex 13 270 351 9109513 jit.gl.gridshape test @shape torus @color 1 1 1
0.9 @lighting_enable 1 @scale 0.2 0.2 0.2 @tex_map 1 @texture proj2 proj
@blend_enable 1 @smooth_shading 1;
#P window setfont “Sans Serif” 10.;
#P window linecount 1;
#P message 512 243 103 9109514 read mushrooms.obj;
#P newex 381 243 128 9109514 loadmess read tester1.obj;
#P window setfont “Sans Serif” 9.;
#P window linecount 2;
#P newex 381 269 257 9109513 jit.gl.model test @lighting_enable 0
@smooth_shading 1 @scale 0.5 @blend_enable 0 @matrixoutput 0 @tex_map 1;
#P window setfont “Sans Serif” 10.;
#P window linecount 1;
#P newex 454 69 71 9109514 expr $f1*.5+2;
#P message 399 58 39 9109514 store 1;
#N vpreset 1;
#X append 1 2 1 58 0 toggle int 1 ; 4 81 94 toggle int 0 ; 10 199 16
flonum float 0.071111 ; 11 199 53 flonum float -0.291111 ; 12 199 91
flonum float -0.13 ; 13 143 299 flonum float;
#X append 1 2 0. ; 15 163 423 flonum float 1. ; 16 163 460 flonum float 1.
; 17 96 455 flonum float 1. ; 22 164 524 flonum float 0.559259 ; 23 187
646 flonum float 0.257407 ; 27 337 44;
#X append 1 2 toggle int 1 ; 28 337 86 flonum float 30. ; 33 337 243
flonum float 1. ; 39 336 351 toggle int 1 ; 40 336 393 flonum float 30. ;
45 336 550 flonum float 1. ; 55 222 706;
#X append 1 2 number int 0 ; 61 222 634 flonum float 0. ; 62 222 670
flonum float 0. ; 63 222 598 flonum float 90. ;;
#P preset 399 80 47 27;
#P newex 646 164 182 9109514 expr $f1*2.5*($f2*(1/pow($f2\,2)))+0.5;
#P window setfont “Sans Serif” 9.;
#N vpatcher 602 417 966 717;
#P origin 0 -35;
#N comlet y;
#P outlet 104 212 15 0;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 104 123 83 9109513 expr -$i1/450.+0.9;
#P newex 235 141 40 9109513 change;
#P newex 235 118 30 9109513 == 0;
#P toggle 235 163 15 0;
#P window linecount 2;
#P message 235 189 82 9109513 ; jitter cursor $1;
#N comlet x;
#P outlet 23 211 15 0;
#P window linecount 1;
#P newex 23 123 78 9109513 expr $i1/450.-1.4;
#P newex 23 92 65 9109513 unpack 0 0 0;
#N comlet jit.window dump;
#P inlet 23 40 15 0;
#P newex 23 64 63 9109513 route mouse;
#P connect 1 0 0 0;
#P connect 0 0 2 0;
#P connect 2 0 3 0;
#P connect 3 0 4 0;
#P connect 2 1 9 0;
#P connect 9 0 10 0;
#P connect 7 0 8 0;
#P connect 8 0 6 0;
#P connect 6 0 5 0;
#P pop;
#P newobj 138 147 103 9109513 p handle_mouse_data;
#P flonum 550 336 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 550 357 42 9109513 rate $1;
#P message 437 327 77 9109513 read traffic.mov;
#P message 484 357 27 9109513 stop;
#P message 450 357 31 9109513 start;
#P flonum 393 336 35 9 0.5 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 351 336 15 0;
#P newex 351 356 52 9109513 metro 30;
#P message 514 357 31 9109513 clear;
#P newex 351 381 63 9109513 jit.qt.movie;
#P newex 351 409 403 9109513 jit.gl.texture test @bordercolor 1 1 1 1
@blendcolor 1 1 1 0.1 @wrap clampborder @name proj2;
#P window setfont “Sans Serif” 10.;
#P newex 524 140 182 9109514 expr $f1*2.5*($f2*(1/pow($f2\,2)))+0.5;
#P window setfont “Sans Serif” 9.;
#P flonum 243 337 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 243 358 42 9109513 rate $1;
#P message 130 328 83 9109513 read dishes.mov;
#P message 177 358 27 9109513 stop;
#P message 143 358 31 9109513 start;
#P flonum 86 337 35 9 0.5 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P toggle 44 337 15 0;
#P newex 44 357 52 9109513 metro 30;
#P message 207 358 31 9109513 clear;
#P newex 44 382 63 9109513 jit.qt.movie;
#P flonum 646 187 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 524 164 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 491 199 102 9109513 pak anchor 0.5 0.5;
#N vpatcher 716 74 1199 420;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 98 79 60 9109513 unpack 0. 0.;
#P window linecount 1;
#P newex 32 47 109 9109513 route theta zoom anchor;
#P window linecount 0;
#P newex 353 98 27 9109513 t b l;
#P flonum 32 127 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 190 219 27 9109513 * 1.;
#P newex 370 178 27 9109513 * -1.;
#P newex 227 219 27 9109513 * 1.;
#P newex 32 219 27 9109513 * 1.;
#P newex 370 123 60 9109513 unpack 0. 0.;
#P newex 353 76 60 9109513 vexpr 1./$f1;
#P newex 69 219 27 9109513 * -1.;
#P newex 32 149 81 9109513 expr 0.5*cos($f1);
#P newex 209 149 78 9109513 expr 0.5*sin($f1);
#P flonum 301 244 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 264 244 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 227 244 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 190 244 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 191 267 128 9109513 pak tex_plane_t 0. 0.5 0. 0.5;
#P flonum 143 245 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 106 245 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 69 245 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 32 245 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 33 267 130 9109513 pak tex_plane_s 0.5 0. 0. 0.5;
#P inlet 32 25 15 0;
#P outlet 33 297 15 0;
#P connect 1 0 23 0;
#P connect 23 0 21 0;
#P fasten 22 0 21 0 358 122 37 122;
#P connect 21 0 13 0;
#P connect 13 0 17 0;
#P connect 17 0 3 0;
#P fasten 7 0 0 0 196 291 38 291;
#P connect 2 0 0 0;
#P fasten 16 0 17 1 375 171 54 171;
#P fasten 3 0 2 1 37 263 68 263;
#P fasten 12 0 14 0 214 182 74 182;
#P connect 14 0 4 0;
#P fasten 19 0 14 1 375 208 91 208;
#P fasten 4 0 2 2 74 263 98 263;
#P connect 23 2 24 0;
#P fasten 5 0 2 3 111 263 128 263;
#P fasten 24 0 6 0 103 104 148 104;
#P fasten 6 0 2 4 148 263 158 263;
#P fasten 12 0 20 0 214 182 195 182;
#P connect 20 0 8 0;
#P fasten 16 1 20 1 425 213 212 213;
#P fasten 21 0 12 0 37 145 214 145;
#P fasten 8 0 7 1 195 263 225 263;
#P fasten 13 0 18 0 37 193 232 193;
#P connect 18 0 9 0;
#P fasten 16 1 18 1 425 213 249 213;
#P fasten 9 0 7 2 232 263 254 263;
#P fasten 10 0 7 3 269 263 283 263;
#P fasten 24 1 11 0 153 108 306 108;
#P fasten 11 0 7 4 306 263 312 263;
#P fasten 23 1 15 0 70 71 358 71;
#P connect 15 0 22 0;
#P connect 22 1 16 0;
#P connect 16 0 19 0;
#P pop;
#P newobj 299 215 94 9109513 p TexCoordMagic;
#P message 299 188 56 9109513 theta $1;
#P newex 299 163 107 9109513 expr $f1*3.14/180;
#P flonum 455 96 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 460 163 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 423 163 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 393 186 70 9109513 pak zoom 1. 1.;
#P flonum 299 143 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 91 199 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 53 199 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 16 199 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 13 220 99 9109513 pak position 0. 0. 0.;
#P newex 44 410 305 9109513 jit.gl.texture test @bordercolor 1 1 1 1
@blendcolor 1 1 1 1 @name proj;
#N vpatcher 10 59 171 198;
#P window setfont “Sans Serif” 9.;
#P window linecount 0;
#P newex 74 79 41 9109513 s draw;
#P window linecount 1;
#P newex 50 50 58 9109513 t b b erase;
#P inlet 50 30 15 0;
#P outlet 50 79 15 0;
#P connect 1 0 2 0;
#P fasten 2 2 0 0 103 73 55 73;
#P lcolor 13;
#P connect 2 0 0 0;
#P connect 2 1 3 0;
#P pop;
#P newobj 0 100 42 9109513 p Draw;
#P message 94 100 70 9109513 fullscreen $1;
#N vpatcher 10 59 170 225;
#P window setfont “Sans Serif” 9.;
#P newex 50 72 38 9109513 sel 27;
#P newex 50 50 40 9109513 key;
#P outlet 50 94 15 0;
#P connect 1 0 2 0;
#P connect 2 0 0 0;
#P pop;
#P newobj 94 60 33 9109513 p Esc;
#P toggle 94 81 15 0;
#P newex 94 120 151 9109513 jit.window test @depthbuffer 1;
#P newex 0 78 57 9109513 qmetro 33;
#P toggle 0 58 15 0;
#P newex 0 121 86 9109513 jit.gl.render test;
#P connect 1 0 2 0;
#P connect 2 0 7 0;
#P connect 64 0 0 0;
#P connect 7 0 0 0;
#P connect 20 0 54 0;
#P connect 9 0 54 0;
#P connect 46 0 10 0;
#P connect 10 0 9 1;
#P connect 27 0 26 0;
#P fasten 26 0 24 0 49 378 49 378;
#P fasten 32 0 24 0 248 377 49 377;
#P fasten 25 0 24 0 212 377 49 377;
#P fasten 30 0 24 0 182 377 49 377;
#P fasten 29 0 24 0 148 377 49 377;
#P fasten 31 0 24 0 135 377 49 377;
#P connect 24 0 8 0;
#P connect 46 1 11 0;
#P connect 11 0 9 2;
#P connect 28 0 26 1;
#P connect 5 0 4 0;
#P connect 4 0 6 0;
#P connect 6 0 3 0;
#P connect 65 0 64 3;
#P connect 12 0 9 3;
#P connect 3 1 46 0;
#P connect 33 0 32 0;
#P connect 13 0 18 0;
#P connect 18 0 19 0;
#P fasten 14 0 20 0 398 211 304 211;
#P connect 19 0 20 0;
#P connect 21 0 20 0;
#P connect 39 0 38 0;
#P fasten 43 0 36 0 442 376 356 376;
#P fasten 41 0 36 0 455 376 356 376;
#P fasten 42 0 36 0 489 376 356 376;
#P fasten 37 0 36 0 519 376 356 376;
#P fasten 44 0 36 0 555 376 356 376;
#P fasten 38 0 36 0 356 377 356 377;
#P connect 36 0 35 0;
#P connect 20 0 51 0;
#P connect 9 0 51 0;
#P connect 60 0 51 0;
#P connect 59 0 51 0;
#P connect 56 0 51 0;
#P connect 52 0 51 0;
#P connect 53 0 51 0;
#P connect 58 0 51 0;
#P connect 40 0 38 1;
#P connect 49 0 48 0;
#P connect 17 0 15 0;
#P connect 15 0 14 1;
#P fasten 16 0 14 2 465 182 458 182;
#P connect 12 0 50 0;
#P connect 50 0 17 0;
#P connect 17 0 16 0;
#P connect 10 0 34 0;
#P connect 34 0 22 0;
#P connect 22 0 21 1;
#P connect 45 0 44 0;
#P connect 23 0 21 2;
#P connect 63 0 60 1;
#P connect 11 0 47 0;
#P connect 47 0 23 0;
#P connect 61 0 60 2;
#P connect 62 0 60 3;
#P connect 17 0 34 1;
#P connect 55 0 56 0;
#P connect 17 0 47 1;
#P window clipboard copycount 66;

Best wishes,

Ivica Ico Bukvic, D.M.A.
Composition, Music Technology, CCTAD, CHCI
Virginia Tech
Dept. of Music – 0240
Blacksburg, VA 24061
(540) 231-1137
(540) 231-5034 (fax)
ico@vt.edu
http://www.music.vt.edu/people/faculty/bukvic/

http://ico.bukvic.net

#32439

You must be logged in to reply to this topic.