| Author |
Message |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 10/06/2008 23:06:46
|
codyhawke
Joined: 09/06/2008 18:46:41
Messages: 13
Offline
|
Hi guys -
Currently I'm trying to perfect the technique of finding the right camera Z, view size, and plane size in order to make a bitmap copy of a movie clip used as a texturematerial to look EXACTLY like the original copy. The movie clip's name is p_icons. I'm having trouble finding a perfect fit. Here are my current settings, which give me the right size, but a horribly pixelated image:
camera.z=150;
view=new View(camera,p_icons.width*2,p_icons.height*2);
var texture:Texture = new Texture(new BitmapData(p_icons.width,p_icons.height,true,0x000000));
texture.bitmapData.draw(p_icons,null,null,"alpha");
texture.bitmapData.draw(p_icons);
var textmat=new TextureMaterial(texture);
plane1 = new Plane(p_icons.width*.5,p_icons.height*.5,1,1,false,false,false);
Any ideas? If theres any more information I can provide to help find a solution, please let me know.
Thanks,
Cody
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 10/06/2008 23:53:01
|
Goddel2
Joined: 04/06/2008 18:04:22
Messages: 7
Offline
|
This was posted in the papervision mailing list and I believe it may be of some help.
In Papervision distance between camera and object / camera focus == camera zoom -1
Math.abs(camera.z - obj.z) / camera.focus == camera.zoom - 1;
This shows you the object at scale 1:1 on your viewport.
I'm not sure how camera focus and zoom work in alternativa. Maybe someone can help us out. Also I think that you should make the width of the plane the same as the width of the texture.
This message was edited 2 times. Last update was at 10/06/2008 23:56:37
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 10/06/2008 23:56:51
|
codyhawke
Joined: 09/06/2008 18:46:41
Messages: 13
Offline
|
That is AWESOME. exactly the kind of response I was looking for. I'll give it a go within the next hour, and let you know what happens. Thanks a million!
-Cody
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 00:15:41
|
codyhawke
Joined: 09/06/2008 18:46:41
Messages: 13
Offline
|
Oops....maybe I spoke too soon. I don't think there's a focus parameter for the camera. Maybe FOV would come into play somehow? Shucks
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 00:24:07
|
makc
![[Avatar]](/images/avatar/bbcbb1e844266f4abdfc29b3d8a64628607fa47e.png)
Joined: 02/06/2008 12:19:17
Messages: 1704
Offline
|
from here:
...a camera has two characteristics which define how we see things through it. These are the field of view (FOV) and focal length (F). Also, we have a rectangular view. Let's define it's half-diagonal like D. There is a relation between all three values: D / F = tan(FOV/2). So, when you change a camera's FOV or view's dimensions, the focal length is recalculated to match the previous expression. Due to focal length's change objects on a screen change their scale accordingly. So, all you have to do to prevent objects' scale changing is to keep value of the expression D / tan(FOV/2) constant, i.e. when you change FOV, adjust view size and vice versa.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 00:52:34
|
codyhawke
Joined: 09/06/2008 18:46:41
Messages: 13
Offline
|
Hopefully this thread'll be a great resource in the days and months to come. I've also realized that using the boolean smoothing property on the TextureMaterial constructor to be quite helpful in minimizing pixelation:
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 01:31:04
|
Goddel2
Joined: 04/06/2008 18:04:22
Messages: 7
Offline
|
makc wrote:from here:
...a camera has two characteristics which define how we see things through it. These are the field of view (FOV) and focal length (F). Also, we have a rectangular view. Let's define it's half-diagonal like D. There is a relation between all three values: D / F = tan(FOV/2). So, when you change a camera's FOV or view's dimensions, the focal length is recalculated to match the previous expression. Due to focal length's change objects on a screen change their scale accordingly. So, all you have to do to prevent objects' scale changing is to keep value of the expression D / tan(FOV/2) constant, i.e. when you change FOV, adjust view size and vice versa.
I don't fully understand this. What does this formula have to do with the obj's distance from the camera? How far do they have to be set apart once fov and view have been set accordingly? Can anyone give an example of this?
This message was edited 3 times. Last update was at 11/06/2008 01:35:40
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 08:16:50
|
mike
Joined: 01/06/2008 00:00:06
Messages: 786
Offline
|
Elido Ruiz, forgive me for my english I'll try to explain more simply. Imagine that we have a view with width 400 and height 300. So it's diagonal will be 500 and half-diagonal 250. There is a camera too with FOV set to PI/2. According to the formula D / F = tan(FOV/2), F (focal length) will be D / tan(FOV/2) = 250 / tan(PI/4) = 250. A point which has coordinate z = 250 in camera's coordinate system doesn't change it's x and y coordinates during projection on a screen because 1/z for perspective projection yields 1 in this case. So, to prevent a picture's distortion, we have to place it on a distance of 250 from the camera.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 18:52:16
|
Goddel2
Joined: 04/06/2008 18:04:22
Messages: 7
Offline
|
Ah thank you for the explanation I will be trying this later today
This message was edited 1 time. Last update was at 11/06/2008 18:52:52
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 22:32:30
|
mike
Joined: 01/06/2008 00:00:06
Messages: 786
Offline
|
I've forgotten one thing (my head was busy with another problem ): the expression 1/Z means F/Z because projected X coordinate is calculated as X * F / Z (the same for Y). To say even shorter: the focal plane of the camera is projected without scale change.
P.S. In the next update of API doc this problem will be reviewed in detail.
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 11/06/2008 23:10:38
|
Goddel2
Joined: 04/06/2008 18:04:22
Messages: 7
Offline
|
After reading it again I am just confused in one part...
F (focal length) will be D / tan(FOV/2) = 250 / tan(PI/4) = 250
F = D / tan(FOV/2)
250 / tan(PI/4) = 250 is not correct?
While using your example it is correct but when I attempt to change the view size to 1000,1000 it no longer works.. I used this equation to calculate FOV and camera Z
Also I don't understand how you got the Z value of 250 in the first place? right now I am just assuming D = Z
This message was edited 4 times. Last update was at 11/06/2008 23:21:48
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 12/06/2008 00:54:14
|
mike
Joined: 01/06/2008 00:00:06
Messages: 786
Offline
|
If I'm right, we want to draw a picture on a plane and place the camera so the picture would have the same dimensions (say, 100x100) in the view as it has in a graphic file. The solution:
Create a Plane primitive 100x100 units and assign it a texture with our picture. The Plane by default will be placed at the origin of coordinate system and will be parallel to XY coordinate plane. Place a camera on the scene (and connect it to a view). The camera by default looks along Z axis in positive direction so we have to assign some negative value to it's Z coordinate. Let's define it's absolute value as distance. As I said before, the focal plane of the camera is projected to the view without changing it's scale so we have to maintain right values for the camera's FOV and the view's diagonal to keep focal length equal to distance. According to the formula given earlier, FOV = 2 * atan(D/F), D -- half-diagonal of the view, F -- focal length of the camera, in our case it equals to distance. So, every time the view's size is changed, the following code has to be executed:
Quite simple, yeah? I hope, this will help
This message was edited 1 time. Last update was at 13/06/2008 22:00:46
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 12/06/2008 01:44:39
|
Goddel2
Joined: 04/06/2008 18:04:22
Messages: 7
Offline
|
Ah thank you so much for your time. Please excuse my poor math skills
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 19/07/2008 16:14:51
|
jukko
Joined: 03/06/2008 14:34:09
Messages: 8
Offline
|
Hey guys,
i have a further question regarding the size of a plane. I have big ground 2048x2048 and i want to create a lot of planes on it with different textures. The size of the textures are 75x75 px but if i creates a plane with the same size and add the texture to it, the plane is much bigger than 75x75 px.
I read this posted messages but i think this is working if i have only one plane, right? Because i have a fix distance to calculate the fov. But in this case i have more planes with different distances...
So, what can i do, to see the planes in the right size, if the camera stays directly in front of the planes?? Any ideas? Solutions?
Thanks
chris
|
|
|
 |
![[Post New]](/templates/default/images/icon_minipost_new.gif) 20/07/2008 11:33:45
|
jw7rgg89
Joined: 03/06/2008 09:44:45
Messages: 42
Offline
|
I don't know for sure if I understand fully what you mean, but I think you're trying to have the planes on exact same size on your screen, even though they have different coordinates, correct?
Maybe you should try using an orthographic projection viewport... And else "fake it" in 2d, it doesn't make a lot of sense to me using a 3D-engine without wanting the perspective?
But maybe I got your question all wrong?
|
|
|
 |
|
|