[Papervision3D] MeshBatch (sorting multiple meshes by face)

Carlos Ulloa c4rl054321 at gmail.com
Mon Dec 18 17:44:59 EST 2006


Hi Simon,

This is really really good.

It's something I've been thinking about recently. This is not only good for
z sorting, but also makes the multi object parser easier to implement, so we
can read files with more than one mesh and one material.

Really nice implementation. I'm very glad that people are finding
Papervision3D so easy to expand. There's quite a few people on this list
that can contribute to make this even better. Just to give you an idea, the
first release 18 days ago had 13 different classes. Today we have 29 classes
only on AS2 plus a whole AS3 version.

Name wise, what do you think if we call it MeshGroup instead? I'm trying to
leave all objects outside core as user friendly as possible.

I will incorporate it in the next revision.

Thanks,

C4
// noventaynueve.com
// papervision3d.org



On 18/12/06, Simon Oliver <psifli at yahoo.com> wrote:
>
> Some of the scenes I've been playing around with work a bit better when
> all the faces for some meshes are combined and then z-sorted all in one
> batch (rather than z-sorting the average vertex pos per object) if their
> shape is a bit peculiar (large objects such as floors, walls, boxes etc when
> compared with smaller objects inside them perhaps). Was thinking a MeshBatch
> class might be useful where you can combine multiple Meshes into a single
> entity to allow all faces to be sorted together. The class below does this,
> and you can use it as you would add to a scene, ie:
>
>         _meshBatch=new MeshBatch();
>
>         blocks= new Ase( brickMaterial, "blocks_01.ase" ,1);;
>         room= new Ase( material, "room_01.ase" ,1);;
>         floor= new Ase( floorMaterial, "floor_01.ase" ,1);;
>
>         _meshBatch.push(blocks);
>         _meshBatch.push(floor);
>         _meshBatch.push(room);
>
>         scene.push (_meshBatch);
>
> Hope its of use :)
>
> Also, the ASE issue with the Maya exporter still seems to be there (the
> use of \r\n rather than just \n). Reckon we could switch to just \n ? ta!
>
>
>
> package org.papervision3d.objects {
>
>     import org.papervision3d.objects.Mesh;
>     import org.papervision3d.core.proto.DisplayObject3D;
>     import org.papervision3d.cameras.Camera3D;
>     import org.papervision3d.core.proto.CameraObject3D ;
>     import org.papervision3d.scenes.Scene3D;
>     import org.papervision3d.core.proto.SceneObject3D;
>     import org.papervision3d.core.geom.Face3D;
>
>     import flash.display.Sprite
>
>     public class MeshBatch extends DisplayObject3D
>     {
>
>         public var meshes      :Array;
>         public var faces      :Array;
>         public var showFaces  :Boolean;
>         public var sortFaces  :Boolean;
>
>         public function MeshBatch()
>         {
>             super();
>             this.meshes = new Array();
>             this.faces = new Array();
>             //showFaces=true;
>             sortFaces=true;
>         }
>
>         public function push( mesh:Mesh ):void
>         {
>             meshes.push(mesh);
>         }
>
>         public override function project( camera :CameraObject3D ):void
>         {
>             var mesh:Mesh;
>
>             for (var i:Number=0;mesh=meshes[i];i++)
>                 mesh.project(camera);
>         }
>
>         public override function render( scene :SceneObject3D ):void
>         {
>
>             this.faces = new Array();
>
>             var mesh:Mesh;
>             for (var i:Number=0;mesh=meshes[i];i++)
>                 this.faces=this.faces.concat(mesh.faces);
>
>             var faces:Array = this.faces;
>
>             if( this.sortFaces )
>                 faces.sortOn( 'screenZ', Array.DESCENDING | Array.NUMERIC);
>
>             var container  :Sprite    = this._container || scene.container
> ;
>             var showFaces :Boolean   = this.showFaces;
>             var rendered  :Number    = 0;
>
>             var face :Face3D;
>
>             for( var j:int = 0; face = faces[j]; j++ )
>             {
>                 if( face.visible )
>                     rendered += face.render( container, showFaces );
>             }
>             scene.stats.rendered += rendered;
>         }
>     }
> }
>
> ------------------------------
> Try the all-new Yahoo! Mail<http://us.rd.yahoo.com/mail/uk/taglines/default/nowyoucan/wall_st_2/*http://us.rd.yahoo.com/evt=40565/*http://uk.docs.yahoo.com/nowyoucan.html>. "The New Version is radically easier to use" – The Wall Street Journal
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20061218/5173dc78/attachment.htm


More information about the Papervision3D mailing list