Separate 2 scenes in one Stage3D?

Software: Away3D 4.x

Raino, Newbie
Posted: 22 January 2013 07:31 AM   Total Posts: 12

I create a map(x & z coordinate for land),
and make a sprite by Sprite3D.
when I set y value of sprite,part of it covered by the map.
So I want to separate them to 2 scenes,to let the sprite all be visible.

I read a post"Away3D and Starling interoperation” and make a try.
Create 2 View3Ds for each.
It doesn’t work,they seems to be still in one scene (the sample pic).

Please help~what’s wrong with my test, and is their any way to make it display like 2 layers.

_stage3DManager Stage3DManager.getInstance(Config.stage);
_stage3DProxy _stage3DManager.getFreeStage3DProxy();

......

var 
scene:Scene3D = new Scene3D();
_viewMap = new View3D();
_viewMap.stage3DProxy _stage3DProxy;
_viewMap.shareContext true;
_viewMap.scene scene;
_viewMap.camera _camera;
Config.main.addChild(_viewMap)
 
var 
scene:Scene3D = new Scene3D();
_view = new View3D();
_view.stage3DProxy _stage3DProxy;
_view.shareContext true;
_view.scene scene;
_view.camera _camera;
Config.main.addChild(_view

 

   

Raino, Newbie
Posted: 23 January 2013 07:14 AM   Total Posts: 12   [ # 1 ]

Finally I success.
Create a View3D to contain the terrain plane.
Create another View3D to contain 2D-Sprite and Terrain Object.

//I make 2 Scene3Ds 2 View3Ds

var scene:Scene3D = new Scene3D();
_viewMap = new View3D();
_viewMap.stage3DProxy=stage3DProxy
_viewMap
.shareContext=true;
_viewMap.scene scene;
_viewMap.camera _camera;
Config.main.addChild(_viewMap)

var 
scene:Scene3D = new Scene3D();
_view = new View3D();
_view.stage3DProxy=stage3DProxy
_view
.shareContext=true;
_view.scene scene;
_view.camera _camera;
_view.mouseChildren=false
_view
.mouseEnabled=false
Config
.main.addChild(_view)

......
//render then one by one

stage3DProxy.clear();
stage3DProxy.context3D.setDepthTest(false,Context3DCompareMode.ALWAYS)
_viewMap.render();
stage3DProxy.context3D.setDepthTest(true,Context3DCompareMode.LESS)
_view.render();
stage3DProxy.present(); 

 

   

/\/\/\, Newbie
Posted: 01 February 2013 12:49 PM   Total Posts: 15   [ # 2 ]

Hi i tried the same way, but it doesn´t work.
It just looks like before, the FX view is not in front of the main view.

here´s my code, is there an error?!

public  function init():void
  {
   _stage3DManager 
Stage3DManager.getInstance(stage);
   
// Create a new Stage3D proxy to contain the separate views
   
_stage3DProxy _stage3DManager.getFreeStage3DProxy();
   
_stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATEDonContextCreated);
   
_stage3DProxy.antiAlias 4;
  
_scene = new Scene3D();
   
_sceneFX = new Scene3D();

 
// MAIN VIEW
   
_view = new View3D();
   
_view.stage3DProxy _stage3DProxy
   _view
.shareContext=true;
   
_view.antiAlias 4;
   
_view.scene _scene;
   
_view.camera _camera;
   
   
// EFFECTS VIEW 
   
_viewFX = new View3D();
   
_viewFX.stage3DProxy=_stage3DProxy
   _viewFX
.shareContext=true;
   
_viewFX.scene _sceneFX;
   
_viewFX.camera _camera;
   
_viewFX.mouseChildren _viewFX.mouseEnabled false;
   
   
addChild(_view);
   
addChild(_viewFX); 
_stage3DProxy.clear();
   
_stage3DProxy.context3D.setDepthTestfalseContext3DCompareMode.ALWAYS)
   
_view.render();   
   
_stage3DProxy.context3D.setDepthTest(true,Context3DCompareMode.LESS)
   
_viewFX.render();
   
_stage3DProxy.present(); 

 

   

/\/\/\, Newbie
Posted: 01 February 2013 12:50 PM   Total Posts: 15   [ # 3 ]

Hi i tried the same way, but it doesn´t work.
It just looks like before, the FX view is not in front of the main view.

here´s my code, is there any error?!

public  function init():void
  {
   _stage3DManager 
Stage3DManager.getInstance(stage);
   
// Create a new Stage3D proxy to contain the separate views
   
_stage3DProxy _stage3DManager.getFreeStage3DProxy();
   
_stage3DProxy.addEventListener(Stage3DEvent.CONTEXT3D_CREATEDonContextCreated);
   
_stage3DProxy.antiAlias 4;
  
_scene = new Scene3D();
   
_sceneFX = new Scene3D();

 
// MAIN VIEW
   
_view = new View3D();
   
_view.stage3DProxy _stage3DProxy
   _view
.shareContext=true;
   
_view.antiAlias 4;
   
_view.scene _scene;
   
_view.camera _camera;
   
   
// EFFECTS VIEW 
   
_viewFX = new View3D();
   
_viewFX.stage3DProxy=_stage3DProxy
   _viewFX
.shareContext=true;
   
_viewFX.scene _sceneFX;
   
_viewFX.camera _camera;
   
_viewFX.mouseChildren _viewFX.mouseEnabled false;
   
   
addChild(_view);
   
addChild(_viewFX); 
_stage3DProxy.clear();
   
_stage3DProxy.context3D.setDepthTestfalseContext3DCompareMode.ALWAYS)
   
_view.render();   
   
_stage3DProxy.context3D.setDepthTest(true,Context3DCompareMode.LESS)
   
_viewFX.render();
   
_stage3DProxy.present(); 

 

   

Raino, Newbie
Posted: 01 February 2013 01:07 PM   Total Posts: 12   [ # 4 ]

Oh,I see.
I miss to tell that you should disable(or make a switch on/off) all setDepthTest() method in away3d package.(about 8 classes used this method)
Good Luck:)

 

   

/\/\/\, Newbie
Posted: 02 February 2013 02:08 PM   Total Posts: 15   [ # 5 ]

Thanks, now it works, although i´m wondering if hacking half the engine is necessary to achieve something that doesnt seem tooo complicated?

 

   

Raino, Newbie
Posted: 03 February 2013 01:24 AM   Total Posts: 12   [ # 6 ]

I think Away3D is designed to limited purpose in 3D,full 3d world and one space.Not for any unnatural view.
If you got better way to do so,please tell me.

 

   

Avatar
Mu Duck, Newbie
Posted: 02 December 2013 11:46 PM   Total Posts: 20   [ # 7 ]

Well You’d better use raycast picker on your terrain, get local y coordinate and adjust the bottom of your character to fit this coordinate.

Or if you have just a constant y coordinate for the whole plane - then just set your character’s y to this number and also + character’s maxY property.

so something like this:

char.y = terrain_y + char.maxY; Should be fine.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X