Guest User

Untitled

a guest
Sep 18th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Hi Richard,
  2.  
  3. I'm a little bit lost with the pull request, as I don't have Away3D GIT repo cloned here. The occlusion part is rather simple.
  4.  
  5. This is a ColorMaterial, der hides itself and all objects behind it by calling context.setColorMask(false, false, false, false);
  6.  
  7. The only thing, that the DefaultRenderer is missing in drawRenderables is a
  8. _activeMaterial.cleanUp(_context); call (so the material itself could do the context.setColorMask(true, true, true, true);
  9. Or the DefaultMaterialBase.updateMaterial() itself includes context.setColorMask(true, true, true, true);
  10.  
  11. I'm not sure, what fits your engine best as this is the first time I'm looking at its code today.
  12.  
  13. Anyway. Hope to see it implemented somehow
  14.  
  15.  
  16. package away3d.materials {
  17.     import away3d.arcane;
  18.  
  19.     import flash.display3D.Context3D;
  20.  
  21.     use namespace arcane;
  22.  
  23.     /**
  24.      * OcclusionMaterial is a ColorMaterial for an object, that hides all other objects behind itself.
  25.      */
  26.     public class OcclusionMaterial extends ColorMaterial
  27.     {
  28.         private var _occlude : Boolean = true;
  29.  
  30.         /**
  31.          * Creates a new OcclusionMaterial object.
  32.          * @param occlude Whether or not to occlude other objects.
  33.          * @param color The material's diffuse surface color.
  34.          * @param alpha The material's surface alpha.
  35.          */
  36.         public function OcclusionMaterial(occlude : Boolean = true, color : uint = 0xcccccc, alpha : Number = 1)
  37.         {
  38.             super(color, alpha);
  39.             this.occlude = occlude;
  40.         }
  41.  
  42.         /**
  43.          * Whether or not an object with this material applied hides other objects.
  44.          */
  45.         public function get occlude() : Boolean
  46.         {
  47.             return _occlude;
  48.         }
  49.  
  50.         public function set occlude(value : Boolean) : void
  51.         {
  52.             _occlude = value;
  53.         }
  54.        
  55.         /**
  56.          * @inheritDoc
  57.          */
  58.         arcane override function updateMaterial(context : Context3D) : void
  59.         {
  60.             super.updateMaterial(context);
  61.             if(occlude) {
  62.                 context.setColorMask(false, false, false, false);
  63.             }
  64.         }
  65.     }
  66. }
Add Comment
Please, Sign In to add comment