[Papervision3D] [Papervision3D ] OutlineMaterial: what now?

Boris Munser boris at unvoll.com
Mon Dec 1 10:01:08 PST 2008


I'm trying to create a new papervision material for my needs: 
OutlineMaterial (not only a silhouette).
what I did:
- added Boolean var "culledOnLastframe" to Vertex3D.as
- duplicated and modified WireframeMaterial.as to OutlineMaterial.as
modifications of OutlineMaterial:
override public function drawTriangle(face3D:Triangle3D, graphics:Graphics, 
renderSessionData:RenderSessionData, altBitmap:BitmapData = null, 
altUV:Matrix = null):void
  {
   //linewidth based on face parent screenZ:........
   distToCam = face3D.Instance.screenZ;
   lineWidth = Math.min( Math.max(1000/distToCam, 1), 3);
   graphics.lineStyle( lineWidth, lineColor, lineAlpha );

   if( face3D.v0.culledOnLastframe && face3D.v1.culledOnLastframe )
   {
 graphics.moveTo( face3D.v0.vertex3DInstance.x, 
face3D.v0.vertex3DInstance.y );
    graphics.lineTo( face3D.v1.vertex3DInstance.x, 
face3D.v1.vertex3DInstance.y );

   }
   if( face3D.v1.culledOnLastframe && face3D.v2.culledOnLastframe )
   {
       graphics.moveTo( face3D.v1.vertex3DInstance.x, 
face3D.v1.vertex3DInstance.y );
    graphics.lineTo( face3D.v2.vertex3DInstance.x, 
face3D.v2.vertex3DInstance.y );
   }
   if( face3D.v2.culledOnLastframe && face3D.v0.culledOnLastframe )
   {
    graphics.moveTo( face3D.v2.vertex3DInstance.x, 
face3D.v2.vertex3DInstance.y );
    graphics.lineTo( face3D.v0.vertex3DInstance.x, 
face3D.v0.vertex3DInstance.y );
   }
   //renderSessionData.renderStatistics.triangles++;
   graphics.moveTo( face3D.v0.vertex3DInstance.x, 
face3D.v0.vertex3DInstance.y );
   graphics.lineStyle();

  }

- changed TriangleMash3D.as "project" function to set all vertices' 
culledOnLastframe.value to false before render
- within modified TriangleMash3D.as, all faces' vertices are set to 
culledOnLastframe=true if culled;

Result: http://unvoll.com/schrottplatz/outlineshaderwoes.jpg

- what you see there is a compositeMaterial (bitmap+OutlineMaterial)...
- what the material does: draw lines between everly vertex of a 
TriangleMesh3D which is part of a triangle that was culled during the last 
rendering process...
- the problem is the BAD lines that are drawn when there is not enough 
geometry between opposite edges of the lowpoly mesh (a well-subdivided 
sphere would render fine because of a "notCulled" vertex avoiding the 
linedraw)
- I'm trying to keep this cheap on calculations. (thinking of 
vertex.connectedFaces.dictionary..compare, diff vertex face.normals to 
camera normal.. ouch)
- how can I "cull" the BAD lines?
- am I missing something?

I.m stuck,
Boris


-








More information about the Papervision3D mailing list