Finding the edges of my scene

Software: Away3D 4.x

Rob Dodson, Newbie
Posted: 04 January 2012 10:10 PM   Total Posts: 15

I’m sure this question has been asked on the forums before but I’m not sure how best to phrase it so I’m not having much luck searching for an answer.

I’m trying to move a vertical line across the screen so that it exactly matches the mouse position. My camera is at 0, 0, 100 and looking at the center of the screen. I need to figure out how large it’s viewing space is so I can find the percentage of the screen that the mouse is over. Sort of like this:

totalSceneWidth * (stage.mouseX / stage.stageWidth)

any help is greatly appreciated :D

   

Rob Dodson, Newbie
Posted: 08 January 2012 08:48 PM   Total Posts: 15   [ # 1 ]

sorry to double post but I really need to figure this out…

lets say I have a scene and my camera’s distance is set to 1000. How do I determine the size of the viewing area?

   

John Brookes, Moderator
Posted: 09 January 2012 05:58 AM   Total Posts: 732   [ # 2 ]

For the default camera looking at origin
// dist is the distance from the camera
// so if you want the size of the frustum with the default camera 0,0,-1000 and set dist =1000
//Then maxheight,maxwidth gives the height,width of the frustum at z=0
// At dist = 1500 would give you height of the frustum at z=500
var dist:Number = 1000
var maxheight:Number = Math.tan((PerspectiveLens(view.camera.lens).fieldOfView * 0.5) * Math.PI / 180) * dist*2;
var maxWidth:Number = maxheight * (view.width / view.height);

//eg
_sphere.x = maxWidth/2 //would put a sphere at z=0 to the edge of the screen


But from what you doing maybe something like the drag3D class would be better (not sure)

   

Rob Dodson, Newbie
Posted: 09 January 2012 07:58 PM   Total Posts: 15   [ # 3 ]

oh cool I didn’t know there was a Drag3D class, that’s good to know!

And thank you very much for the functions, that is very helpful! Is the frustrum the term for the camera’s viewable space? I know there are near and far frustrums which control what gets rendered..do they combine to form a cube of sorts and everything inside of there is what gets drawn to screen?

   

John Brookes, Moderator
Posted: 10 January 2012 09:10 AM   Total Posts: 732   [ # 4 ]

Yes and..
Its a frustum (not frustRum).

Google “view frustum” lots of images of one.

   

Rob Dodson, Newbie
Posted: 10 January 2012 04:15 PM   Total Posts: 15   [ # 5 ]

oh sorry about that. thanks again

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X