You think too complex!
A single straight line, (PathSegment or PathCommand for 3.6)as profile is 
enough, such as -100,0,0 0,0,0 100, 0,0
Check the Broomstick example class, I've pushed few rings in there, inclusive 
one with thickness which is exactly what you want.

Even if slightly different from 3.x engine version, the profile principle is 
exactly the same.

Fabrice

On Apr 1, 2011, at 12:33 PM, Melanikus wrote:

> Hiya,
> 
> I am trying to create a custom class (sort of like a primitive) for
> creating a round tube so that I can easily create duplicates of this
> object on stage.
> 
> However, I am having trouble getting my head around how best to
> implement the custom class while using the LatheExtrusion class.  I
> have looked at creating a primitive using the standard methods but
> tese seem to extend the AbstractPrimitive class which seems to require
> exact face and vertex information (I could be wrong about this but all
> examples I have seen create faces to create the primitive).  I need my
> version to just read in the radius, thickness and depth of the tube in
> order to create an extruded shape.
> 
> At the moment I just get a blank screen with no model displayed.  I am
> pretty sure I am missing something fairly straightforward, but I am
> pretty stumped right now.  Any help would be greatly appreciated.
> 
> Here is my current code for  the class.  It is a bit of a work in
> progress.
> 
> [code]
> package {
>       import flash.display.*;
>       import flash.geom.Vector3D;
> 
>       import away3d.arcane;
>       import away3d.extrusions.*;
>       import away3d.materials.*;
>       import away3d.core.utils.*;
>       import away3d.core.base.*;
> 
>       public class RoundTube extends Object3D {
> 
>               public function RoundTube(radius:Number, thickness:Number,
> depth:Number, init:Object = null):void {
>                       super(init);
>                       drawRoundTube(radius, thickness, depth);
>               }
> 
>               //draw round tube
>               public function drawRoundTube(radius:Number, thickness:Number,
> depth:Number):void {
>                       var seg:Number = depth/5;
>                       var profile:Array = [
>                               new Vector3D(0, 0, 0),
>                               new Vector3D(0, 0+seg, 0),
>                               new Vector3D(0, 0+(seg*2), 0),
>                               new Vector3D(0, 0+(seg*3), 0),
>                               new Vector3D(0, 0+(seg*4), 0),
>                               new Vector3D(0, 0+depth, 0),
>                               new Vector3D(0+thickness, 0+depth, 0),
>                               new Vector3D(0+thickness, 0+(seg*4), 0),
>                               new Vector3D(0+thickness, 0+(seg*3), 0),
>                               new Vector3D(0+thickness, 0+(seg*2), 0),
>                               new Vector3D(0+thickness, 0+seg, 0),
>                               new Vector3D(0+thickness, 0, 0),
>                               new Vector3D(0, 0, 0)
>                       ];
> 
>                       var roundTube:LatheExtrusion = new 
> LatheExtrusion(profile);
>                       roundTube.subdivision = 18;
>                       roundTube.offsetRadius = radius;
>                       roundTube.centerMesh = false;
>                       roundTube.revolutions = 1;
>                       roundTube.bothsides = false;
> 
>                       //flips the model over
>                       roundTube.rotationX = -90;
> 
>                       var wMaterial:WireColorMaterial = new 
> WireColorMaterial(0x373737);
>                       wMaterial.wireColor = 0x373737;
>                       roundTube.material = wMaterial;
> 
>                       //add to holder
>                       //addChild(roundTube);
> 
>                       trace("model complete");
> 
>               }
> 
> 
>       }
> }
> [/code]
> 
> The class is then instantiated in the main code here:
> 
> [code]
> 
> holder = new ObjectContainer3D();
> var model:RoundTube = new RoundTube(10, 2, 300);
> holder.addChild(model);
> _view.scene.addChild(holder);
> 
> [/code]

Reply via email to