Solved this problem by realizing that the order of UV coordinates must match the order of facial coordinates in order for the texture to apply itself seamlessly, and by seeing through the texture tutorial at the away3d tutorials page that the maximum value of any UV is 1.
>From there, take current vertex x coordinate / furthest right vertex x coordinate to get the u point on your image, and take current vertex y coordinate / highest vertex y coordinate to get the v. So you can express this as: UV = ( U coordinate, V coordinate ) UV = ( this_vertex.x / ( mesh_position + mesh_width/2 ) , this_vertex.y / ( mesh_position + mesh_height/2 ) ) Such that the width of the mesh != 0. This will result in a value 0 <= x | y <= 1 which corresponds to your desired image's matching pixel to apply to the mesh. I only tested it with 2D cutout style faces, not objects with a variable Z axis. On Jul 4, 4:09 am, away3dfan <[email protected]> wrote: > I was unable to post images directly. Here are the links without > leading http so as to confuse google enough to let me post them: > > UV Error: img30 . imageshack . us / img30 / 4274 / uverror . png > Original desired image: eclecti.cc / files / 2008/03 / face . jpg > > (no w w w in prefix) > > Thanks once again. > > On Jul 4, 4:02 am, away3dfan <[email protected]> wrote: > > > So that's what UVs are for! > > > I don't necessarily need a bitmap data if there's something easier, > > that's just all I found in the documentation. > > > In any case, the screen is no longer black on view (infact it's quite > > a pretty render of a texture) however the alignments are still off. > > The second face aligns correctly it seems, but I don't totally > > understand what to do with the first face to get it to align > > properly. See screenshots below if interested. > > > Here is my updated code: > > > // In class > > [Embed(source="C:/pic.jpg")] > > public var faceBitmap:Class; > > > // In function > > var texturedShape:Mesh = new Mesh(); > > var f:Face = new Face( 0:0:0, 100:0:0, 100:100:0, null, new UV(0, 0), > > new UV(1, 1), new UV(0, 1 ) ); > > var f2:Face = new Face( 0:100:0, 100:0:0, 100:100:0, null, new UV(0, > > 0), new UV(1, 1), new UV(0, 1 ) ); > > texturedShape.addFace(f); > > texturedShape.addFace(f2); > > texturedShape.material = new PhongBitmapMaterial( Cast.bitmap > > (faceBitmap) ); > > _scene.addChild( texturedShape ); > > > Please note: vertex assignments would be in the form new Vertex( 0, 0, > > 0 ), etc. I'm using the above for clarity in troubleshooting. > > > Can someone please explain to me how the UV assignments can be made to > > spread an image evenly across multiple faces? Any help is greatly > > appreciated! > > > On Jul 3, 9:00 am, Rob Bateman <[email protected]> wrote: > > > > Hey away3dfan > > > > if you want to texture a mesh with a bitmapmaterial, you will need to set > > > uv > > > coordinates on each face object to allow teh mesh to 'skin' itself with > > > the > > > bitmapdata you use in any bitmapmaterial. Have a closer look at any of the > > > primitive classes like sphere or plane to see how you create and apply > > > these > > > uv coordinates > > > > cheers > > > > Rob > > > > On Fri, Jul 3, 2009 at 8:36 AM, away3dfan <[email protected]> wrote: > > > > > In my last post here I was working with the assignment of dynamic > > > > materials to custom-defined objects, but I think this was a bit > > > > premature for my understanding, so here I'm asking a question about > > > > only one piece of my problem: > > > > > I would like to create a custom mesh (a flat plane cutout, really) and > > > > apply *one* material stretched across all the faces in the cutout (the > > > > way it is when a texture is applied to a sphere for example). This is > > > > what I tried: > > > > > // In class > > > > [Embed(source="C:/pic.jpg")] > > > > public var earthBitmap:Class; > > > > > // In function > > > > var texturedShape:Mesh = new Mesh(); > > > > var f:Face = new Face( v1a, v2a, v3a ); > > > > var f2:Face = new Face( v1b, v2b, v3b ); > > > > texturedShape.addFace(f); > > > > texturedShape.addFace(f2); > > > > texturedShape.material = new PhongBitmapMaterial( Cast.bitmap > > > > (earthBitmap) ); > > > > _scene.addChild( texturedShape ); > > > > > However, this results in the entire screen going black when the face > > > > is in view of the camera. The problem also occurs when only one face > > > > is used. Please can you tell me what is the correct way to apply an > > > > embedded texture to one face, or across multiple faces of a single > > > > mesh? This will help me very much. > > > > > Thank you! > > > > > PS: Ideally I would have created only one surface with slanted edges > > > > to create the shape I want, but I believe the only way to do it is > > > > with individual faces, so this is the method that I'm currently using > > > > even though it results in tiny spaces between a couple of the faces > > > > which I have not found a way to get rid of yet. > > > > -- > > > Rob Bateman > > > Flash Development & Consultancy > > > > [email protected]
