3d Illusion with Kinect Motion Tracking

Serious Cyrus's picture

I'm trying to figure out the fake 3d effect you can get with motion tracking, but not sure if it's completely possible in QC.

I've got a kinect hooked up, and figured out how to do a basic empty 3d box illusion by tracking the head. It just moves the base of the cube around based on head position. Trouble is my simple maths will only work for a box without any translations. I'm sure there must be a proper way to do it with a camera, or skewing a whole scene somehow. I can't get my head around how you would change the camera position, but still keep the top face square to the projection surface.

Can anyone point me in the right direction?

Here's a video of what I've done, hopefully showing what I want to achieve., and attached the comp that works out the base position from the xyz of the head (y&z swapped for different planes)

http://youtu.be/BiS4_-sC8GQ

PreviewAttachmentSize
Fake 3D Box.qtz22.62 KB

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

Thanks for the video, it's def what I'm looking for, nice effect. I reckon I've got enough to pull that off, I was making further improvements last night.

It doesn't help that I can't figure out what you call this kind of perspective shifting, keeping the facing plane flat, surely it has a name?

I've been looking through a few maths papers on the subject. I'd seen the one you posted from utah before, but it's been a long time since I did math, I rarely have to do geometry in my current work so it's all got a bit rusty, struggling through.

My hope was that there was some transform you can apply to many objects, like other patches for transform. As it is, I think I'll have to come up with custom shapes that can figure out the distortion themselves.

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

Wrote something that provides all the coords for a cube with changes for the perspective, and can cope with rotations and such.

I've made a cube with GL Quads which works fine, but why does it go dark when I put it in a lighting patch? Have I missed something? Am I doing something stupid?

PreviewAttachmentSize
Fake 3D Cube.qtz141.94 KB
GL Quad Cube from structure.qtz36.05 KB

gtoledo3's picture
Re: 3d Illusion with Kinect Motion Tracking

The GL Quad generates no normals, which are needed for it to respond to lighting.

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

Thanks! Something new to learn...

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

This is getting me somewhere, I've been looking up everything to do with normals and QC and it's suddenly opened up a whole new world. Reading up on openGL, I think I can accomplish what I want with a Vertex Shader. I'm still reading up on everything, but maybe someone her can speed me along my way.

Basically, I know the exact transform I want to apply to ever vertex, reading on shaders, it seems to me I could just do it with a vertex shader. My question is, can shaders be nested? can they inherit or somehow call the super shaders? I'd like to write a shader that does all the normal computations for perspective, and whatever else it does, then add my transform at the end, I just need to figure out the right calls to make, then I know what I'm working with.

Crispy75's picture
Re: 3d Illusion with Kinect Motion Tracking

You're attempting to implement a 3D engine from scratch in Quartz Composer!

Get the GL Tools http://kineme.net/release/GLTools/16 and use the GL camera controls to move the viewpoint. Buy the 3D Tools http://kineme.net/Kineme3D and put arbitrary 3D objects in your scene

franz's picture
Re: 3d Illusion with Kinect Motion Tracking

you can calculate your normals and apply transforms within one shader.

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

Crispy75 wrote:
You're attempting to implement a 3D engine from scratch in Quartz Composer!

Get the GL Tools http://kineme.net/release/GLTools/16 and use the GL camera controls to move the viewpoint. Buy the 3D Tools http://kineme.net/Kineme3D and put arbitrary 3D objects in your scene

I wonder if I'm getting too ambitious, it certainly doesn't look easy to write the shaders from scratch without any experience I was really hoping to hack stuff already done.

I had thought of using a camera, it seemed the logical way to do it, but I just can't figure out how to keep the top face in my example aligned to the surface I'm projecting on.

Still, I'm trying the 3d tools, i already had the GLtools, but didn't realise QC hid private patches till trying to find that camera patch...

franz wrote:
you can calculate your normals and apply transforms within one shader.

I'm slowly getting my head round what shaders can do, I'm going through the many examples I've found around the web. I found a really cool shader on this site which did the normals, but they all seem so specific, like for individual objects with similar textures. Aren't there a bog standard set of shaders that do a regular simple 3d scene, pretty much the same as renedering the objects supplied in QC, setting colours or just images on surfaces and have shadows work.

