Hi,
I have a problem of Z sorting I think, and I don’t understand how Away 3D 4 works with it. I have 2 planes that always face the camera. the red plane is closer than the green plane and hence is in front (at least at start). The camera starts to turn on itself, and then at some point the green plane goes front! I don’t understand why, can somebody explain me what happen? As the green plane is further than the red plane, I would assume that it is ALWAYS back, but obviously it is not the case….
Please help !
Here is my sample code :
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" backgroundAlpha="0"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import away3d.containers.View3D;
import away3d.materials.ColorMaterial;
import away3d.primitives.Plane;
private var _view: View3D;
public function mainLine()
{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
setupView3D();
}
private function setupView3D() : void {
_view = new View3D();
_view.width=1000;
_view.height=700;
_view.antiAlias = 2;
_view.backgroundColor = 0x333333;
uiComponent.addChild(_view);
initPrimitives();
}
public var plane:Plane;
public var plane2:Plane;
private function initPrimitives():void
{
plane=new Plane(new ColorMaterial(0xff0000));
plane.x=10;
plane.z=500;
plane.y=10;
plane.rotationX=-90;
_view.scene.addChild(plane);
plane2=new Plane(new ColorMaterial(0x00ff00));
plane2.x=-10;
plane2.z=510;
plane2.y=-10;
plane2.rotationX=-90;
_view.scene.addChild(plane2);
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
}
private function handleEnterFrame(ev : Event) : void
{
_view.camera.rotationY+=0.2;
plane.rotationY=_view.camera.rotationY;
plane2.rotationY=_view.camera.rotationY;
_view.render();
}
]]>
</fx:Script>
<mx:UIComponent id="uiComponent" width="100%" height="100%" addedToStage="mainLine()"/>
</s:Application>
Thank you very much in advance.
Also if somebody could explain how z-sorting works in general in Away3D4, it would be sweet
Take care,
Alex