No, I didnt find any problem like that. Guess Im luckyer! On Tue, Sep 2, 2008 at 10:18 PM, Ari Braginsky <[EMAIL PROTECTED]> wrote:
> > Li, > > Thank you for your post. I'm not sure if your solution is the same as > the solution that I need for my problem. > > To clarify, I'm moving a point around on a mesh that has a bitmap > image inside of it. When I move that point, I need to track the > relative position of that point on the bitmap in normal 2D space in > order to measure the pixel color value at that point. > > Because of the subdivision values, the bitmap image inside of the mesh > is deformed such that when your point is on top of a feature in the > bitmap mesh, it doesn't exactly line up with the same converted (by > way of the mesh X and Y scale division method) point on the 2D > bitmap. It is somewhat off. > > I need to be able to adjust for the subdivision distortion. > > Is this similar to your problem that was solved with your solution? > > Thanks, > Ari > > > On Sep 2, 8:06 pm, Li <[EMAIL PROTECTED]> wrote: > > Hey Ari, > > > > Ive been working with a similar issue in reflections. The solution I used > > might be useful to you. The particular problem I had was, once I obtained > a > > 3d point that I knew was on the surface of a plane, what would be the 2d > > coordinates of that point on the plane? The solution involved determining > > the top side and left side vectors of the plane, obtaining a vector from > the > > top left corner of the plane to the 3d point, and then using dot products > to > > project that vector onto the side vector. That gives you a scalar value > that > > corresponds to the coordinate system transformation of the point. > > > > If you think it might help you, here is the code: > > > > //Three vertices. > > edgePoint = getVertexGlobalPosition(plane.vertices[0], > > plane); > > var p2:Number3D = > getVertexGlobalPosition(plane.vertices[1], > > plane); > > var p3:Number3D = > getVertexGlobalPosition(plane.vertices[4], > > plane); > > > > //Side vectors. > > topVector = new Number3D(); > > topVector.sub(p2, edgePoint); > > sideVector = new Number3D(); > > sideVector.sub(p3, edgePoint); > > > > wRatio = MovieMaterial(plane.material).movie.width/plane.width; > > hRatio = > > MovieMaterial(plane.material).movie.height/plane.height; > > > > //TRANSLATE GLOBAL TO PLANE. > > //Translates a world 3D point to a corresponding 2D point > on > > the plane's material. > > private function > > translateGlobalToPlane(point:Number3D):Point > > { > > /* > > Finds a vector from one of the corners of the > plane > > to the point, > > and projects this vector on its sides, > considering > > scaling. > > */ > > var v:Number3D = new Number3D(); > > v.sub(point, edgePoint); > > return new > > Point(wRatio*v.dot(topVector)/topVector.modulo, hRatio*(this.height - > > v.dot(sideVector)/sideVector.modulo)); > > } > > > > //GET VERTEX GLOBAL POSITION. > > //Translates vertex coordinates to world coordinates. > > private function getVertexGlobalPosition(vertex:Vertex, > > vertexContainer:Object3D):Number3D > > { > > var m:Matrix3D = new Matrix3D(); > > m.tx = vertex.x; > > m.ty = vertex.y; > > m.tz = vertex.z; > > m.multiply(vertexContainer.transform, m); > > return new Number3D(m.tx, m.ty, m.tz); > > } > > > > On Tue, Sep 2, 2008 at 9:34 PM, Ari Braginsky <[EMAIL PROTECTED]> > wrote: > > > > > I'm having an issue retrieving 2D coordinates off of a mesh based on a > > > 3D object's position on the mesh. > > > > > You can normally retrieve the 2D coordinates on the bitmap making up > > > the mesh by dividing the coordinates of the object by the mesh's X and > > > Y scale values (see extrusions/CollisionMap.as class). > > > > > However, if you look at the position on the mesh and compare it to the > > > raw bitmap, due to some deformations that happen to the mesh with > > > certain subdivision values, the objects that appear in the bitmap > > > don't line up with the 2D coordinates on the raw bitmap. If you tweak > > > the subdivision values, the objects on the bitmap in the mesh move > > > around/get squashed/etc. > > > > > Example: > > > > > Create a bitmap with a circle in the center filled with the color red. > > > > > Create an elevation using a flat height map and use the bitmap for its > > > skin. > > > > > When rendered in 3D, you will see the red circle in the center of the > > > mesh. If you move your mouse over it, you can translate the 3D > > > coordinates into 2D space and divide them by the mesh's X and Y scale > > > values to get the real coordinates on the raw bitmap. > > > > > What I'm seeing with subdivision values X = 200 and y = 200 is that my > > > point on the mesh doesn't correlate to the same point on the 2D bitmap > > > when I convert the 3D coordinates to 2D, taking into account the mesh > > > scale values. > > > > > Is there something else I need to do to account for the subdivision > > > values? > > > > > If I didn't want any deformation of the mesh, are there subdivision > > > values I can use such that 3D points on the mesh would exactly match > > > up with 2D points on the associated bitmap? > > > > > Thanks, > > > Ari >