Forums > Jitter

2d on top of 3d

July 31, 2008 | 10:25 am

I have been using opengl to draw a 3d graph in real time of some positional data. what i want to do is layer some transparent 2d graphs or drawings ontop of the 3d graph. I am using blend to create the transparency but i cant seem to work out how to draw 2d images on top of 3d.

the 3d graph is drawn using jit.gl.gridshape and uses handle + camera positions to navigate around it. automatic is set off for all the objects so i can control the drawing order…

any ideas?

thanks

david


July 31, 2008 | 11:42 am

a start,

http://www.cycling74.com/forums/index.php?t=msg&goto=66889

On Thu, Jul 31, 2008 at 12:25 PM, David Bradshaw wrote:

>
> I have been using opengl to draw a 3d graph in real time of some positional
> data. what i want to do is layer some transparent 2d graphs or drawings
> ontop of the 3d graph. I am using blend to create the transparency but i
> cant seem to work out how to draw 2d images on top of 3d.
>
> the 3d graph is drawn using jit.gl.gridshape and uses handle + camera
> positions to navigate around it. automatic is set off for all the objects
> so i can control the drawing order…
>
> any ideas?
>
> thanks
>
> david
>
>
>


July 31, 2008 | 7:39 pm

Cheers, that does the trick but it seems to be very expensive, presumably due to constantly changing viewing angles. any ideas how i could speed it up
?

thanks

david


July 31, 2008 | 8:03 pm

no, it ok to change viewing angle, a patch?

On Thu, Jul 31, 2008 at 10:39 PM, David Bradshaw wrote:

>
> Cheers, that does the trick but it seems to be very expensive, presumably
> due to constantly changing viewing angles. any ideas how i could speed it
> up
> ?
>
> thanks
>
> david
>


July 31, 2008 | 8:56 pm

not sure exactly what you want without a patch, but couldn’t you just use @transform_reset 1 or 2 on your 2D elements?


July 31, 2008 | 10:18 pm

hi

here is a test patch that should show what i am after

i need the plane and the sphere to be in 3d and be able to be controlled using handle

i need the text and the ellipse to be in 2d and ontop of the 3d objects

The patch shown works but it is very slow on my computer (which in fairness isnt very powerful but it does handle the rest of my jitter work OK)

I am aware of what transform_reset should do but none of the objects seem to have it listed as an attribute…

thanks

david

max v2;
#N vpatcher 0 0 1024 692;
#P origin 0 50;
#P window setfont "Sans Serif" 9.;
#P comment 658 443 100 9109513 < - 2D stuff;
#P newex 331 77 63 9109513 jit.window foo;
#P newex 123 286 33 9109513 v rot;
#P newex 87 286 34 9109513 v pos;
#P newex 165 95 83 9109513 prepend position;
#P newex 248 121 33 9109513 v rot;
#P newex 165 121 34 9109513 v pos;
#P newex 165 59 93 9109513 route position;
#P newex 24 456 70 9109513 jit.gl.render foo;
#P toggle 330 560 15 0;
#P message 254 559 74 9109513 blend_enable $1;
#P flonum 361 492 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 281 522 92 9109513 pak color 0. 0. 0. 0.;
#P flonum 235 492 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 189 523 90 9109513 pak position 0. 0. 0.;
#P message 185 465 73 9109513 ellipse 0.1 0.4;
#P newex 167 581 144 9109513 jit.gl.sketch foo @depth_enable 0;
#P newex 166 304 40 9109513 t b b b;
#P message 197 326 234 9109513 lookat 0. 0. 0. , position 0. 0. 0. , rotate 0. 0. 0. 1.;
#P flonum 211 200 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 165 231 90 9109513 pak position 0. 0. 0.;
#P newex 165 257 283 9109513 jit.gl.gridshape foo @lighting_enable 1 @depth_enable 1 @shape sphere @color 1. 1. 1. 1. @automatic 0 @scale 0.02 @color 1 0 0;
#B color 5;
#P window setfont Tahoma 10.;
#P flonum 321 364 35 10 0 0 0 282 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 282 394 96 18481162 pak position 0. 0. 2.;
#P message 186 392 48 18481162 text hello;
#P newex 182 425 313 18481162 jit.gl.text2d foo @automatic 0 @inherit_transform 0 @depth_enable 0;
#P window setfont "Sans Serif" 9.;
#P newex 165 35 71 9109513 jit.gl.handle foo;
#P toggle 22 62 15 0;
#P newex 22 88 34 9109513 qmetro;
#P newex 22 111 79 9109513 t b b b b b erase;
#P newex 164 163 278 9109513 jit.gl.gridshape foo @lighting_enable 0 @depth_enable 1 @poly_mode 1 1 @shape plane @color 1. 1. 1. 1. @automatic 0;
#B color 5;
#P user panel 161 158 325 142;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 161 301 487 303;
#X brgb 191 191 191;
#X frgb 0 0 0;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P comment 509 201 100 9109513 < - 3D stuff;
#P comment 404 584 100 9109513;
#P connect 7 0 6 0;
#P connect 6 0 5 0;
#P connect 5 5 26 0;
#P connect 5 0 26 0;
#P connect 31 0 26 0;
#P connect 32 0 26 0;
#P connect 16 0 26 0;
#P connect 5 4 31 0;
#P connect 5 4 32 0;
#P connect 5 3 4 0;
#P connect 8 0 27 0;
#P connect 27 0 30 0;
#P connect 30 0 28 0;
#P connect 14 0 13 0;
#P connect 5 2 13 0;
#P connect 5 1 17 0;
#P connect 17 0 18 0;
#P connect 20 0 18 0;
#P connect 19 0 18 0;
#P connect 22 0 18 0;
#P connect 24 0 18 0;
#P connect 11 0 9 0;
#P connect 10 0 9 0;
#P connect 17 1 9 0;
#P connect 15 0 14 1;
#P connect 17 2 16 0;
#P connect 21 0 20 1;
#P connect 15 0 14 2;
#P connect 21 0 20 2;
#P connect 15 0 14 3;
#P connect 27 1 29 0;
#P connect 25 0 24 0;
#P connect 12 0 11 1;
#P fasten 12 0 11 2 343 396;
#P connect 23 0 22 4;
#P pop;


