Drawing a dashed line

Software: Away3D 4.x

Hector, Sr. Member
Posted: 19 December 2011 10:36 AM   Total Posts: 137

Hi guys,
I want to make a 3d drawing application in away3D v4. At the moment I can draw lines using ‘linearExtrude’, although I’m not sure if this is the best way to do it.

I need to create dashed and dotted lines. At the moment I know PathUtils.getPointsOnCurve(), which allows me to split a segment in different parts, but segments are not all the same length and I need the dashed lines to be the same length.

What are the best tools to do this? should I check splines?

Maybe it’s easier using a texture? Is it possible to keep the texture from stretching and aligned in every segment?

Does anybody knows if more drawing tools or things like curveSegment will be available soon?

   

Hector, Sr. Member
Posted: 22 December 2011 06:00 PM   Total Posts: 137   [ # 1 ]

In case it may help somebody I will describe what I’m doing at the moment:

I get the path that the user previously draw.
Get the path length, calculate dashed and gap spaces for every segment and use getPointsOnCurve() to get the new segments position.
Extrude every segment and merge them all together.

Seems working until I find a better method.

   

Avatar
Fabrice Closier, Administrator
Posted: 22 December 2011 08:51 PM   Total Posts: 1265   [ # 2 ]

If you use point on curve, you will have different length for each dash.
You need to use a distribute algorithm, which basically is measure the distance from last point along the curve by adding small amount of time to the pointer. This is can be slow if you want it very accurate, but I’ve seen nice and fast results with some threshold to define howmany attempts you do per dash. This way you still can draw your dashed curve fast.
This is one of the unfinished addons I’ve started long ago for the Path class.

   

Hector, Sr. Member
Posted: 22 December 2011 09:06 PM   Total Posts: 137   [ # 3 ]

Thanks Fabrice,

Yes, I calculate the amount of dashes based on the percent of distance that every segment takes in the path length. Also, If the user has selected arrow heads for the lines I merge them following the line direction.

Thanks for the hard work. I look forward for those addons. My next step is to make the same lines parabolic, so the user can modify the bending and elevation of each line.

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X