- Home /
rotating mesh without changing position of its vertices in world space?
Hello, i would like to be able to rotate my 3d mesh without changing the world space position of its vertices, using drag from the mouse or touch pad.
currently, i am rotating the mesh using the mouse like this:
float rotX = Input.GetAxis("Mouse X") * 2 * Mathf.Deg2Rad;
float rotY = Input.GetAxis("Mouse Y") * 2 * Mathf.Deg2Rad;
mesh.transform.RotateAround(Vector3.up, -rotX);
mesh.transform.RotateAround(Vector3.right, rotY);
which works well for dragging the mouse/touchpad. however, i am using an octree for collisions with the mesh, which is built when the mesh is initialized (with the starting mesh world space vertices), but when i rotate the mesh as above, the world space vertex positions change, so i have to rebuild my octree on every frame (which will not perform well in my case with 10000s of vertices).
is there a way to make it appear as if the object is rotating (maintaining the same behavior as my code above), while keeping the world space vertices the same?
thanks
Unless I misunderstand what you're writing about, I can't even make sense out of your question. $$anonymous$$y reaction is that the very expected act of altering a transform (rotation or translation) is precisely so the world coordinates of the vertices of the mesh are moved, and do so without moving the vertices in the local coordinate space of the mesh. That's the basic, fundamental operation of the GPU's means of putting objects in view.
The only way you can appear to rotate a mesh without moving the mesh is to move the camera around the object. In such a case the object's world space isn't altered because the camera is what moves. That only makes sense if there's no environment, no other objects in the scene.
With that said, I have no idea why you're motivated to perform collisions using an octree as that implies PhysX isn't perfor$$anonymous$$g collision testing, and collision tests are among the most consu$$anonymous$$g of the work a PhysX engine does, meaning that doing collision testing in C# makes no sense at all.
Obviously I have little information from which to divine what you're really doing, and I sense that is necessary in order to be of any help to you at all.