Vector Graphics on a Material 3.6

Software: Away3D 3.x

Avatar
Choons, Sr. Member
Posted: 27 July 2011 07:05 PM   Total Posts: 281

Hi guys,

I’ve been tasked with trying to use a vector texture on a material in 3.6. The client says he thinks MovieMaterial can load a vector graphic. If so, does it remain a scalable vector graphic or is it converted to a bitmap?

I have to be able to load the vector graphic into Flash dynamically using actionscript so I am looking at using this library to load in an SVG

http://code.google.com/p/as3svgrendererlib/

am I on the right path here? Is it possible to get a vector graphic on material in 3.6? thanks for any help/advice on this

   

Avatar
Darcey, Moderator
Posted: 27 July 2011 07:52 PM   Total Posts: 209   [ # 1 ]

There is WU media:
http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/

Example from Li in 2009 - Using swf.as
http://www.lidev.com.ar/importing-graphics-from-flash-to-away3d/

Vector shapes in 3.6
http://polygeek.com/3965_away3d_101-vector-shapes

A long time ago I used an SVG in pv3d for a floor item, but swf.as will handle that now.

Go down the swf.as path 1st and then explore the svg option.

Something like:

// 1 create / import your vector art into flash linkage id "FLAmyVectorDrawing" publish swf or mc

// 2 do your import of the swf symbol or use swc etc

var swfAsset:ByteArray = new FLAmyVectorDrawing() as ByteArray();
var 
swf:Swf = new Swf();
swf.libraryClips ["FLAmyVectorDrawing"];

var 
myVectorDrawingOC3D:ObjectContainer3D swf.parseGeometry(swfAsset) as ObjectContainer3D;

scene.addChild(myVectorDrawingOC3D); 
   

Avatar
Choons, Sr. Member
Posted: 27 July 2011 08:16 PM   Total Posts: 281   [ # 2 ]

righteous. Thanks so much, Darcey. Haven’t seen you post about any new demos on AFTC lately. Miss those exceptional demos ; )

   

Avatar
Darcey, Moderator
Posted: 27 July 2011 08:23 PM   Total Posts: 209   [ # 3 ]

Ye, I’m kind of missing my article writing… My work load for the past few months and the next few months is insane.

I can’t wait to get writing for Away 3D 4 and FP11 smile

   

Avatar
Choons, Sr. Member
Posted: 27 July 2011 08:31 PM   Total Posts: 281   [ # 4 ]

good problem to have, but yeah my just having fun with Away3D has turned into tight deadlines and lots of coffee. Side note - I have LLoyd’s in my family tree. Maybe we’re distant cousins wink

   

Avatar
Darcey, Moderator
Posted: 27 July 2011 08:36 PM   Total Posts: 209   [ # 5 ]

Away3D bring us all together :p lol

   

Avatar
Choons, Sr. Member
Posted: 27 July 2011 08:56 PM   Total Posts: 281   [ # 6 ]

looking at Li’s example. Can that vector graphic be applied on a material? Looks like he just adds the graphic to the scene.

   

Avatar
Darcey, Moderator
Posted: 27 July 2011 09:01 PM   Total Posts: 209   [ # 7 ]

Ah, not gone done the route of using the vector as a texture for a primitive or model but I would expect that it can be done via:

1. Grab vector asset via wu media and attach it to a movieclip or sprite and apply it to one of the Away3D materials. Add to MovieMaterial or one of the Sprites.

   

Avatar
Choons, Sr. Member
Posted: 27 July 2011 09:07 PM   Total Posts: 281   [ # 8 ]

ah yeah. I see MovieMaterial’s type is Sprite. I’ll give that shot and report back if it works. thanks again

   

Avatar
Choons, Sr. Member
Posted: 28 July 2011 08:23 AM   Total Posts: 281   [ # 9 ]

well I did manage to get wumedia’s VectorShapes to parse in a swf that contains vector graphics and draw them into a Sprite. That worked great but it appears that putting the sprite with vector graphics into MovieMaterial converts the vector graphics to bitmaps. So I just went a loooonnng way around to get the same results as using a simple BitmapMaterial apparently. I suppose I can uderstand that as calculating all the curves would be an astronomical computing task.

If anyone knows a way to get true vector graphics into an Away3D material, I’d love to know.

   

Avatar
Darcey, Moderator
Posted: 28 July 2011 09:41 AM   Total Posts: 209   [ # 10 ]

I don’t think there is any way to actually wrap vector shapes around a mesh and keep aspect ratio, no distortion of the vector etc.

If Swf.as brings in a vector and converts it to vertices / vectors in Away3D, then it would be about the wrapping of 1 set of vertices around another set of vertices… To do this with aspect ratio, no distortion of the vector etc, kind of like a cloth (plane) being placed over a cube, I’ve no idea bar plugging it into a physics engine.

   

Avatar
Choons, Sr. Member
Posted: 28 July 2011 10:02 AM   Total Posts: 281   [ # 11 ]

yeah when I really thought about it, i realized why that is so. Let me bounce this idea off you. The whole reason they want the vector graphics is to be able to cam zoom in very close without pixelation of the texture. Since I’m stuck with a bitmap either way, I’m thinking of taking “snapshots” of the scaled sprite by using bitmapData draw on a set rectangular area of the sprite. The sprite would get scaled larger and smaller in the background in accord with the cam zoom level. At reasonable zoom points I switch out the material’s bitmapdata (now a simple BitmapMaterial). I could be pre-render a few on either side of the zoom level for performance. The only question I have is accessing that set rectangle size snapshot area on a constantly changing sprite.

   

Avatar
Darcey, Moderator
Posted: 28 July 2011 10:10 AM   Total Posts: 209   [ # 12 ]

Need more info on the constantly changing sprite bit. But the changing of the texture on the fly is nice and easy, you just have to ensure your changing the correct face.material or cube.cubematerial etc. When rotating items and having to work out if they are in view and facing the camera, that would bring me back to searching the google group, googling and then probably posting here and in the group for help again. The only way I can think of to check if a face is in view is to either hit test it grab it with mouseclick or to loop through every face performing some set of if statments at a guess.

Just watchout if your trying to apply a filters and use various different materials on the same object (it’s what I’m fighting with at the moment). And multiple interactive materials on a single object seem to be activating others even though clearly defined unique IDs for activation are in place lol..

   

Avatar
Choons, Sr. Member
Posted: 28 July 2011 10:31 AM   Total Posts: 281   [ # 13 ]

sounds like we are working on the exact same thing! Yeah to be a bit more clear- say I have a bitmapData object a set size of 256 X 256. Initially the sprite containing the vector graphics is scaled to 1 at the same size. By the way, the sprite is no longer being used directly for the material, but instead its image has been drawn into the bitmapData object which is then used for the material. User begins zooming in the cam, and in the background the app is scaling up the sprite. At a set zoom level, another 256 X 256 bitmapData “snapshot” is taken of the now larger sprite. Instead of putting the whole image of the sprite in the bitmapData object, only a portion of the enlarged sprite is sampled. Since the graphics in the sprite are vector-based they never get pixelated and (so my theory goes) every 256 X 256 bitmap snapshot of it stay clean as well. The only thing I don’t have a handle on yet is how to sample that small square portion of a sprite that is become huge. I’ve done it with matrix ops on other bitmaps, just don’t know if that translates to sprites.

   

Avatar
Darcey, Moderator
Posted: 28 July 2011 10:41 AM   Total Posts: 209   [ # 14 ]

lol does sound very similar. You can grab me on google talk if you have it installed just add .(JavaScript must be enabled to view this email address)

You probably want to go down the bitmapdata path, I’m trying to modify the bitmapdata of a bitmapmaterial on the fly while updating the bitmapmaterial.

You may want to try:

1. Add the vector image to the stage (so you can see where it is and what you are going to be capturing for the zoom) via sprite (standard flash)

2. Take a bitmapdata.draw of that sprite and update the bitmapmaterial

3. On zoom - scaleX & Y of the sprite and do another bitmapdata.draw of it and update the bitmapmaterial again

and so on.

   

Avatar
Darcey, Moderator
Posted: 28 July 2011 10:44 AM   Total Posts: 209   [ # 15 ]

This is what I posted a few days back… I still not resolved it though.

http://away3d.com/forum/viewthread/372/

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X