Regarding the normals, looking through the 3d tools suggested above, I think I'll be better off making my 3d objects better in QC, with the normals built in, I can just about get my head round that.

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

The GLSL stuff was out of my league for now, I figured out how to do it using meshes and an openCL kernel, it's not a perfect solution as yet, I think something that modifies every coord in the scene would be better. Thanks all for the different approaches, they all help.

Google sketchup turned out to be an invaluable tool, I'd tried using blender, but I found simple stuff very hard without a proper mouse, in sketchup I can quickly build up the 3d models, distorting them with an openCL kernel was very easy with the example given in the mesh filter template. I also figured out how to set the texture in sketchup to make them easy to replace with the get and set mesh texture patches, you just use images of the size you want in QC, then edit the position of the texture in sketchup so 1 instance covers the surface you need, excellent.

blackburst's picture
Re: 3d Illusion with Kinect Motion Tracking

The first video posted is what I'm going for. Has anybody succeeded with this effect in QC? I've toyed around with gl camera, lookat and 3d transforms but there are certain nesting combinations that lead to the 3d transform not doing anything. Even if somebody can help/quote me on required glsl shaders. Thanks.

Sala28's picture
Re: 3d Illusion with Kinect Motion Tracking

Fake 3d Cube With Light

Plugins- GL tools and Kineme Data Tools

PreviewAttachmentSize
Fake3dCubeWithLight.qtz250.14 KB

Sala28's picture
Re: 3d Illusion with Kinect Motion Tracking

Fake 3d Cube With Light Update

PreviewAttachmentSize
Fake3dCubeWithLight_2.qtz275.81 KB

blackburst's picture
Re: 3d Illusion with Kinect Motion Tracking

Thanks for your reply. I don't have the patch "DTStructureBreakOutPatch" which is required. But I can't imagine a structure patch solving the problem I'm having as is mentioned above though. Your X variable will still translate the cube across the screen's x-axis. The illusion involves the perceived object staying stationary, which I can't seem to imagine(with a head-trackingless setup for testing) with the object moving that way. For the sake of clarity I'm looking at projecting onto a small piece of frosted glass (2'*2'), vertical in front of the viewer being tracked. Naturally the projected 3d object will want to be as big as possible on this surface, and if the head tracking causes it to translate off the screen then :( there must be a way...

Serious Cyrus's picture
Re: 3d Illusion with Kinect Motion Tracking

blackburst wrote:
Thanks for your reply. I don't have the patch "DTStructureBreakOutPatch" which is required. But I can't imagine a structure patch solving the problem I'm having as is mentioned above though. Your X variable will still translate the cube across the screen's x-axis. The illusion involves the perceived object staying stationary, which I can't seem to imagine(with a head-trackingless setup for testing) with the object moving that way. For the sake of clarity I'm looking at projecting onto a small piece of frosted glass (2'*2'), vertical in front of the viewer being tracked. Naturally the projected 3d object will want to be as big as possible on this surface, and if the head tracking causes it to translate off the screen then :( there must be a way...

It's supposed to be working like that, the illusion is like looking into a box, and it depends from what angle you are looking as to what you can actaully see inside. It won't really work with an object that you could walk round, as it does quickly translate off the screen, you have to think of the viewer as being constrained to looking into the top of the box, with no possibility of seeing through the sides. So when the viewer walks too much to the side, their view is blocked by the walls of the hole in the surface. You could use a huge projection area and a tiny object to keep the illusion up for longer, or draw the bounds of the box the object is in, or use some other visual cue to clearly give the illusion that the object is in a hole in space that the viewer can see into.

I'll take a look at Sala28's stuff later tonight!

Sala28's picture
Re: 3d Illusion with Kinect Motion Tracking

Watch this video! amazing!! https://vimeo.com/13768202

gtoledo3's picture
Re: 3d Illusion with Kinect Motion Tracking

Oh, that's really cool. I did something like that with a cube (led, no head tracking), and all I had to use was three gl quads and the uv texture offsets to get the illusion.