Trin Posted June 10, 2010 Report Share Posted June 10, 2010 HI Lavas, i want to know if there is any method to determin the normal vector for any specific point on a 3d object?! Actually i dont need to show it on the front panel, ijust need to save the normal vector data. Looking forward for hearing anything Quote Link to comment
vugie Posted June 10, 2010 Report Share Posted June 10, 2010 I don't understand the context... All the normal data for the mesh is the data you provide during mesh inititialization (one normal vector either per vertex or per face). You may also use respective property to get Normal Array. It is not possible for standard objects like sphere or cone. If you have per vertex binding and you want to determine normal of point which lays between vertices, you have to make a weighted sum of normals form 3 (for triangles) or 4 (for quads) closest vertices. You have to remember that when the object is rotated or not uniformly scaled, norwar vectors should be transformed as well. Quote Link to comment
Trin Posted June 10, 2010 Author Report Share Posted June 10, 2010 Thanks for your reply, may be i should put it in this way, what i really mean is a funtion/method of 3d picture control to calculate normal vector. attach is a simple vi that load a wrl file and should calculate normal vector of the marked point inside "mouse down" event handler. Cheers P.s: i cannot load a wrl file, there is an Error says You aren't permitted to upload this kind of file cube4b.vi Quote Link to comment
vugie Posted June 10, 2010 Report Share Posted June 10, 2010 Ok. As I said it is only possible when object hit with mouse is a mesh (you can check with trying to downcast reference of object's drawable to mesh class and checking for an error). You are loading an external file, so you cannot be sure that it contains normal data (normals cause that objects look smoother). Lets assume that it does not contain such data and you have to calculate it from face orientation. So you have to find a face clicked with mouse. PickPoint method gives you only 3D coordinates not related to geometry. Use "Vertex Array" and "Indices" properties of the mesh to get information about faces of clicked object and than search for the face which contain point you acquired with PickPoint. When you find is calculation normal is as simple as calculating cross product of two vectors, but searching for the face is not so simple. PickPoint does this behind the scenes, but unfortunately it doesn't provide this information. There are a lot of methods to find a face: from relatively simple and slow to complex and fast. The simplest is searching faces one by one checking whether it contain a point (also few methods for that). What to use is dependent on complexity of your geometry, frequency of performing the search and any additional information you know about the geometry. Quote Link to comment
Trin Posted June 10, 2010 Author Report Share Posted June 10, 2010 Thanks vugi, as usual you gave a great hints. well, i should say that i checked my wrl code, and it has the normal vector data.my question is how i can relate the mouse coord to wrl for determining in which face it is?is there any sample VI that i can get some ideas from it. Also, how i can get a reference to a 3D scene Mesh, which has a Normal array, as far as i understand the 3D scene mesh has a property node that make it possible to read the normal vector. The only VI that i can get some idea is the http://decibel.ni.com/content/docs/DOC-2059 i am trying to reverse the codes to get some ideas, but on the other hand it is somehow complicated and i am a newbie in Labview. Thanks for any help, Quote Link to comment
vugie Posted June 11, 2010 Report Share Posted June 11, 2010 Also, how i can get a reference to a 3D scene Mesh, which has a Normal array, as far as i understand the 3D scene mesh has a property node that make it possible to read the normal vector. Here is a method: You have to check Draw Mode (triangles or quads) in order to know hoe to interpret Indices (refer to mesh example in LV). It's also good to check Normal Binding Mode (whether normals are defined per vertex, per face or not binded at all). 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.