[Papervision3D] Fw: Positioning 3D plane to match 2D rectangle.

Strange Loop Studios info at strangeloopstudios.com
Wed Aug 26 07:24:51 PDT 2009


Hi Frank,

Thanks for that!
So basically to get a 1 to 1 match camera.z should be the negative equal of 
camera.focus where camera.zoom is a multiplier with 1 being 1x scale, 2 
being 2x scale etc... perfect
But what about if my scene uses zoom and focus values that are not the same 
like the defaults {focus:10, zoom:30.000000000000007} ? I'll end up with a 
multiplier/percentage but what should i multiply it with?
How do i use the dist_to_object value to set the camera.z when it is a value 
like 0.33333333333333326 (which is the result using the default settings)? 
If i run my test code below without explicitly setting the zoom and focus to 
easy to work with numbers items don't match because the camera.z is far too 
close to 0,0,0.

Here's my test code:

package
{

 import flash.display.Sprite;
 import org.papervision3d.cameras.CameraType;
 import org.papervision3d.materials.ColorMaterial;
 import org.papervision3d.objects.primitives.Plane;
 import org.papervision3d.view.BasicView;

 [SWF(width="800", height="600", frameRate="20", backgroundColor="#000000")]
 public class pv3dtest extends Sprite
 {

  private var planeWidth:int = 200;
  private var planeHeight:int = 100;
  private var basicView:BasicView;
  private var s:Sprite;
  private var plane:Plane;

  public function pv3dtest()
  {
   setupPapervision();
   setupSprite();
   matchDimensions();
  }

  private function setupSprite():void
  {
   s = new Sprite();
   s.graphics.lineStyle(1, 0xffffff, 1);
   s.graphics.beginFill(0x00ff00, .2);
   s.graphics.drawRect(0, 0, planeWidth, planeHeight);
   s.graphics.endFill();
   s.x = (stage.stageWidth-s.width)/2;
   s.y = (stage.stageHeight-s.height)/2;
   addChild(s);
  }

  private function setupPapervision():void
  {
   basicView = new BasicView(800, 600, false, true, CameraType.DEBUG);
   addChild(basicView);
   plane = new Plane(new ColorMaterial(0xff0000, 1, true), planeWidth, 
planeHeight);
   //plane.x = 0;
   //plane.y = 0;
   //plane.z = 0;
   basicView.scene.addChild(plane);
   basicView.startRendering();
  }

  private function matchDimensions():void
  {
   //basicView.camera.x = 0;
   //basicView.camera.y = 0;
   basicView.camera.focus = 1000;
   basicView.camera.zoom = 1;
   var distanceToPlane:Number = 
(basicView.camera.focus/basicView.camera.zoom);
   trace("distanceToPlane = "+distanceToPlane);
   basicView.camera.z = -distanceToPlane;
  }
 }
}



----- Original Message ----- 
From: "Frank Weinhold" <Frank.Weinhold at neue-digitale.de>
To: <papervision3d at osflash.org>
Sent: Wednesday, August 26, 2009 12:48 PM
Subject: Re: [Papervision3D] Fw: Positioning 3D plane to match 2D rectangle.


Hi!

You'll have to use the camera parameters to calc the distance from the 
camera to the 3D plane. This distance should be:

dist_to_object = camera.focus / camera.zoom;

for example:

camera.x = 0;
camera.y = 0;
camera.z = 500;
camera.focus = 500;
camera.zoom = 1;

plane.x = 0;
plane.y = 0;
plane.z = 0;

should display the plane's 3d dimensions 1:1 in 2d dimensions.

Maybe that will help...

Frank Weinhold Flash Application Developer Neue Digitale / Razorfish P +49 
30 2936388 - 24   office | earth :: think before you print

-----Ursprüngliche Nachricht-----
Von: papervision3d-bounces at osflash.org 
[mailto:papervision3d-bounces at osflash.org] Im Auftrag von Strange Loop 
Studios
Gesendet: Mittwoch, 26. August 2009 13:12
An: papervision3d at osflash.org
Betreff: Re: [Papervision3D] Fw: Positioning 3D plane to match 2D rectangle.

Thanks Buti,

I don't seem to be able to get the results i want using this. It's nowhere
near close! So i'm either understanding it wrong or need a few pointers
still.

Has anyone got any other examples/code?

Cheers
Doug


----- Original Message ----- 
From: "Buti" <butilon at gmail.com>
To: <papervision3d at osflash.org>
Sent: Wednesday, August 26, 2009 9:38 AM
Subject: Re: [Papervision3D] Fw: Positioning 3D plane to match 2D rectangle.


> Maybe this is helpfull
>
> http://www.everydayflash.com/blog/index.php/2008/07/07/pixel-precision-in-papervision3d/
>
>
> Strange Loop Studios wrote:
>> Hi Everyone,
>>
>> I'm wondering how i can go about positioning and sizing a plane in 3D
>> space to match the position and size of a rectangle in 2D space.
>> Has anyone got any advice please?
>>
>> Cheers
>> Doug
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
> -- 
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>


--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.67/2326 - Release Date: 08/25/09
18:07:00



_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

_______________________________________________
Papervision3D mailing list
Papervision3D at osflash.org
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



--------------------------------------------------------------------------------



No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.67/2326 - Release Date: 08/25/09 
18:07:00





More information about the Papervision3D mailing list