Log in or register to post comments

User defined targets scale/size

August 6, 2013 - 4:23am #1

Hello,

I want to show a video over a user-defined target. The video must "fit" inside a rectangle that is presented to the user as a 2D GUI.

So if say, I have a GUI rectangle that is a third of the height of the device's screen height, what scale should be the 3D plane containing the video? So that the video appears "inside" the GUI rectangle? (of course only in the original state where the user is supposed to be parallel to the target)

Is there a formula? Should I try to find a relationship with CameraCalibration.getSize() ? Or CameraCalibration.getPrincipalPoint () ?

 

Thanks !

 

Erik

User defined targets scale/size

September 13, 2014 - 8:53pm #7

how did u create the GUI rectangle?

User defined targets scale/size

August 14, 2013 - 2:04am #6

So, I found a solution - for the poor soul that would have the same issue. To put it in different words, I was trying to match the scale of a target in the 3D scene with the size a 2D on-screen pattern.

The idea is to have a series of invisible "reference" objects attached to the target. When the target is captured, a script goes through all those objects until one matches the size of the 2D pattern (using unprojection, ie Camera.WorldToScreenPoint with MeshRenderer.bounds).

The scale of the matching object is then applied to the actual tracked 3D object.

Kind of acrobatic but it works perfectly.

User defined targets scale/size

August 12, 2013 - 3:07am #5

The mask idea is a nice idea.

But I should have been more clear about what I intend to do :

The user is supposed to draw a black square with a felt-tip marker (any size, any location) on a specific paper. Then there's a video onto this user-defined marker, which itself contains a black square that should match the black square the user drawn.

Do you see what I mean?

 

Thanks heaps !

User defined targets scale/size

August 10, 2013 - 11:32am #4

By size I mean the width and height dimensions of the device screen.

But there may be another approach that you can consider. Does this effect accomplish what you're trying to do? - http://www.moosejaw.com/moosejaw/shop/content_xraypr____

* that's done with depth masking and doesn't require you to dynamically scale anything.

User defined targets scale/size

August 9, 2013 - 9:33am #3

Thanks for your reply.

The video plane is rendered using perspective, and yes it has to be rendered onto the target.

Since the "visible" size of the plane is computed from the actual perspective, I reckon from your answer that the only factor to determine the plane "physical" scale (ie transform.localScale) should be the screen size. By that do you mean the screen height? Or the diagonal?

I understand there must be som complex math behind that, I'm just trying to find an acceptable approximation tht could work on avariety of devices (iOs and Android). Thanks for your help ! 

User defined targets scale/size

August 6, 2013 - 11:23am #2

Are you rendering the 3D plane orthographically, or using perpsective?

Is the video to be rendered onto the target?

The principle influence on scale will obviously be the distance from the camera, which is approximated as scale / distance. Once you know the scale factor, you should be able to modify the size of the plane to fill the rectangle, the size of which would be determined as a proportion of the screen size - http://docs.unity3d.com/Documentation/ScriptReference/Screen.html

Log in or register to post comments