Pixel perfect plane

Software: Away3D 4.x

Karim Beyrouti, Administrator
Posted: 26 March 2012 01:53 PM   Total Posts: 30

Hello Forum,

This has been discussed before, however I am having dificulty finding a solution that works with Away 4.0. I am trying to get pixel prefect positioning of a plane, i.e. getting a plane that is 128 x 32 to show up
at those dimensions on the screen. Any pointers ?

Kind regards

   

Karim Beyrouti, Administrator
Posted: 26 March 2012 03:28 PM   Total Posts: 30   [ # 1 ]

Getting closer to solving this one, however it’s not quite there:

  Sample: http://kurst.co.uk/samples/pixelprecision/
 
the SWF is calculating the fieldOfView based on the objects distance from the camera - and setting that to get pixel precision:

var dist    Number  Vector3D.distanceplaneMesh.position awayView.camera.position );
    var 
fieldOfView Number  = (360 Math.PI) * Math.atan(awayView.view.height / (dist));
    
lens.fieldOfView    fieldOfView;// lens is a PerspectiveLens 

 
I would rather solve this to find the object’s Z position rather than changing the FOV, but am a little confused on how to
proceed from here.

  Source: http://kurst.co.uk/samples/pixelprecision/src.zip
 
Thanks


- karim

   

bardo, Member
Posted: 27 March 2012 02:27 PM   Total Posts: 79   [ # 2 ]

i use this

public static function pixelPerfectCameraValue(camera:Camera3D,h:Number  ):Number {
   
var h:Number h;
   var 
fovy:Number = (camera.lens as PerspectiveLens).fieldOfView*Math.PI/180;
   return  -(
h/2) / Math.tan(fovy/2);
  

move the object on is back vector with this value

ie:

var positionCamera:Vector3D Matrix3DUtils.getForward(camera.transform);
   var 
newPos:Vector3D = new Vector3D(camera.position.positionCamera.* -(Utils3d.pixelPerfectCameraValue(camera450)), camera.position.positionCamera.* -(Utils3d.pixelPerfectCameraValue(camera450) ), camera.position.positionCamera.* -(Utils3d.pixelPerfectCameraValue(camera450))) 

dont know if there is another method, maybe more correct.

   

Karim Beyrouti, Administrator
Posted: 27 March 2012 03:21 PM   Total Posts: 30   [ # 3 ]

Yep - that worked a treat:
http://kurst.co.uk/samples/pixelprecision/pixelperfect.html

updated source for this if it helps anyone:
http://kurst.co.uk/samples/pixelprecision/pixelperfect.zip

Thank you !

   

bardo, Member
Posted: 27 March 2012 05:07 PM   Total Posts: 79   [ # 4 ]

de nada!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X