Split screen of two scenes

Software: Away3D 4.x

drbii, Member
Posted: 28 November 2014 03:40 PM   Total Posts: 72

Can’t seem to get the idea of this.  If someone could point me the right direction that would be great.

I need to separate away3d scenes placed on screen side by side.  I need them to display different content but the cameras need to be synchronized. I.E as the camera rotates around the object on the left the same movement needs to happen to the camera on the right.

I can’t seem to find a good example of two separate scenes being displayed at once.  I think I handle that camera syncing.

Thank you!
Dan

   

Avatar
mrpinc, Sr. Member
Posted: 28 November 2014 04:42 PM   Total Posts: 119   [ # 1 ]

It’s pretty simple actually.  Here is an example.  It’s not optimized but it works.

//engine variables
  
private var scene_one:Scene3D;
  private var 
scene_two:Scene3D;
  private var 
camera:Camera3D;
  private var 
view_first:View3D;
  private var 
view_second:View3D;
  
  public function 
MultiViewport() 
  
{
   init
();
  
}
  
  
private function init():void 
  {
   stage
.scaleMode StageScaleMode.NO_SCALE;
   
stage.align StageAlign.TOP_LEFT;
   
   
initEngine();
  
}
  
  
private function initEngine():void 
  {     
   view_first 
= new View3D();
   
view_first.backgroundColor 0x00FF80
   
   view_second 
= new View3D();
   
view_second.backgroundColor 0xFF80FF;
   
   
addChild(view_first);
   
addChild(view_second);
   
   var 
cubeg:CubeGeometry = new CubeGeometry(200,200,200);
   
   var 
cube1:Mesh = new Meshcubeg );
   var 
cube2:Mesh = new Meshcubeg );
   
   
view_first.scene.addChildcube1 );
   
view_second.scene.addChildcube2 );
   
   
onResizenull );
   
   
//setup the render loop
   
addEventListener(Event.ENTER_FRAMEonEnterFrame);
  
}
  
  
private function onResize(e:Event):void
  {
   view_first
.width view_second.width stage.stageWidth 2;
   
view_second.view_second.width;
   
   
view_first.height view_second.height stage.stageHeight;
  
}
  
  
private function onEnterFrame(e:Event):void 
  {
   view_first
.camera.moveRight10 );
   
view_first.camera.lookAt( new Vector3D() );
   
view_second.camera.transform view_first.camera.transform;
   
   
view_first.render();
   
view_second.render();
  
   

drbii, Member
Posted: 30 November 2014 07:40 PM   Total Posts: 72   [ # 2 ]

Thanks mrpinc!  I’ll give this a try.  Just now getting back to it.

   

Avatar
Fabrice Closier, Administrator
Posted: 30 November 2014 08:14 PM   Total Posts: 1265   [ # 3 ]

Almost smile
If you apply the code above, it will indeed display 2 views doing same things if you update both…. there’s however a flaw in this picture: double content!

simply do
view_first = new View3D();
_scene = view_first.scene;
view_second = new View3D(_scene);

AddChild anything you want to _scene as usual.
when you render, both views will show same content seen from different cameras (after you’ve set their own positions and lookAts ).

and if you push a bit further, you can also use only one stage3D by sharing contexts.

 

   

drbii, Member
Posted: 30 November 2014 08:20 PM   Total Posts: 72   [ # 4 ]

Do you set up two stage3dProxies as well?  I am using Starling for my UI. 

Running into a lot of errors right now that i am sorting thru and the 2nd viewport is not showing up.

Thanks,
Dan

   

drbii, Member
Posted: 30 November 2014 08:22 PM   Total Posts: 72   [ # 5 ]

Fabrice,

I am wanting each view to have separate content.  Does that still apply?  I am basically comparing two scenario’s in each view.  Each will have different models.

   

drbii, Member
Posted: 01 December 2014 01:13 AM   Total Posts: 72   [ # 6 ]

I have it working now, thanks! 

One stage3d to rule them all!

   

Avatar
Fabrice Closier, Administrator
Posted: 01 December 2014 11:57 AM   Total Posts: 1265   [ # 7 ]

if you show different content, it’s of course not applicable and is above code perfectly valid.

   

drbii, Member
Posted: 03 December 2014 12:39 AM   Total Posts: 72   [ # 8 ]

Ok, I have the two views and have them synced.  My UI is in starling using feathers.  Why does view#2 always cover my Feathers UI?  I have tried reordering their draw order but that doesn’t do anything.

   

rdoi, Member
Posted: 10 December 2014 01:32 PM   Total Posts: 86   [ # 9 ]
drbii - 03 December 2014 12:39 AM

Ok, I have the two views and have them synced.  My UI is in starling using feathers.  Why does view#2 always cover my Feathers UI?  I have tried reordering their draw order but that doesn’t do anything.

Double check the rendering order in your enterframe loop, the starling.nextFrame() should be the last layer to be rendered (in the top);

Or just post your render code, so we can review it.

(Furthermore, I predict you will probably have problems with mouse events…).

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X