Full Menu:

Blog Summary

  1. Flash XML loops and accessing data Joel Reinke 13-Mar-2013
  2. The Latest: Apps & PHP customization Joel Reinke 20-Jun-2012
  3. Photoshop Tree Tutorial Joel Reinke 07-Nov-2011
  4. Developer Resource - Papervision3D joel reinke 27-Sep-2011
  5. Photoshop Landscape Painting Expanded Joel Reinke 09-Sep-2011


Web Design Mountain : developers : Papervision3D Better Cylinder

Papervision3D Better Improved Cylinder

Separate Material for "Tube" and "Top/Bottom"

Using the standard Papervision 3D Cylinder, I finally had enough!  I should have just modified the basic class a long time ago, but I didn't have the confidence to go monkeying around with the core code.  Now I've done it and I'm a lot happier.

The issue:  The core Cylinder primitive object just uses the same material for the top, bottom, and the tube of the cylinder.  So say you want to design a Coin, the face of the coin will be stretched and warped across the whole tube of the cylinder which looks horrible.

The solution:  I've made a separate, improved Cylinder, called CylinderPlus, which you can download here.  It is very similar to the normal cylinder in usage.  I'll explain how to install it and use it next.

CylinderPlus CylinderPlus (7 KB)

Installation

Simple: Download it here. Save it in your Papervision Source Directory under:
org > papervision3d > objects > primitives

Usage

Almost just like the original cylinder:

  • Where you add your imports add:

    import org.papervision3d.objects.primitives.CylinderPlus;

  • Where you declare your global or local instances of objects:

    private var betterCylinder:CylinderPlus;

  • Where you define your materials make 2 materials:

    var facesC:BitmapFileMaterial=new BitmapFileMaterial("assets/coin.png");
    var tubeC:BitmapFileMaterial=new BitmapFileMaterial("assets/tube.png");

  • Make the cylinder:

    betterCylinder = new CylinderPlus(facesC, tubeC, 360, 20, 32, 1);

    Definition:

    ( material:MaterialObject3D=null, material2:MaterialObject3D=null, radius:Number=100, height:Number=100, segmentsW:int=8, segmentsH:int=6, topRadius:Number=-1, topFace:Boolean=true, bottomFace:Boolean=true )
     

Its just like the standard Cylinder but you have 2 materials accepted at the begining.  This makes for easy, standard usage that's a lot less work than having a Materials List like for a cube, when a simpler approach is logical for this application.

Designing this wasn't Rocket Surgery but it will save you time and headaches trying workarounds.  Thank me by linking to my site and helping me spread my resources to the web (please don't redistribute, just send them here)