I have implemented surface extrusion along the z-axis for Graphics3D.
Graphics3D.depth defines the size and direction of the extrusion.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | var yellowColor:FlatShadeMaterial = new FlatShadeMaterial(light, 0xfffc00); yellowColor.doubleSided = true; surface3D.graphics3D.depth = 10; //Set depth of surface extrusion surface3D.z = -surface3D.graphics3D.depth / 2; surface3D.graphics3D.linesPerCurve = 6; //Set curve quality surface3D.graphics3D.beginFill(yellowColor); //Main body of smiley face surface3D.graphics3D.drawCircle(0, 0, 0, 50); //Now we draw inside the main body to create holes //Draw eyes surface3D.graphics3D.drawCircle(-18, 18, 5, 10); surface3D.graphics3D.drawCircle(18, 18, 5, 10); //Draw mouth surface3D.graphics3D.drawRect(-20, -25, -5, 40, 8); surface3D.graphics3D.endFill(); |

[...] have been exploring this subject as well, you can find their experiments here and here and [...]
Is it possible to do a ’stepped’ extrusion to increase the z-segments used?
Hi Ugo,
Unfortunately the current code only creates two triangles for every four sets of edge points. It would be fairly straight forward to create duplicate sets of the edge points between the two end surfaces to increase the triangle count. Alternatively the sides could be created using planes so you could specify the number of triangles.
Regards,
James
Hey James
Thanks for the reply. I’m really keen to experiment with your library but I can’t seem to compile it through the flash IDE. What version of Papervision are you using to get Surface3D working? I keep getting the following errors as soon as soon as I try to use the draw methods of the Graphics3D class:
TypeError: Error#1009: Cannot access a property or method of a null object reference.
isplayObject3D/project()
at org.papervision3d.org.cameras: :camera3D/projectfaces()
at org.papervision3d.org.core.geom: :Trianglemesh3D/project()
at org.papervision3d.org.objects:
at org.papervision3d.org.core.render.project: :BasicProjectionPipeline/projectObject()
at org.papervision3d.org.core.render.project: :BasicProjectionPipeline/project()
at org.papervision3d.org.render: :BasicRenderEngine/renderScene()
Any thoughts or help would be greatly appreciated. Thanks!
Hi! James,Ugo
I got the same errors!
But I remark renderer.clipping code and it can work.
I dont know why?
sorry,my English is poor!!!
this is my Letter3D Surface Extrusion Demo.
Why some surface missing?
[http://cubeparks.appspot.com/demo/Font3DTest1/DelaunayBasicView1.html]
Hi, I’ve found this class searching for some extrusion class, this one is usefull when no curves are used, some one is requesting for more triangles on lines, this can be done changing the line function on Graphics 3D, something like this :
public function lineTo(x:Number, y:Number, z:Number, $divide:Boolean = true):void {
if($divide){
var segments:Number = 20;
var previousPoint:Vertex3D = this._points[this._points.length-1];
var xDiv:Number = (x-previousPoint.x)/segments;
var yDiv:Number = (y-previousPoint.y)/segments;
var zDiv:Number = (z-previousPoint.z)/segments;
for(var i:uint=1;i<=segments;i++){
this.updateCurrentPoint(previousPoint.x+(i*xDiv), previousPoint.y+(i*yDiv), previousPoint.z+(i*zDiv));
this.storeCurrentPoint();
}
}else{
this.updateCurrentPoint(x, y, z);
this.storeCurrentPoint();
}
}
But still giving problems when curves are used, also for some reason I just get drawn the bottom face not the top one, I’ll be checking it I’ve just started to play with papervision just a few weeks ago so sure would take me some time to figure what’s going on there, I hope somebody could come with some fix.