Hi Squ,

As I mentioned in my reply to your previous post, I believe the
difference in redering comes from the difference between Flash's built
in 3D settings vs. Away3D's camera settings. Did you look into
tweaking the perspective center, field of view and focal length of the
overlay sprite?

Here's another link that might help 
http://www.flashandmath.com/flashcs4/ppfl/index.html

Matching the Away3D rendering settings to a 2.5D Flash sprite kind of
defeat the purpose of using Away3D in the first place. Most people,
including me, use Away3D because the built-in 3D API in Flash has
major shortcomings, like managing FOV and projectionCenter. You can
use MovieMaterial to render sprites in Away3D. I would recommend you
do all your 3D in Away3D and keep content outside to 2D only.

If you need two 3D world you could also use multiple views that share
the same camera or copy the camera transform from one view to  the
other. Finally, I'll ask again: why are you trying to do this overlay
setup? Maybe if we understand what you are trying to achieve we can
help you further.

Cheers,

J.

On Jan 31, 10:57 am, squ <[email protected]> wrote:
> I need a real sprite to be projected over a view
> but I would like this sprite to be transformed this way an Object3D
> would be
>
> here is the link:http://prologis.win.pl/OverlayTest.swf
> the top red square is an overlay sprite object
> the bottom one is a Plane that is used as a leading object3D for the
> overlay sprite
>
> I use these matrixes for the red sprite:
>
> viewMatrix.identity();
> viewMatrix.rawData = camera.viewMatrix.rawData;
>
> overlayMatrix.identity();
> overlayMatrix.rawData = object3D.sceneTransform.rawData;
> overlayMatrix.append(viewMatrix);
>
> (object3D - is a leading Plane)
>
> possition ON means I add to matrixes: if (away3D.db.selected)
> overlayMatrix.position = new Vector3D(sourceProjection.x,
> sourceProjection.y, 0);
>
> sourceProjection - is the screen coordinates I get from the leading
> plane
>
> normally the possition should be ON, but when it is off we can see
> that the red top sprite is sort of above the Plane - this is probably
> where the differences come from
>
> I use standard away3D scene and add the overlay with this code:
> overlay = new Overlay(this,viewContainer, view, camera);
>
> the overlay class looks like this:
>
> package away3d.overlays
> {
>         import away3d.cameras.*;
>         import away3d.core.base.*;
>         import away3d.containers.View3D;
>         import away3d.cameras.Camera3D;
>         import away3d.primitives.*;
>
>         import flash.geom.*;
>         import flash.display.*;
>         import flash.events.*;
>
>         public class Overlay extends Sprite implements IOverlay
>         {
>
>                 private var away3D:Object = null;
>                 private var view:View3D = null;
>                 private var camera:Camera3D = null;
>
>                 public var object3D:Plane;
>                 private var scale:Number;
>                 private var sourceProjection:Vector3D;
>
>                 public var overlayMatrix:Matrix3D = new Matrix3D();
>                 private var flipY:Matrix3D = new Matrix3D();
>                 private var viewMatrix:Matrix3D = new Matrix3D();
>
>                 private var overlayContainer:Sprite;
>                 private var testSprite:Sprite;
>                 private var viewContainer:Sprite;
>
>                 public function Overlay(a:Object, vc:Sprite, v:View3D, 
> c:Camera3D,
> init:Object = null)     {
>
>                         away3D = a;
>                         viewContainer = vc;
>                         view = v;
>                         camera = c;
>                         flipY.appendScale(1, -1, 1);
>                         overlayContainer = new Sprite();
>                         this.visible = false;
>                         createTestSprite();
>
>                 }
>
>                 private function createTestSprite():void {
>                         testSprite = new Sprite();
>                         testSprite.graphics.clear();
>                         testSprite.graphics.beginFill(0xFF0000, 1);
>                         testSprite.graphics.lineStyle(3, 0x000000);
>                         testSprite.graphics.drawRect(-150, -150, 300, 300);
>                         testSprite.graphics.endFill();
>                         setNewSettings();
>                 }
>
>                 private function setNewSettings():void {
>                         object3D = new Plane({width:testSprite.width,
> height:testSprite.height,yUp:false});
>                         object3D.x = 0;
>                         object3D.y = 0;
>                         object3D.z = 400;
>
>                         object3D.yaw(30);
>                         //object3D.pitch(180);
>
>                         object3D.rotationX = -60;
>                         //object3D.rotationY = -70;
>                         //object3D.rotationZ = 0;
>
>                         //testSprite.rotationX = 90;
>
>                         view.scene.addChild(object3D);
>                         this.addChild(testSprite);
>                         view.addOverlay(this);
>                 }
>
>                 public function update():void {
>
>                         sourceProjection = camera.screen(object3D);
>
>                         if(!sourceProjection || sourceProjection.z < 0){
>                                 if(this.visible) this.visible = false;
>                                 return;
>                         }
>                         if(!this.visible) this.visible = true;
>
>                         scale = 
> camera.lens.getPerspective(sourceProjection.z);
>
>                         viewMatrix.identity();
>                         viewMatrix.rawData = camera.viewMatrix.rawData;
>
>                         overlayMatrix.identity();
>                         overlayMatrix.rawData = 
> object3D.sceneTransform.rawData;
>                         overlayMatrix.append(viewMatrix);
>
>                         scale = 
> camera.lens.getPerspective(sourceProjection.z);
>                         overlayMatrix.appendScale(scale,scale,1);
>
>                         var posZ = overlayMatrix.rawData[14]
>
>                         if (away3D.db.selected) overlayMatrix.position = new
> Vector3D(sourceProjection.x, sourceProjection.y, 0);
>
>                         this.transform.matrix3D = overlayMatrix;
>
>                         //trace(this.parent.x);
>
>                 }
>
>         }
>
>
>
>
>
>
>
> }

Reply via email to