vchelaru
06-23-2010, 03:39 PM
I apologize if this is a simple question covered already. I did a quick search but couldn't find anything about this specifically.
I'm looking to set up a 3D camera. I tried doing it with the following code:
var app:Application = FlexGlobals.topLevelApplication as Application;
var pp:PerspectiveProjection = new PerspectiveProjection();
pp.fieldOfView = 45;
app.stage.transform.perspectiveProjection = pp;
That does give me a perspective view, but there are a few things I don't quite understand:
1. What is the "near clip plane?" In other words, how close can objects get to the camera before disappearing? In my tests, if objects are by default at Z = 0, then I can move them about 920 units towards the camera before they start to get clipped. How is this calculated? How can I predict it? It seems a little arbitrary.
2. Where is the camera's "eye". Given a field of view of 45 degrees and a screen height of 600 pixels, then if my math is correct the Camera should be 724 units "back" from the Z=0 plane. But that doesn't make sense why I can move an object 920 units before it disappears.
I am coming from a XNA background so some of how this works is a little new to me. Thanks in advance for any help.
EDIT: A friend of mine said he has better luck with app.root.transform.perspectiveProjection instead of app.stage.transform.perspectiveProjection. Both worked for me and didn't seem to make a difference.
I'm looking to set up a 3D camera. I tried doing it with the following code:
var app:Application = FlexGlobals.topLevelApplication as Application;
var pp:PerspectiveProjection = new PerspectiveProjection();
pp.fieldOfView = 45;
app.stage.transform.perspectiveProjection = pp;
That does give me a perspective view, but there are a few things I don't quite understand:
1. What is the "near clip plane?" In other words, how close can objects get to the camera before disappearing? In my tests, if objects are by default at Z = 0, then I can move them about 920 units towards the camera before they start to get clipped. How is this calculated? How can I predict it? It seems a little arbitrary.
2. Where is the camera's "eye". Given a field of view of 45 degrees and a screen height of 600 pixels, then if my math is correct the Camera should be 724 units "back" from the Z=0 plane. But that doesn't make sense why I can move an object 920 units before it disappears.
I am coming from a XNA background so some of how this works is a little new to me. Thanks in advance for any help.
EDIT: A friend of mine said he has better luck with app.root.transform.perspectiveProjection instead of app.stage.transform.perspectiveProjection. Both worked for me and didn't seem to make a difference.