July 31, 2008 | 11:09 pm

try this:

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 488 73 48 196617 loadbang;
#P message 26 287 34 196617 reset;
#P newex 17 308 182 196617 jit.gl.handle foo @inherit_transform 1;
#P newex 228 96 176 196617 t b b b b;
#P newex 228 70 52 196617 r thebang;
#P toggle 726 288 15 0;
#P message 650 287 82 196617 blend_enable $1;
#P flonum 757 220 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 679 250 99 196617 pak color 0. 0. 0. 0.;
#P flonum 633 220 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 587 251 99 196617 pak position 0. 0. 0.;
#P message 583 193 75 196617 ellipse 0.1 0.4;
#P newex 563 309 177 196617 jit.gl.sketch foo @transform_reset 1;
#P flonum 273 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 227 265 99 196617 pak position 0. 0. 0.;
#P window linecount 2;
#P newex 227 291 305 196617 jit.gl.gridshape foo @lighting_enable 1 @depth_enable 1 @shape sphere @color 1. 1. 1. 1. @automatic 0 @scale 0.02 @color 1 0 0;
#B color 5;
#P window setfont Tahoma 10.;
#P flonum 719 92 35 10 0 0 0 -22912 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 680 122 98 -1501560822 pak position 0. 0. 2.;
#P message 584 120 50 -1501560822 text hello;
#P newex 575 161 229 -1501560822 jit.gl.text2d foo @automatic 0 @transform_reset 1;
#P window setfont "Sans Serif" 9.;
#P window linecount 2;
#P newex 228 200 292 196617 jit.gl.gridshape foo @lighting_enable 0 @depth_enable 1 @poly_mode 1 1 @shape plane @color 1. 1. 1. 1. @automatic 0;
#B color 5;
#P window linecount 1;
#P message 35 219 68 196617 fullscreen $1;
#P toggle 18 219 15 0;
#P newex 60 194 35 196617 sel 27;
#P newex 18 194 40 196617 key;
#P newex 18 239 75 196617 jit.window foo;
#P newex 47 151 52 196617 s thebang;
#P newex 18 173 82 196617 jit.gl.render foo;
#P user jit.fpsgui 72 112 60 196617 0;
#P newex 18 86 66 196617 t b b erase b;
#P toggle 18 35 15 0;
#P newex 18 61 57 196617 qmetro 20;
#P connect 31 0 20 0;
#P connect 31 0 13 0;
#P connect 22 0 21 1;
#P connect 22 0 21 2;
#P connect 18 0 17 1;
#P connect 18 0 17 2;
#P connect 18 0 17 3;
#P connect 15 0 14 1;
#P fasten 15 0 14 2 741 124;
#P connect 25 0 19 0;
#P connect 23 0 19 0;
#P connect 20 0 19 0;
#P connect 21 0 19 0;
#P connect 28 0 19 0;
#P connect 13 0 12 0;
#P connect 14 0 12 0;
#P connect 28 1 12 0;
#P connect 28 2 16 0;
#P connect 28 3 11 0;
#P connect 30 0 29 0;
#P connect 29 0 4 0;
#P connect 27 0 28 0;
#P connect 17 0 16 0;
#P connect 26 0 25 0;
#P connect 24 0 23 4;
#P connect 2 3 3 0;
#P fasten 7 0 8 0 59 211 59 196;
#P connect 2 1 5 0;
#P fasten 9 0 10 0 34 234 34 219;
#P connect 10 0 6 0;
#P fasten 8 0 9 0 65 216 23 216;
#P connect 2 0 4 0;
#P connect 2 2 4 0;
#P connect 0 0 2 0;
#P connect 1 0 0 0;
#P window clipboard copycount 32;


July 31, 2008 | 11:19 pm

i’m a big proponent of the @layer attribute. You will probably also want to set your text2d’s blend_mode to 6 7.

-b


August 1, 2008 | 11:34 am

David Bradshaw skrev:
> hi
>
> here is a test patch that should show what i am after
>
> i need the plane and the sphere to be in 3d and be able to be controlled using handle
>
> i need the text and the ellipse to be in 2d and ontop of the 3d objects
>
> The patch shown works but it is very slow on my computer (which in fairness isnt very powerful but it does handle the rest of my jitter work OK)
>
I’m getting a nice solid 60fps from your patch… just you know, fyi.
Andreas.


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