as an aside:

In one (circular) LatheExtrusion the profile was described as exact
shapes (arcs and lines). Also, the profile changes dynamically. So I
obtained a higher resolution profile than the one I extruded and used 

package {
  import Kreis;
  import away3d.core.math.MatrixAway3D;
  import away3d.core.math.Number3D;
  import flash.display.BitmapData;
  public class NormalMapGeneratorCircularExtrusion {
    private var _profileNormals : Array;
    //private var _axis : String; // around y axis only for now
    private var _normalMap : BitmapData;
    private var _width : uint;
    private var _height : uint;

    /** 
        NormalMapGeneratorCircularExtrusion
        profileNormals : normals of the profile (normalized)
     **/
    public function NormalMapGeneratorCircularExtrusion(profileNormals : Array, 
//axis : String, 
                                                        width : uint):void {
      var stepAngle : Number = 360.0 / width;
      var rot : MatrixAway3D = new MatrixAway3D;
      _profileNormals = profileNormals;
      //_axis = axis;
      _height = _profileNormals.length;
      _width = width;
      _normalMap = new BitmapData(_width, _height);

      var point : Number3D = new Number3D;
      for (var x : uint = 0; x < _width; x++) {
        rot.rotationMatrix(0.0, 1.0, 0.0, Kreis.radians(-stepAngle*x));
        for (var y : uint = 0; y < _height; y++) {
          point.clone(profileNormals[y]);
          point.rotate(point, rot);
          var r : int = 127 + point.x * 127;
          var g : int = 127 + point.y * 127;
          var b : int = 127 + point.z * 127;
          _normalMap.setPixel(x, y, 
                              ((r>255) ? 255 : r) << 16 | ((g>255) ? 255 : g)  
<< 8 | ((b>255) ? 255 : b));
        }
      }
    }
    public function get normalMap():BitmapData {
      return _normalMap;
    }
  }

}

in order to generate a much more detailed normal map.

I was thinking that the LatheExtrusion class could actually be
modified to optionally compute a normal map from an optional
high-resolution profile when the extrusion is done.

Best regards,

Marko

At Tue, 8 Jun 2010 08:55:48 -0700 (PDT),
timdiacon wrote:
> 
> OK cheers guys,
> 
> Unfortunately the math in that class is way over my head so good to
> know you have an idea where it's going wrong.
> 
> I shall await any further developments with eager anticipation ;-)
> 
> On May 19, 10:58 pm, Fabrice3D <[email protected]> wrote:
> > problem is more linked to face neighbourgs calculation I think, I've 
> > noticed vertex normals being equal to face normal itself.
> > its a problem I want to look at.
> > recalcucating each normals "by hand" in prefab allows perfectly smooth 
> > surfaces, without changing the gnerated mesh at all
> > same applies to all extrusions.
> >
> > but I'll know for sure once I come to it.
> >
> > Fabrice
> >
> > On May 19, 2010, at 11:15 PM, Rob Bateman wrote:
> >
> > > Yes, taking a quick look it seems the problem here is that the lathe 
> > > creates separate vertices for each face segment along the axis of a lathe 
> > > - which creates problems for the vertex normal calculations. this could 
> > > be potentially fixed by using the weld class on the created lathe to weld 
> > > together any duplicate vertex positions, although fab would know more as 
> > > these are his classes. fab?
> >
> > > On Mon, May 10, 2010 at 4:42 PM, timdiacon <[email protected]> 
> > > wrote:
> > > Hello,
> >
> > > I know this has been mentioned a couple of times before here...
> >
> > >http://groups.google.com/group/away3d-dev/browse_thread/thread/52b00f...
> >
> > > and here
> >
> > >http://groups.google.com/group/away3d-dev/browse_thread/thread/eb3543...
> >
> > > Just thought I would mention I have tested the now renamed
> > > LatheExtrusion in both 2.5 and 3.5 and this problems still seems to be
> > > there :(
> >
> > > The following example shows the results in 3.5 which give a sort of
> > > flat shaded effect?
> >
> > >http://www.iamarobot.co.uk/lathee/main.html
> >
> > > I'm desperate to create some nicely shaded lathe objects, has anyone
> > > got any further insight into this?
> >
> > > --
> > > Rob Bateman
> > > Flash Development & Consultancy
> >
> > > [email protected]
> > >www.infiniteturtles.co.uk
> > >www.away3d.com

Attachment: pgpcNxydFG8rI.pgp
Description: PGP signature

Reply via email to