how to use PathExtrude?

Software: Away3D 4.x

JimmyZju, Newbie
Posted: 19 March 2013 02:31 AM   Total Posts: 8

I am new to Away3D. I want to use the PathExtrude class to construct some pipelines. But the example codes online I found is using older version of Away3D. Can anyone show me some demonstration code using the 4.x Away3D?

Any idea would be appreciated! Thanks.

   

Avatar
Fabrice Closier, Administrator
Posted: 19 March 2013 08:35 AM   Total Posts: 1265   [ # 1 ]

here an example of CUBIC path—> 4 entries per segment

private function populateCubic() : void
  {
  var diff:BitmapData = Bitmap(new Diffuse()).bitmapData;
  var bt:BitmapTexture = new BitmapTexture(diff);
  var material:TextureMaterial = new TextureMaterial(bt);
  material.lightPicker = _staticLightPicker;
 
  // a cubic path
  var pathData:Vector.<Vector3D> = Vector.<Vector3D>([
  new Vector3D(-500, 0,0),
  new Vector3D(-250, 100,0),
  new Vector3D(250, 100,0),
  new Vector3D(500, 0,0),
 
  new Vector3D(500, 0,0),
  new Vector3D(750, -100,0),
  new Vector3D(850, -100,0),
  new Vector3D(1000, 0,0)
  ]);
 
  //saving path for further uses, like animation
  _path = new CubicPath(pathData);
 
  // the profile, the shape definition projected along the path, in this case a rect
  var profile:Vector.<Vector3D> = Vector.<Vector3D>([new Vector3D(-100, -50, 0),
                new Vector3D(-100, 50, 0),
              new Vector3D(0, 50, 0),
              new Vector3D(100, 50, 0),
              new Vector3D(100, 0, 0),
              new Vector3D(100, -50, 0),
              new Vector3D(0, -50, 0),
              new Vector3D(-100, -50, 0)
                ]);
 
 
  var subdivision:uint = 10;
  _pathExtrude = new PathExtrude( material, _path, profile, subdivision);
  _pathExtrude.coverSegment = true;
  _pathExtrude.smoothSurface = true;
 
  _view.scene.addChild(_pathExtrude);
  }

 

   

Avatar
Fabrice Closier, Administrator
Posted: 19 March 2013 08:55 AM   Total Posts: 1265   [ # 2 ]

Here a quadratric example.

In this case, we use Prefab 1.x path editor (on todo for 2.x)
to generate the path and simply copy paste the data into the class.

private function makeQuadraticPath() : void
  {
  var diff:BitmapData = Bitmap(new Diffuse()).bitmapData;
  var bt:BitmapTexture = new BitmapTexture(diff);
  var material:TextureMaterial = new TextureMaterial(bt);
  material.lightPicker = _staticLightPicker;
 
  // A simple copypaste from Prefab3D’s 1.x .awp path exports
  var data:Array = [2275,0,-32.5,2089.75,0,529.75,1665.625,293.9631168664363,971.75,1665.625,293.9631168664363,971.75,1241.5,587.9262337328726,1413.75,498.875,782.3829044346695,1555.125,498.875,782.3829044346695,1555.125,-243.75,976.8395751364665,1696.5,-877.5,784.8225334860448,1483.625,-877.5,784.8225334860448,1483.625,-1511.25,592.8054918356231,1270.75,-1742,398.34882113382616,773.5,-1742,398.34882113382616,773.5,-1972.75,203.8921504320292,276.25,-1797.25,41.503232422655884,-235.625,-1797.25,41.503232422655884,-235.625,-1621.75,-120.88568558671744,-747.5,-1101.75,-224.84387830400362,-1040,-1101.75,-224.84387830400362,-1040,-581.75,-328.8020710212898,-1332.5,34.125,-425.62013723120924,-1324.375,34.125,-425.62013723120924,-1324.375,650,-522.4382034411287,-1316.25,971.75,-463.5435403585238,-1001,971.75,-463.5435403585238,-1001,1293.5,-404.64887727591884,-685.75,1225.25,-205.4879130726602,-250.25,1225.25,-205.4879130726602,-250.25,1157,-6.326948869401548,185.25,724.75,94.53357876487867,472.875,724.75,94.53357876487867,472.875,292.5,195.3941063991589,760.5,-204.75,261.74796098604486,680.875,-204.75,261.74796098604486,680.875,-702,328.1018155729309,601.25,-822.25,406.05368991458886,268.125,-822.25,406.05368991458886,268.125,-942.5,484.00556425624677,-65,-659.75,538.7973031336326,-287.625,-659.75,538.7973031336326,-287.625,-377,593.5890420110183,-510.25,-61.75,674.735882147429,-433.875,-61.75,674.735882147429,-433.875,253.5,755.8827222838397,-357.5,429,859.5828499106706,-117];
 
  var pathData:Vector.<Vector3D> = new Vector.<Vector3D>();
  for(var i:uint = 0;i<data.length;i+=3)
  pathData.push(new Vector3D(data[ i ], data[i+1], data[i+2]));
 
  _path = new QuadraticPath(pathData);
 
  var profile:Vector.<Vector3D> = new Vector.<Vector3D>();
  var v:Vector3D;
  var count:uint = 30;
  var step:Number = 360/count;
  var angle:Number ;
 
  for(i = 0;i<=count;++i){
  angle = (step*i)+90;
  v = new Vector3D();
  v.x = Math.cos(angle/180*Math.PI) * 200;
  v.y = Math.sin(-angle/180*Math.PI) * 200;
  profile.push(v);
  }
 
  _pathExtrude = new PathExtrude( material , _path, profile, 20, false, true);
  _view.scene.addChild(_pathExtrude);
  }

 

 

   

JimmyZju, Newbie
Posted: 19 March 2013 09:07 AM   Total Posts: 8   [ # 3 ]

Thanks Fabrice, your codes really give a lot help. And I have a new question: how can I build solid extrusion instead of a shell?

Thanks again!

 

   

Avatar
Fabrice Closier, Administrator
Posted: 19 March 2013 11:27 AM   Total Posts: 1265   [ # 4 ]

There is no “close” option in PathExtrude, but I’ve added a prop just for that: keepExtremes. which allow you to retrieve the start and end points that you need to close the mesh if required. So you can build the closing gaps as you want using DelaunayMesh, SkinExtrude etc..

public function get startProfile() : Vector.<Vector3D>
public function get endProfile() : Vector.<Vector3D>

 

   

JimmyZju, Newbie
Posted: 19 March 2013 11:52 AM   Total Posts: 8   [ # 5 ]

Really thank you! But I may not describe my question well. Currently I can get PathExtrude entity like this (shown in Picture below). It’s a shell (empty, just surface), while I want a solid pipe or pipe with a thick layer. How can I achieve that effect?

Thank you again!

 

   

Avatar
Fabrice Closier, Administrator
Posted: 19 March 2013 12:02 PM   Total Posts: 1265   [ # 6 ]

While there is a concept of thickness in LatheExtrude & LinearExtrude, there is none in PathExtrude. In order to acheive this, you need to proceed in two steps:
Build the extrude, but use only its geometry instead of addChilding it. You then build a new buffer from the data of the extrude by generating 2 faces from one. By using the normals of the extrude. A simple multiply by halfthickness in positive and negative will give you for each original face, 2 faces. Closing is same except you will compair the extreme vectors as explained above with the 2 new faces sides. once indices, vertices en uvs are build, pass them to MeshHelper.build method or construct the new mesh yourself. Delete original extrude.

Keep in mind that you may need to invert uv’s and face widing for either the inner or outer surface depending on PathExtrude constructor or path direction.

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X