   modifying created mesh
  Hello,I am using MDX9 for my final project, and I have a problem I would like to have an option to edit created meshes, right now I am using it's build-in mesh types, like polygon, box etc. What I would like to do, is to be able to edit for instance a polygon and change its shapes by changing each point position, I am not quite sure how it can be done, maybe I could use Mesh.IndexBuffer, to get all the indices which sounds quite reasonable but, how I will be sure which one I am editing. I don't want to make another 3d editor, but I want to have the basic functions for editing them.The other problem I have is it possible to instead of using multiple lights and be sure that something is lighted up properly, light up whole scene? I am making live video mapping application, and on every mesh i will be streaming different video, so i was wondering if i can make the whole scene lighted up?thanks!   
  First, I'm not familiar with MDX. However, one general approach to editing existing meshes is to "pick" one or more faces of the mesh. That's most often done by creating ray and ray direction vectors using the screen position where the mouse is clicked.Another approach is to draw the mesh and then draw points at each of the mesh vertex positions. The user can draw a select rectangle around a vertex or vertices to select them for dragging or editing in some other fashion.MDX should have some support functions for testing intersections of a ray with a mesh, and for projecting vertex positions and unprojecting screen positions.That should give you some terms to search for, either in the MDX documenation or with google.   ;  Thanks, I managed to modify mesh by creating customvertex from mesh, and then put the modyfied data back to mesh, still didn't figure out how to catch right verticles from screen cords  public Mesh getVerticles(Mesh mesh)    { verts =(CustomVertex.PositionNormalColored[])mesh.VertexBuffer.Lock(0,typeof(CustomVertex.PositionNormalColored),LockFlags.None,mesh.NumberVertices); verts[2].X = 2.0f; // example   mesh.VertexBuffer.SetData(verts, 0, LockFlags.None);   return mesh;   };  Modifying the mesh vertices themselves is how its done. Good job.With regard to selecting a particular face or vertex, that's usually done by getting user input via the mouse - by clicking on a face or dragging a rectangle around one or more vertices on-screen.Perhaps someone more familiar with MDX can provide more information, but you'll have to learn about picking, unprojecting mouse positions and projecting vertex positions. You can google or search this site for information on "picking," "unproject mouse" and "project world position" to get an idea of the principles that are involved.   ;  Hey,thanks, it helped me to find the right topic, I got it kind of working but I have some strange problemsthat's the code that does the job   public IntersectInformation[] unprojectMouse(int x, int y)   {  Vector3 near = new Vector3((float)x,(float)y,0);  Vector3 far = new Vector3((float)x, (float)y, 1);  near.Unproject(this._device.Viewport, this._device.Transform.Projection, this._device.Transform.View, this._device.Transform.World);  far.Unproject(this._device.Viewport, this._device.Transform.Projection, this._device.Transform.View, this._device.Transform.World);  IntersectInformation[] ii = new IntersectInformation[MeshList.Count];  foreach (MeshView mesh in MeshList)  { mesh.mesh.Intersect(near, far, out ii);  }  return ii;   }but in the foreach section, which iterates through all meshes, it only returns intersection with the mesh that is last in the collection, for ex. i have 2 polygons named polygon1 and polygon2, and it returns intersection of the second one only, when i add the second one to the collection first, and then second, if catches the other one, I hope my explanation was understandable... anybody know what the heck is going on there?   ;  Did you forget to provide an index to the info you wanted filled in? Something like:int idx = 0;foreach (MeshView mesh in MeshList){   mesh.mesh.Intersect(near, far, out ii[idx]);    idx++;};  Hey,thats not a issue I changed this one but it doesn't matter I belive the problem is somewhere else, because intersect returns true/false if it intersects or no, and in this case it return false, what's even more strange, when i am creating meshes they are initialy at 0,0,0 i have a function so i can move the meshes around scene, when i move them on sides, and i click the one on the one that was added last and it returns true, for all 3. its mind blowing why is thatthis is the code i changedpublic int unprojectMouse(int x, int y)   {  Vector3 near = new Vector3((float)x,(float)y,0);  Vector3 far = new Vector3((float)x, (float)y, 1);  bool ret = false;  near.Unproject(this._device.Viewport, this._device.Transform.Projection, this._device.Transform.View, this._device.Transform.World);  far.Unproject(this._device.Viewport, this._device.Transform.Projection, this._device.Transform.View, this._device.Transform.World);  far.Subtract(near);  int idx=0;  ii = new IntersectInformation[MeshList.Count];  foreach (MeshView mesh in MeshList)  { ret = mesh.mesh.Intersect(near,far, out ii[idx++]); if (ret) { MessageBox.Show(mesh.meshName); }  }   return -1;   }for moving the meshes i have something like this its in the MeshView class, which trough i am iterating with the foreach public void DrawMe()   {  device.Transform.World = Matrix.Translation(this._positionXYZ);  this._mesh.DrawSubset(0);   };  I realize English is probably your second language, but your posts are very difficult to read. When describing a technical issue or asking a technical question, perhaps using a few more periods and appropriate captital letters here and there would help.Try using the mesh transform instead of the device's world transform to unproject your near/far vectors. Consider what unprojecting does: your mesh vertices are located at the origin, but draw to the screen using a transform. When you click on the screen, that position is interpreted as being at that translated world position. To do the intersection, the vectors created for the mouse position need to be translated back to the origin where testing of the intersections is done.   ;Quote:Original post by BuckeyeI realize English is probably your second language, but your posts are very difficult to read. When describing a technical issue or asking a technical question, perhaps using a few more periods and appropriate captital letters here and there would help.no doubts about that :), sorry... I will try harder :)Quote:Try using the mesh transform instead of the device's world transform to unproject your near/far vectors. I tought that world transform is the right way for positioning meshes, other thing is that Mesh class does not have any method for what are you talking about, I could convert it to customvertex and from there change all vertices position by some value, is this what you mean?Quote:Consider what unprojecting does: your mesh vertices are located at the origin, but draw to the screen using a transform. When you click on the screen, that position is interpreted as being at that translated world position. To do the intersection, the vectors created for the mouse position need to be translated back to the origin where testing of the intersections is done.I understand what you mean, but I tought that when I make a transformation to the world matrix, it is kind of saved in the device.transform.world... because if this would not be true, I would not be able to position all the meshes separately, I belive you are right, it's my first MDX project and all the 3D transformations and thinking in 3 dimensions makes me dizzy;  I checked the thing about transform.matrix, and once I make the change to the matrix, the change is there so when I am unprojecting far, and near vector it has the changed world matrix, so I guess It should work fine, as the unproject is working in the same world matrix[Edited by - azjata on November 19, 2010 3:35:46 PM]