It is currently Thu Sep 02, 2010 2:24 pm




Post new topic Reply to topic  [ 3 posts ] 
 More z-sorting problems 
Author Message

Joined: Mon Nov 16, 2009 12:41 pm
Posts: 27
Post More z-sorting problems
Hi guys

I had problem with concave objects z-sorting that I'm trying to solve by cutting it in two pieces using MeshUtil.cutTriangleMesh() (viewtopic.php?f=14&t=1404). Everything looks fine, except both result TriangleMesh3Ds are somehow magically linked to the original object's ViewportLayer.

More specifically: setting the layerIndex for the result objects viewportLayer has no effect while setting layerIndex for the original object's viewportLayer affects both result objects at the same time.

What confuses me most is the fact that the original object was not added to stage nor his viewportLayer was not created yet! I have spent lot of time trying to fix it but there layer must be somehow associated with the verticles or faces itself.

I have created simple example, please check the attached file. Here is part of the code:

Code:
  1.  var sphere : Sphere = new Sphere();
  2. sphere.z = 500;
  3. container3D.addChild(sphere);
  4.    
  5. var cylinder : Cylinder = new Cylinder(new ColorMaterial(0xFFFFFF * Math.random()), 200, 100, 64, 16);
  6.  
  7. var plane : Plane3D = new Plane3D(new Number3D(Math.sin(.5 * Math.PI), 0, -Math.cos(.5 * Math.PI)), new Number3D(0,0,0));
  8. var cylinderSlices : Array = MeshUtil.cutTriangleMesh(cylinder, plane);
  9.  
  10. cylinderSlices[0].x = 20;
  11. cylinderSlices[1].x = -20;
  12.  
  13. container3D.addChild(cylinderSlices[0]);
  14. container3D.addChild(cylinderSlices[1]);
  15.  
  16. viewportLayer = viewport.getChildLayer(container3D);
  17. viewportLayer.sortMode = ViewportLayerSortMode.INDEX_SORT;
  18.  
  19. var cubeLayer : ViewportLayer = viewportLayer.getChildLayer(sphere);       
  20. var sliceALayer : ViewportLayer = viewportLayer.getChildLayer(cylinderSlices[0]);
  21. var sliceBLayer : ViewportLayer = viewportLayer.getChildLayer(cylinderSlices[1]);
  22.  
  23. cubeLayer.layerIndex = 2;
  24. sliceALayer.layerIndex = 3;
  25. sliceBLayer.layerIndex = 1;
  26.  
  27. //TODO: uncomment this to affect the result slices
  28. //var cylinderLayer : ViewportLayer = viewportLayer.getChildLayer(cylinder);
  29. //cylinderLayer.layerIndex = 4;
  30.  


Help me Obi-Wan Kenobi (John Brookes) you're my only hope.


Attachments:
Test2.zip [1.16 KiB]
Downloaded 18 times
Tue Nov 17, 2009 10:29 pm
Profile
Forum Administrator

Joined: Sat Mar 07, 2009 9:59 pm
Posts: 1107
Post Re: More z-sorting problems
hmmm weird :shock:

erm this seems to work. Just cloned them :?
Code:
  1.  
  2. var slice1:DisplayObject3D = cylinderSlices[0].clone()
  3. var slice2:DisplayObject3D = cylinderSlices[1].clone()         
  4. container3D.addChild(slice1);
  5. container3D.addChild(slice2);
  6.  
  7. trace(slice1.parent.numChildren);
  8.  
  9. viewportLayer = viewport.getChildLayer(container3D);
  10. viewportLayer.sortMode = ViewportLayerSortMode.INDEX_SORT;
  11.  
  12. var cubeLayer : ViewportLayer = viewportLayer.getChildLayer(sphere);       
  13. var sliceALayer : ViewportLayer = viewportLayer.getChildLayer(slice1);
  14. var sliceBLayer : ViewportLayer = viewportLayer.getChildLayer(slice2);
  15.  
  16. cubeLayer.layerIndex = 1;
  17. sliceALayer.layerIndex = 2;
  18. sliceBLayer.layerIndex = 3;
  19.  
  20.  


Wed Nov 18, 2009 7:51 pm
Profile

Joined: Mon Nov 16, 2009 12:41 pm
Posts: 27
Post Re: More z-sorting problems
loooooool I spent so much time debugging the TriangleMesh3D and Viewport3D:)

Thanks for the help John! This was very important for me.

ps: don't you know why is it happening?


Wed Nov 18, 2009 10:56 pm
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.