60FPS? You must be using a non-crap machine!
I have no idea why there's the amount of polys that there are - I'm
just pulling vector data out of GraphicsPath commands, then extruding
it, code below. If you can think of a cleaner approach then I'm all
ears!
package
{
import Singularity.Geom.Bezier2;
import __AS3__.vec.Vector;
import away3d.containers.ObjectContainer3D;
import away3d.entities.Mesh;
import away3d.extrusions.LinearExtrude;
import away3d.tools.Merge;
import com.codeazur.as3swf.exporters.AS3GraphicsDataShapeExporter;
import com.codeazur.as3swf.tags.TagDefineShape;
import com.codeazur.as3swf.tags.TagDefineSprite;
import com.codeazur.as3swf.timeline.FrameObject;
import flash.display.GraphicsPath;
import flash.display.IGraphicsData;
import flash.geom.Vector3D;
public class Walls extends Mesh
{
private var _data:Vector.<IGraphicsData>;
private var _bezier:Bezier2 = new Bezier2();
private var _graphicsExporter:AS3GraphicsDataShapeExporter;
private var _curveSegments:int = 4;
private var _buildContainer:ObjectContainer3D;
public function Walls(tag:TagDefineSprite)
{
super();
_graphicsExporter = new
AS3GraphicsDataShapeExporter(Main.structureSwf);
// Initialise a Bezier2 class to calculate points on a
curve
_bezier = new Bezier2();
_bezier.addControlPoint(0, 0);
_bezier.addControlPoint(0, 0);
_bezier.addControlPoint(0, 0);
// Create a holder to add the walls to before merging
_buildContainer = new ObjectContainer3D();
// Grab the graphics data from the Sprite, extrude only
the paths
for each (var frameObject:FrameObject in
tag.frames[0].objects)
{
var shape:TagDefineShape =
(Main.structureSwf.getCharacter(frameObject.characterId) as
TagDefineShape);
shape.export(_graphicsExporter);
Main.testOverlay.graphics.drawGraphicsData(_graphicsExporter.graphicsData);
extrudePaths(_graphicsExporter.graphicsData);
}
var merge:Merge = new Merge(false, true, false);
merge.apply(this,
merge.applyToContainer(_buildContainer));
_buildContainer = null;
material = Main.wallsMaterial;
}
private function
extrudePaths(graphicsData:Vector.<IGraphicsData>):void
{
for each (var graphicsCommand:IGraphicsData in
graphicsData)
{
if (graphicsCommand is GraphicsPath)
{
extrudePath(graphicsCommand as
GraphicsPath);
}
}
}
private function extrudePath(path:GraphicsPath):void
{
var profile:Vector.<Vector3D>;
profile = new Vector.<Vector3D>;
//loop through the remaining commands
for (var i:int = 0; i < path.commands.length; i++)
{
// GraphicsPathCommands: 0 - NO_OP | 1 -
MOVE_TO | 2 -
LINE_TO | 3 - CURVE_TO
switch (path.commands[i])
{
case 1: // MOVE_TO - extrude profile if
exists, start new profile
if (profile.length > 0)
addExtrusion(profile);
profile = new Vector.<Vector3D>;
profile.push(new
Vector3D(path.data.shift(), 0, -
path.data.shift()));
break;
case 2: // LINE_TO - add a new profile
point
profile.push(new
Vector3D(path.data.shift(), 0, -
path.data.shift()));
break;
case 3: // CURVE_TO - add profile
points along curve
addCurve(profile, path);
break;
}
}
addExtrusion(profile);
}
private function addCurve(profile:Vector.<Vector3D>,
path:GraphicsPath):void
{
_bezier.moveControlPoint(0, profile[profile.length -
1].x,
profile[profile.length - 1].z);
_bezier.moveControlPoint(1, path.data.shift(),
-path.data.shift());
_bezier.moveControlPoint(2, path.data.shift(),
-path.data.shift());
for (var i:Number = 1/_curveSegments; i < 1; i +=
1/_curveSegments)
{
profile.push(new Vector3D(_bezier.getX(i), 0,
_bezier.getY(i)));;
}
profile.push(new Vector3D(_bezier.getControlPoint(2).X,
0,
_bezier.getControlPoint(2).Y));
}
private function addExtrusion(profile:Vector.<Vector3D>):void
{
var linearExtrude:LinearExtrude = new
LinearExtrude(null, profile,
LinearExtrude.Y_AXIS, 20, 3, false, 2, 3, null, false, false, "",
false);
_buildContainer.addChild(linearExtrude);
}
}
}
On Jun 9, 9:50 pm, Michael Iv <[email protected]> wrote:
> I get 60/60 FPS. But can you tell me why you have almost 100000 polys? I
> think with such a model you can reduce the poly count at least to 20-30%
> less.
>
>
>
>
>
>
>
>
>
> On Thu, Jun 9, 2011 at 11:33 PM, wagster <[email protected]> wrote:
> > Sure - here's a 3 storey hotel built programmatically:
>
> >http://www.pictureandword.com/test_platforms/floorplan_viewer/v2/inde...
>
> > That's pretty much worst case scenario - I don't actually need the
> > third storey, I just added it to see at what point the frame rate will
> > start dropping. It's just on the edge now with 100k polys. Any tips
> > on squeezing a bit more performance from it? I can't imagine I'll get
> > much more than that.
>
> > The absence of floors will tell you why I'm waiting for a concave
> > DelaunayMesh or preferably a Swf class. Guests will immediately fall
> > into infinity with this kind of setup.
>
> > Wag
>
> > On Jun 9, 4:16 pm, Fabrice3D <[email protected]> wrote:
> > > screendump or url of these "seriously complex building layouts" we could
> > see???
>
> > > Fabrice
>
> > > On Jun 9, 2011, at 4:46 PM, wagster wrote:
>
> > > > I know - patience is a virtue and all that :)
>
> > > > I ended up using Wumedia Swf class for the floor and LinearExtrusion
> > > > for the walls in 3.6 (everything is drawn in Flash IDE as we need to
> > > > production-line our building layouts). This has the advantage that
> > > > you can draw labels and all sorts of things on the floor - perfect for
> > > > me. Think I'll probably do the same when Swf resurfaces.
>
> > > > BTW - LinearExtrude + Merge allows for some seriously complex building
> > > > layouts at high framerates!
>
> > > > On Jun 9, 3:14 pm, Fabrice3D <[email protected]> wrote:
> > > >> no, that would be one of next classes coming.
> > > >> this one simply "connects" vectors as Mesh. It doesn't have any
> > awareness of a "path" or defined contours/constrains.
>
> > > >> Regarding architectural applications, one that I've started a while
> > ago and hope to finish one of these days, will allow you to define one or
> > more "holes", basically closed shapes, rects, circles etc
> > > >> and eventually another class would use that result to extrude. think
> > here the wall with door and window, extruded at wall thickness. But as some
> > features required are very near of booleans operations,
> > > >> so I started do more research in that field first, to see if I could
> > do this via a smarter way...
>
> > > >> I will gradually add these (hopefuly) usefull classes as I go. But I
> > can't garanty they will be released in a logical order. By that I mean that
> > like in case above of the wall being extruded
> > > >> the class doing this might be released before the one actually
> > generating the base mesh with "holes".
>
> > > >> There are still many 3.6 classes that need to join the 4.0 packages
> > and get enhanced in the process.
> > > >> As said before, all happends 1 by 1 :))
>
> > > >> Fabrice
>
> > > >> On Jun 9, 2011, at 3:48 PM, wagster wrote:
>
> > > >>> Oh cool - another prezzie from the Fabrice factory!
>
> > > >>> I put together a Delaunay class myself (for architectural generation)
> > > >>> a couple of months ago but gave up because I couldn't make it handle
> > > >>> concave shapes. Did you get that figured out? (I know, I know, I
> > > >>> could just try it out, but I'm at work and I can't wait until I get
> > > >>> home!)
>
> > > >>> On Jun 9, 11:40 am, Fabrice3D <[email protected]> wrote:
> > > >>>> Hi all,
>
> > > >>>> I've just added 2 new classes to Broomstick
> > > >>>> and 1 example class.
>
> > > >>>> - DelaunayMesh:
> > > >>>> Located in "extrusions" package this class allows you to generate
> > meshes from (random) vectors. At least 3 are required.
> > > >>>> This is very usefull in many cases, such as terrain building from
> > pointclouds data, closing shapes, architectural generation, editing tools
> > (such as Prefab ;) ) etc etc
>
> > > >>>> - Trident
> > > >>>> Our good old dev friend is back, but this time, located into "debug"
> > package instead of primitives
> > > >>>> It works exactly as the previous versions, except you are now also
> > able to change it's position and it looks a bit more sexy :)
>
> > > >>>> - Demo class
> > > >>>> I've added a simple example of a random cloud of vector3d's to mesh
> > using the Delaunay class, in the code
> > > >>>> you'll find as well the Trident in action for those new to Away and
> > even added a small snippet for the new MeshDebugger in case you've missed my
> > post on this one.
>
> > > >>>> Cheers,
> > > >>>> Fabrice
>
> --
> Michael Ivanov ,Programmer
> Neurotech Solutions Ltd.
> Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.net
> Tel:054-4962254
> [email protected]
> [email protected]
On Jun 9, 9:50 pm, Michael Iv <[email protected]> wrote:
> I get 60/60 FPS. But can you tell me why you have almost 100000 polys? I
> think with such a model you can reduce the poly count at least to 20-30%
> less.
>
>
>
>
>
>
>
>
>
> On Thu, Jun 9, 2011 at 11:33 PM, wagster <[email protected]> wrote:
> > Sure - here's a 3 storey hotel built programmatically:
>
> >http://www.pictureandword.com/test_platforms/floorplan_viewer/v2/inde...
>
> > That's pretty much worst case scenario - I don't actually need the
> > third storey, I just added it to see at what point the frame rate will
> > start dropping. It's just on the edge now with 100k polys. Any tips
> > on squeezing a bit more performance from it? I can't imagine I'll get
> > much more than that.
>
> > The absence of floors will tell you why I'm waiting for a concave
> > DelaunayMesh or preferably a Swf class. Guests will immediately fall
> > into infinity with this kind of setup.
>
> > Wag
>
> > On Jun 9, 4:16 pm, Fabrice3D <[email protected]> wrote:
> > > screendump or url of these "seriously complex building layouts" we could
> > see???
>
> > > Fabrice
>
> > > On Jun 9, 2011, at 4:46 PM, wagster wrote:
>
> > > > I know - patience is a virtue and all that :)
>
> > > > I ended up using Wumedia Swf class for the floor and LinearExtrusion
> > > > for the walls in 3.6 (everything is drawn in Flash IDE as we need to
> > > > production-line our building layouts). This has the advantage that
> > > > you can draw labels and all sorts of things on the floor - perfect for
> > > > me. Think I'll probably do the same when Swf resurfaces.
>
> > > > BTW - LinearExtrude + Merge allows for some seriously complex building
> > > > layouts at high framerates!
>
> > > > On Jun 9, 3:14 pm, Fabrice3D <[email protected]> wrote:
> > > >> no, that would be one of next classes coming.
> > > >> this one simply "connects" vectors as Mesh. It doesn't have any
> > awareness of a "path" or defined contours/constrains.
>
> > > >> Regarding architectural applications, one that I've started a while
> > ago and hope to finish one of these days, will allow you to define one or
> > more "holes", basically closed shapes, rects, circles etc
> > > >> and eventually another class would use that result to extrude. think
> > here the wall with door and window, extruded at wall thickness. But as some
> > features required are very near of booleans operations,
> > > >> so I started do more research in that field first, to see if I could
> > do this via a smarter way...
>
> > > >> I will gradually add these (hopefuly) usefull classes as I go. But I
> > can't garanty they will be released in a logical order. By that I mean that
> > like in case above of the wall being extruded
> > > >> the class doing this might be released before the one actually
> > generating the base mesh with "holes".
>
> > > >> There are still many 3.6 classes that need to join the 4.0 packages
> > and get enhanced in the process.
> > > >> As said before, all happends 1 by 1 :))
>
> > > >> Fabrice
>
> > > >> On Jun 9, 2011, at 3:48 PM, wagster wrote:
>
> > > >>> Oh cool - another prezzie from the Fabrice factory!
>
> > > >>> I put together a Delaunay class myself (for architectural generation)
> > > >>> a couple of months ago but gave up because I couldn't make it handle
> > > >>> concave shapes. Did you get that figured out? (I know, I know, I
> > > >>> could just try it out, but I'm at work and I can't wait until I get
> > > >>> home!)
>
> > > >>> On Jun 9, 11:40 am, Fabrice3D <[email protected]> wrote:
> > > >>>> Hi all,
>
> > > >>>> I've just added 2 new classes to Broomstick
> > > >>>> and 1 example class.
>
> > > >>>> - DelaunayMesh:
> > > >>>> Located in "extrusions" package this class allows you to generate
> > meshes from (random) vectors. At least 3 are required.
> > > >>>> This is very usefull in many cases, such as terrain building from
> > pointclouds data, closing shapes, architectural generation, editing tools
> > (such as Prefab ;) ) etc etc
>
> > > >>>> - Trident
> > > >>>> Our good old dev friend is back, but this time, located into "debug"
> > package instead of primitives
> > > >>>> It works exactly as the previous versions, except you are now also
> > able to change it's position and it looks a bit more sexy :)
>
> > > >>>> - Demo class
> > > >>>> I've added a simple example of a random cloud of vector3d's to mesh
> > using the Delaunay class, in the code
> > > >>>> you'll find as well the Trident in action for those new to Away and
> > even added a small snippet for the new MeshDebugger in case you've missed my
> > post on this one.
>
> > > >>>> Cheers,
> > > >>>> Fabrice
>
> --
> Michael Ivanov ,Programmer
> Neurotech Solutions Ltd.
> Flex|Air |3D|Unity|www.neurotechresearch.comhttp://blog.alladvanced.net
> Tel:054-4962254
> [email protected]
> [email protected]